public final Y getNullSafeValue(X target) { return getValue(target, true); }
@Override public Y getValue() { return expression.getValue(source); }
/** * Invokes the getter chain based on the source object. First the source * object is used as invocation target for the first getter then the results * of the previous operations will be used for the invocation. * <p> * Example of how the chaining works: * <p> * class A{ B getB(){ // return b element } } * <p> * class B{ String getA(){ // return a element } } * <p> * new LazyGetterMethod(new A(), "a.b").invoke() * <p> * is equal to * <p> * new A().getB().getA() * * @return The result of the last getter in the chain * @throws InvocationTargetException {@link Method#invoke(java.lang.Object, java.lang.Object[]) } * @throws IllegalAccessException {@link Method#invoke(java.lang.Object, java.lang.Object[]) } */ public final Y getValue(X target) { return getValue(target, false); }
/** * Invokes the getter chain based on the source object. First the source * object is used as invocation target for the first getter then the results * of the previous operations will be used for the invocation. * <p> * Example of how the chaining works: * <p> * class A{ B getB(){ // return b element } } * <p> * class B{ String getA(){ // return a element } } * <p> * new LazyGetterMethod(new A(), "a.b").invoke() * <p> * is equal to * <p> * new A().getB().getA() * * @return The result of the last getter in the chain * @throws InvocationTargetException {@link Method#invoke(java.lang.Object, java.lang.Object[]) } * @throws IllegalAccessException {@link Method#invoke(java.lang.Object, java.lang.Object[]) } */ public Object invoke() throws InvocationTargetException, IllegalAccessException { return expression.getValue(source); } }
@SuppressWarnings("unchecked") public static <X, Y> Y getValue(X target, String propertyPath, Class<Y> valueClass) { return getExpression((Class<X>) target.getClass(), propertyPath, valueClass).getValue(target); }
public static <X, Y> Y getValue(Class<X> source, X target, String propertyPath, Class<Y> valueClass) { return getExpression(source, propertyPath, valueClass).getValue(target); }