public class LazySetterMethod extends Object
| Constructor and Description |
|---|
LazySetterMethod(Object target,
String fieldNames,
LazyGetterMethod value)
Constructs a LazySetterMethod object for the given source object, field
names as a string separated by '.'
|
LazySetterMethod(Object target,
String fieldNames,
Object value)
Constructs a LazySetterMethod object for the given source object, field
names as a string separated by '.'
|
| Modifier and Type | Method and Description |
|---|---|
void |
invoke()
Invokes the getter/setter chain based on the source object.
|
public LazySetterMethod(Object target, String fieldNames, Object value)
LazySetterMethod#LazySetterMethod(java.lang.Object, java.lang.String[], java.lang.Object[])
with the second parameter fieldNames.split("\\.").target - The object on which to invoke the getter/setter chainfieldNames - The field names which should be used for the setter
determinationargs - The arguments used for the setter methodpublic LazySetterMethod(Object target, String fieldNames, LazyGetterMethod value)
This constructor is equal to #
LazySetterMethod#LazySetterMethod(java.lang.Object, java.lang.String, java.lang.Object[])
except that this constructor shows that #LazyGetterMethod also
can be used as parameter. The LazyGetterMethods will be invoked lazily
target - The object on which to invoke the getter/setter chainfieldNames - The field names which should be used for the setter
determinationargs - The arguments used for the setter methodpublic void invoke()
throws InvocationTargetException,
IllegalAccessException
Example of how the chaining works:
public A(B b){
this.b = b;
}
public B getB(){
return b;
}
}
class B{
private String s;
public B(String s){
this.s = s;
}
public void setS(String s){
this.s = s;
}
}
class A{
private B b;
new LazySetterMethod(new A(new B("")), "b.s", "value").invoke()
is equal to
new A(new B("")).getB().setS("test");
and
new LazySetterMethod(new A(new B("")), "b.s", new LazyGetterMethod(new B("lazyValue"), "s").invoke()
is equal to
new A(new B("")).getB().setS(new B("lazyValue").getS());
Copyright © 2020 Blazebit. All rights reserved.