Class PropertySetExecutor

    • Field Detail

      • SET_START_INDEX

        private static final int SET_START_INDEX
        Index of the first character of the set{p,P}roperty.
        See Also:
        Constant Field Values
      • property

        protected final java.lang.String property
        The property.
      • valueClass

        protected final java.lang.Class<?> valueClass
        The property value class.
    • Constructor Detail

      • PropertySetExecutor

        protected PropertySetExecutor​(java.lang.Class<?> clazz,
                                      java.lang.reflect.Method method,
                                      java.lang.String key,
                                      java.lang.Object value)
        Creates an instance.
        Parameters:
        clazz - the class the set method applies to
        method - the method called through this executor
        key - the key to use as 1st argument to the set method
        value - the value
    • Method Detail

      • discover

        public static PropertySetExecutor discover​(Introspector is,
                                                   java.lang.Class<?> clazz,
                                                   java.lang.String property,
                                                   java.lang.Object value)
        Discovers a PropertySetExecutor.

        The method to be found should be named "set{P,p}property.

        Parameters:
        is - the introspector
        clazz - the class to find the get method from
        property - the property name to find
        value - the value to assign to the property
        Returns:
        the executor if found, null otherwise
      • discoverSet

        private static java.lang.reflect.Method discoverSet​(Introspector is,
                                                            java.lang.Class<?> clazz,
                                                            java.lang.String property,
                                                            java.lang.Object arg)
        Discovers the method for a JexlPropertySet.

        The method to be found should be named "set{P,p}property. As a special case, any empty array will try to find a valid array-setting non-ambiguous method.

        Parameters:
        is - the introspector
        clazz - the class to find the get method from
        property - the name of the property to set
        arg - the value to assign to the property
        Returns:
        the method if found, null otherwise
      • isEmptyArray

        private static boolean isEmptyArray​(java.lang.Object arg)
        Checks whether an argument is an empty array.
        Parameters:
        arg - the argument
        Returns:
        true if arg is an empty array
      • lookupSetEmptyArray

        private static java.lang.reflect.Method lookupSetEmptyArray​(Introspector is,
                                                                    java.lang.Class<?> clazz,
                                                                    java.lang.String methodName)
        Finds an empty array property setter method by methodName.

        This checks only one method with that name accepts an array as sole parameter.

        Parameters:
        is - the introspector
        clazz - the class to find the get method from
        methodName - the method name to find
        Returns:
        the sole method that accepts an array as parameter
      • getTargetProperty

        public java.lang.Object getTargetProperty()
        Description copied from class: AbstractExecutor
        Gets the property targeted by this executor.
        Overrides:
        getTargetProperty in class AbstractExecutor
        Returns:
        the target property
      • invoke

        public java.lang.Object invoke​(java.lang.Object o,
                                       java.lang.Object argument)
                                throws java.lang.IllegalAccessException,
                                       java.lang.reflect.InvocationTargetException
        Description copied from interface: JexlPropertySet
        Method used to set the property value of an object.
        Parameters:
        o - Object on which the property setter will be called with the value
        argument - value to be set
        Returns:
        the value returned from the set operation (impl specific)
        Throws:
        java.lang.IllegalAccessException
        java.lang.reflect.InvocationTargetException
      • tryInvoke

        public java.lang.Object tryInvoke​(java.lang.Object o,
                                          java.lang.Object identifier,
                                          java.lang.Object value)
        Description copied from interface: JexlPropertySet
        Attempts to reuse this JexlPropertySet, checking that it is compatible with the actual set of arguments.
        Parameters:
        o - the object to invoke the get upon
        identifier - the property key to get
        value - the property value to set
        Returns:
        the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.