Class PartialObject

java.lang.Object
com.tangosol.coherence.rest.util.PartialObject

public class PartialObject extends Object
Base class for dynamically generated partial classes.
Author:
as 2011.06.29
  • Field Details

  • Constructor Details

    • PartialObject

      public PartialObject()
      Construct a PartialObject instance.
    • PartialObject

      public PartialObject(Map mapProperties)
      Construct a PartialObject instance.
      Parameters:
      mapProperties - map containing property values for this partial object
  • Method Details

    • get

      public Object get(String sName)
      Get a property value.
      Parameters:
      sName - property name
      Returns:
      property value, or null if the property does not exist
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • create

      public static Object create(Object oSource, PropertySet propertySet)
      Create a PartialObject instance.
      Parameters:
      oSource - object to extract properties from
      propertySet - properties to extract
      Returns:
      partial object containing the supplied subset of properties of the specified object
    • create

      public static PartialObject create(Class clzSource, PropertySet propertySet, Map<String,Object> mapProperties)
      Create a PartialObject instance based on an already extracted set of properties.
      Parameters:
      clzSource - class of the object properties were extracted from
      propertySet - extracted properties
      mapProperties - extracted property values
      Returns:
      partial object containing the supplied subset of properties of the specified object
    • getPartialClass

      public static Class getPartialClass(Class clzSource, PropertySet propertySet)
      Return a partial class for the specified source class and property set.
      Parameters:
      clzSource - source class to base the partial class on
      propertySet - a set of properties to define
      Returns:
      class containing only the specified set of properties
    • createPartialClass

      public static <T> Class createPartialClass(Class clzSource, PropertySet<T> propertySet)
      Create a partial class for the specified source class and property set.
      Parameters:
      clzSource - a source class to base partial the class on
      propertySet - a set of properties to define
      Returns:
      class containing only the specified set of properties
    • createKey

      protected static String createKey(Class clzSource, PropertySet propertySet)
      Create key for the partial class/constructor cache.
      Parameters:
      clzSource - source class to base the partial class on
      propertySet - a set of properties to define
      Returns:
      lookup key
    • copyClassAnnotations

      protected static void copyClassAnnotations(org.objectweb.asm.tree.ClassNode cnSource, org.objectweb.asm.tree.ClassNode cnTarget)
      Copy class-level annotations.
      Parameters:
      cnSource - source class to copy annotations from
      cnTarget - target class to copy annotations to
    • createConstructors

      protected static void createConstructors(org.objectweb.asm.tree.ClassNode cn)
      Implement partial class constructors.
      Parameters:
      cn - partial class
    • castReturnValue

      protected static void castReturnValue(org.objectweb.asm.tree.MethodNode mn)
      Cast a return value into an appropriate type.
      Parameters:
      mn - method whose return value needs to be casted
    • createClass

      protected static Class createClass(org.objectweb.asm.tree.ClassNode cn)
      Create partial class based on partial class definition.
      Parameters:
      cn - partial class definition
      Returns:
      partial class
    • findProperty

      protected static org.objectweb.asm.tree.MethodNode findProperty(List<org.objectweb.asm.tree.ClassNode> listClassNodes, String sName)
      Attempt to find a property with a given name in one of the specified class definitions.
      Parameters:
      listClassNodes - class definitions to search
      sName - method name
      Returns:
      method definition if found, null otherwise
    • findProperty

      protected static org.objectweb.asm.tree.MethodNode findProperty(org.objectweb.asm.tree.ClassNode cn, String sName)
      Attempt to find a property getter with a given name in the specified class definitions.
      Parameters:
      cn - class definition to search
      sName - method name
      Returns:
      method definition if found, null otherwise
    • isMatch

      protected static boolean isMatch(String sMethodName, String sPropertyName)
      Determine if a method represents a property.
      Parameters:
      sMethodName - name of the method
      sPropertyName - name of the property
      Returns:
      true if the specified method represents the specified property, false otherwise
    • getClassNode

      protected static org.objectweb.asm.tree.ClassNode getClassNode(Class clz)
      Return a class definition for the specified class.
      Parameters:
      clz - class to get a definition for
      Returns:
      class definition for the specified class
    • getPartialClassLoader

      protected static PartialObject.PartialClassLoader getPartialClassLoader()
      Return a PartialClassLoader corresponding to the Context ClassLoader.
      Returns:
      PartialClassLoader
    • getPartialClassMap

      protected static ConcurrentHashMap<String,Class> getPartialClassMap(PartialObject.PartialClassLoader loader)
      Return the partial class map corresponding to the PartialClassLoader.
      Parameters:
      loader - the PartialClassLoader corresponding to which the partial class map is required
      Returns:
      the map of Partial classes corresponding to the PartialClassLoader
    • getPartialConstructorMap

      protected static ConcurrentHashMap<String,Constructor> getPartialConstructorMap(PartialObject.PartialClassLoader loader)
      Return the partial constructor map corresponding to the PartialClassLoader.
      Parameters:
      loader - the PartialClassLoader corresponding to which the partial constructor map is required
      Returns:
      the map of Partial constructors corresponding to the PartialClassLoader