Class PathHelper
- java.lang.Object
-
- org.fugerit.java.core.lang.helpers.reflect.PathHelper
-
public class PathHelper extends Object
Simple class to look up a property path in a java object- Author:
- Matteo a.k.a. fugerit
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
CONTINUE_ON_NULL
Constant for continuing on empty path valuestatic boolean
EXIT_ON_NULL
Constant for stopping on empty path value
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
bind(String path, Object target, Object value)
Bind a value to a path in an objectstatic boolean
bind(String path, Object target, Object value, Class<?> paramType, boolean tryInit)
Bind a value to a path in an object.static boolean
bind(String path, Object target, Object value, Class<?> paramType, boolean tryInit, FacadeImplFinder facadeImplFinder)
Bind a value to a path in an object.static Object
bindInit(String path, Object target)
Init a path in an object using initEmptyField() on any property in the path.static Object
initEmptyField(String property, Object target)
static Object
initEmptyField(String property, Object target, FacadeImplFinder facadeImplFinder)
Init a property on object if emptystatic Object
lookup(String path, Object target)
Lookup for a value by getter methods ( return null when a null is encountered ) If a method in path method is not found will raise exceptionstatic Object
lookup(String path, Object target, boolean continueOnNull)
Lookup for a value by getter methodsstatic Object
lookupContinueOnNull(String path, Object target)
Lookup for a value by getter methods ( will continue on null value and eventually raise an exception) If a method in path method is not found will raise exception If a method in path return null will stop and return nullstatic Object
lookupMethod(String path, Object target)
Lookup for a value by full method value (no get prefix is assumed) If a method in path method is not found will raise exception If a method in path return null will stop and return nullstatic Object
lookupMethod(String path, Object target, boolean continueOnNull)
Lookup for a value by full method value (no get prefix is assumed) If a method in path method is not found will raise exception
-
-
-
Field Detail
-
CONTINUE_ON_NULL
public static final boolean CONTINUE_ON_NULL
Constant for continuing on empty path value- See Also:
- Constant Field Values
-
EXIT_ON_NULL
public static final boolean EXIT_ON_NULL
Constant for stopping on empty path value- See Also:
- Constant Field Values
-
-
Method Detail
-
initEmptyField
public static Object initEmptyField(String property, Object target, FacadeImplFinder facadeImplFinder)
Init a property on object if empty- Parameters:
property
- the property to inittarget
- the target objectfacadeImplFinder
- facade for finding target property type- Returns:
- the object used to initialized the empty field
- Throws:
ConfigRuntimeException
- may throw ConfigRuntimeException seeSafeFunction
-
bindInit
public static Object bindInit(String path, Object target)
Init a path in an object using initEmptyField() on any property in the path.- Parameters:
path
- the path in the objecttarget
- the target object- Returns:
- the last created object
-
bind
public static boolean bind(String path, Object target, Object value, Class<?> paramType, boolean tryInit)
Bind a value to a path in an object.- Parameters:
path
- the pathtarget
- the target objectvalue
- the value to setparamType
- the property class typetryInit
- iftrue
will try to init any null object in path- Returns:
- if the binding is successful
-
bind
public static boolean bind(String path, Object target, Object value, Class<?> paramType, boolean tryInit, FacadeImplFinder facadeImplFinder)
Bind a value to a path in an object.- Parameters:
path
- the pathtarget
- the target objectvalue
- the value to setparamType
- the property class typetryInit
- iftrue
will try to init any null object in pathfacadeImplFinder
- facade for finding implementing class- Returns:
- if the binding is successful
-
bind
public static boolean bind(String path, Object target, Object value)
Bind a value to a path in an object- Parameters:
path
- the pathtarget
- the target objectvalue
- the value to set- Returns:
- if the binding is successful
-
lookupMethod
public static Object lookupMethod(String path, Object target, boolean continueOnNull)
Lookup for a value by full method value (no get prefix is assumed) If a method in path method is not found will raise exception- Parameters:
path
- the path in the object (ex. prop1.prop2)target
- the target objectcontinueOnNull
-true
to continue on null value and eventually raise an exception,false
to return null when a null is encountered- Returns:
- the value found in the path
-
lookupMethod
public static Object lookupMethod(String path, Object target)
Lookup for a value by full method value (no get prefix is assumed) If a method in path method is not found will raise exception If a method in path return null will stop and return null- Parameters:
path
- the path in the object (ex. prop1.prop2)target
- the target object- Returns:
- the value found in the path
-
lookup
public static Object lookup(String path, Object target, boolean continueOnNull)
Lookup for a value by getter methods- Parameters:
path
- the path in the object (ex. prop1.prop2)target
- the target objectcontinueOnNull
-true
to continue on null value and eventually raise an exception,false
to return null when a null is encountered- Returns:
- the value found in the path
-
lookup
public static Object lookup(String path, Object target)
Lookup for a value by getter methods ( return null when a null is encountered ) If a method in path method is not found will raise exception- Parameters:
path
- the path in the object (ex. prop1.prop2)target
- the target object- Returns:
- the value found in the path
-
lookupContinueOnNull
public static Object lookupContinueOnNull(String path, Object target)
Lookup for a value by getter methods ( will continue on null value and eventually raise an exception) If a method in path method is not found will raise exception If a method in path return null will stop and return null- Parameters:
path
- the path in the object (ex. prop1.prop2)target
- the target object- Returns:
- the value found in the path
-
-