Class ReflectionValueExtractor
java.lang.Object
org.apache.maven.shared.utils.introspection.ReflectionValueExtractor
Using simple dotted expressions to extract the values from an Object instance,
For example we might want to extract a value like: project.build.sourceDirectory
The implementation supports indexed, nested and mapped properties similar to the JSP way.
- Author:
- Jason van Zyl , Vincent Siveton
- See Also:
-
Method Details
-
evaluate
public static Object evaluate(@Nonnull String expression, @Nullable Object root) throws org.apache.maven.shared.utils.introspection.IntrospectionException The implementation supports indexed, nested and mapped properties.
- nested properties should be defined by a dot, i.e. "user.address.street"
- indexed properties (java.util.List or array instance) should be contains
(\\w+)\\[(\\d+)\\]
pattern, i.e. "user.addresses[1].street" - mapped properties should be contains
(\\w+)\\((.+)\\)
pattern, i.e. "user.addresses(myAddress).street"
- Parameters:
expression
- not null expressionroot
- not null object- Returns:
- the object defined by the expression
- Throws:
org.apache.maven.shared.utils.introspection.IntrospectionException
- if any
-
evaluate
public static Object evaluate(@Nonnull String expression, @Nullable Object root, boolean trimRootToken) throws org.apache.maven.shared.utils.introspection.IntrospectionException The implementation supports indexed, nested and mapped properties.
- nested properties should be defined by a dot, i.e. "user.address.street"
- indexed properties (java.util.List or array instance) should be contains
(\\w+)\\[(\\d+)\\]
pattern, i.e. "user.addresses[1].street" - mapped properties should be contains
(\\w+)\\((.+)\\)
pattern, i.e. "user.addresses(myAddress).street"
- Parameters:
expression
- not null expressionroot
- not null objecttrimRootToken
- trim root token yes/no.- Returns:
- the object defined by the expression
- Throws:
org.apache.maven.shared.utils.introspection.IntrospectionException
- if any
-