1

Code:

class MyClass {
    private String field1;
    private Long field2;
    //getters and setters also here
}

List<MyClass> myClassList = new ArrayList<>();
    //getting my list filled

Now I need to set e.g. field1 for all objects in list to some value. I can do it with:

forEach(myClassList).setField1("some value");  

But how can I set some field dynamically, passing field name as string "field1" or "field2" etc.?

DT7
  • 1,615
  • 14
  • 26
Jack
  • 435
  • 2
  • 6
  • 16

1 Answers1

0

What you're asking is countrary to the main principle on which lambdaj is based. I designed it to allow to invoke the methods of your Beans in a strongly typed way. In this way you have all the help that your favorite IDE can give you like autocompletion. Moreover if you'll decide to rename that method your IDE will be able to automatically change the name for you or at least you'll a compilation error instead of finding the problem only at runtime.

Mario Fusco
  • 13,548
  • 3
  • 28
  • 37