Class ReflectionValueExtractor

java.lang.Object
org.apache.maven.internal.impl.model.reflection.ReflectionValueExtractor

public class ReflectionValueExtractor extends Object
Using simple dotted expressions to extract the values from an Object instance using JSP-like expressions such as project.build.sourceDirectory.

In addition to usual getters using getXxx or isXxx suffixes, accessors using asXxx or toXxx prefixes are also supported.

  • Method Details

    • evaluate

      public static Object evaluate(@Nonnull String expression, @Nullable Object root) throws 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 expression
      root - not null object
      Returns:
      the object defined by the expression
      Throws:
      IntrospectionException - if any
    • evaluate

      public static Object evaluate(@Nonnull String expression, @Nullable Object root, boolean trimRootToken) throws 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 expression
      root - not null object
      trimRootToken - trim root token yes/no.
      Returns:
      the object defined by the expression
      Throws:
      IntrospectionException - if any