Gangmax Blog

自由之思想,独立之精神

Groovy Grape

| Comments

From here and here.

Groovy Grape is Groovy’s dependency manager. A big difference between Grape and other language dependency managers like pip, gem and npm is that, it uses language element(annoation, method call) to describe the dependencies inside a Groovy file, rather than a file out of the program itself like “requirements.txt”, “Gemfile” and “package.json”.

Git Branch Commands

| Comments

1
2
3
4
5
6
7
8
9
10
11
12
# 1. Add the "-u" option in "push" command to make your local created branch
# have the upstream branch setting.
git push -u origin a-new-branch
# The command above will create the "a-new-branch" on remote git server, and
# add associate the remote branch with your local "a-new-branch", aka setting
# upsteam branch of your local "a-new-branch" branch. Without this, when you
# pull after the "push" action, you are ask to add such upstream info manually.

# 2. Find out which remote branch is the upstream branch of (tracked by) a
# local branch.
# From: https://stackoverflow.com/questions/171550/find-out-which-remote-branch-a-local-branch-is-tracking 
git branch -vv

Java Lambda Type Inference

| Comments

I see code like this:

Service.java
1
2
3
4
5
6
7
8
9
@Override
public void log(Request request) {
    // ...
}

@Override
public void submit(Request request) {
    Utils.submit(request, request -> log(request));
}

Here is the code in “Utils.java”:

Utils.java
1
2
3
4
public static void submit(Request request, Consumer<Request> comsumer) {
    // Do something.
    comsumer.accept(request);
}

“request -> log(request)” is a lambda expression, but how does it become a “Consumer”?