Class UniversalUpdater

    • Field Detail

      • BEAN_MODIFIER_PREFIX

        public static final String BEAN_MODIFIER_PREFIX
        JavaBean property modifier prefix.
        See Also:
        Constant Field Values
      • m_sName

        protected String m_sName
        A method name, or a property name.
    • Constructor Detail

      • UniversalUpdater

        public UniversalUpdater()
        Default constructor (necessary for the ExternalizableLite interface).
      • UniversalUpdater

        public UniversalUpdater​(String sName)
        Construct a UniversalUpdater for the provided name. If sName ends in a METHOD_SUFFIX, then the name is a method name. This implementation assumes that a target's class will have one and only one method with the specified name and this method will have exactly one parameter; if the name is a property name, there should be a corresponding JavaBean property modifier method or it will be used as a key in a Map.
        Parameters:
        sName - a method or property name
        See Also:
        computeCanonicalName(String)
    • Method Detail

      • update

        public void update​(Object oTarget,
                           Object oValue)
        Update the state of the passed target object using the passed value. For intrinsic types, the specified value is expected to be a standard wrapper type in the same manner that reflection works; for example, an int value would be passed as a java.lang.Integer.
        Specified by:
        update in interface ValueUpdater
        Overrides:
        update in class AbstractUpdater
        Parameters:
        oTarget - the Object to update the state of
        oValue - the new value to update the state with
        See Also:
        updateComplex(Object, Object)
      • isMethodUpdater

        public boolean isMethodUpdater()
        Return true iff this updater references a setter method.
        Returns:
        true iff this is setter method updater.
      • getMethodName

        public String getMethodName()
        Determine the name of the method that this extractor is configured to invoke.
        Returns:
        method name without the METHOD_SUFFIX
      • getCanonicalName

        public String getCanonicalName()
        Return the canonical name for this updater. A canonical name uniquely identifies an updater, but not how it is to be updated. Thus, two different updater implementations with the same non-null canonical name are considered to be equal, and should reflect this in their implementations of hashCode and equals. Canonical names for properties are designated by their property name in camel case, for instance a Java Bean with method setFooBar would have a property named fooBar, and fooBar would also be its canonical name.
        Returns:
        the updater's canonical name
        Since:
        Coherence 12.3.1
      • updateComplex

        protected void updateComplex​(Object oTarget,
                                     Object oValue)
                              throws InvocationTargetException,
                                     IllegalAccessException
        Implement update of target using reflection or property setter. Cache the reflection computation to enable avoiding reflection lookup if next target has same class type.

        If unable to find method name via reflection and oTarget is a Map, use canonical name as a key to update target.

        Parameters:
        oTarget - the Object to update the state of
        oValue - the new value to update the state with
        Throws:
        InvocationTargetException - if reflection method lookup fails
        IllegalAccessException - if reflection method lookup fails
        Since:
        Coherence 12.3.1
      • computeCanonicalName

        public static String computeCanonicalName​(String sName)
        Compute the canonical name for this updater. If sName does not end with a METHOD_SUFFIX, it is the canonical name of a property. If sName begins with BEAN_MODIFIER_PREFIX and ends with METHOD_SUFFIX, the canonical name is sName value with prefix and suffix removed and the canonical name is for a property. Otherwise, the canonical name is the sName and refers to method name.
        Parameters:
        sName - a method or property name
        Returns:
        return canonical name of sName
      • createUpdater

        public static ValueUpdater createUpdater​(String sNames)
        Return a ValueUpdater for sNames
        Parameters:
        sNames - property or setter method name; this parameter can also be a dot-delimited sequence of property and/or method names which would result in using a CompositeUpdater
        Returns:
        ValueUpdater for sNames
      • equals

        public boolean equals​(Object o)
        Compare the UniversalUpdater with another object to determine equality. Compare by canonical names when both are non-null.
        Overrides:
        equals in class Object
        Returns:
        true iff this UniversalUpdater and the passed object are equivalent ReflectionUpdaters
      • hashCode

        public int hashCode()
        Determine a hash value for the UniversalUpdater object according to the general Object.hashCode() contract.
        Overrides:
        hashCode in class Object
        Returns:
        an integer hash value for this UniversalUpdater object
      • toString

        public String toString()
        Provide a human-readable description of this ValueUpdater object.
        Overrides:
        toString in class Object
        Returns:
        a human-readable description of this ValueUpdater object
      • readExternal

        public void readExternal​(DataInput in)
                          throws IOException
        Restore the contents of this object by loading the object's state from the passed DataInput object.
        Specified by:
        readExternal in interface ExternalizableLite
        Parameters:
        in - the DataInput stream to read data from in order to restore the state of this object
        Throws:
        IOException - if an I/O exception occurs
        NotActiveException - if the object is not in its initial state, and therefore cannot be deserialized into
      • writeExternal

        public void writeExternal​(DataOutput out)
                           throws IOException
        Save the contents of this object by storing the object's state into the passed DataOutput object.
        Specified by:
        writeExternal in interface ExternalizableLite
        Parameters:
        out - the DataOutput stream to write the state of this object to
        Throws:
        IOException - if an I/O exception occurs
      • readExternal

        public void readExternal​(PofReader in)
                          throws IOException
        Restore the contents of a user type instance by reading its state using the specified PofReader object.
        Specified by:
        readExternal in interface PortableObject
        Parameters:
        in - the PofReader from which to read the object's state
        Throws:
        IOException - if an I/O error occurs
      • writeExternal

        public void writeExternal​(PofWriter out)
                           throws IOException
        Save the contents of a POF user type instance by writing its state using the specified PofWriter object.
        Specified by:
        writeExternal in interface PortableObject
        Parameters:
        out - the PofWriter to which to write the object's state
        Throws:
        IOException - if an I/O error occurs