Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for generating static function/predicate for object methods #137

Open
cmadsen opened this issue Feb 25, 2013 · 0 comments
Open

Support for generating static function/predicate for object methods #137

cmadsen opened this issue Feb 25, 2013 · 0 comments

Comments

@cmadsen
Copy link

cmadsen commented Feb 25, 2013

In e.g. google guava there is a lot of boiler plate involved when using guavas functional features with std. java member functions

class Person {
  ...
  public String getName() {
    return name;
  }

  public boolean nonSmoker() {
    return nonSmoker;
  }

  public static final Function<String, Person> GET_NAME = new Function<String, Person>() {
    public String apply(Person p) {
       return p.getName();
    }
  }

  public static final Predicate<Person> NON_SMOKER = new Predicate<Person>() {
    public boolean apply(Person p) {
       return p.nonSmoker();
    }
  }

}

String personName = fromNullable(myPerson).transform(GET_NAME).or("");
Collection<String> nonSmokerNames = from(personList).filter(NON_SMOKER).transform(GET_NAME).toImmutableList();

Any chance of getting lombok-pg to generate this via something like this:

class Person {
  @FunctionFor
  public String getName() {
    return name;
  }
  @PredicateFor
  public boolean nonSmoker() {
    return nonSmoker;
  }
}

?
Funcito does something like this but it is still nosiy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant