Class EntityAccessManager

java.lang.Object
org.neo4j.ogm.metadata.reflect.EntityAccessManager

public class EntityAccessManager extends Object
Determines how entities should be accessed in both reading and writing scenarios by looking up information from ClassInfo in the following order.
  1. Annotated Field
  2. Plain Field
The rationale is simply that we want annotations, whether on fields or on methods, to always take precedence, and we want to use methods in preference to field access, because in many cases hydrating an object means more than just assigning values to fields.
Author:
Adam George, Luanne Misquitta, Michael J. Simons
  • Constructor Details

    • EntityAccessManager

      public EntityAccessManager()
  • Method Details

    • merge

      public static Object merge(Class<?> parameterType, Object newValues, Object[] currentValues, Class elementType)
    • merge

      public static Object merge(Class<?> collectionType, Object newValues, Collection currentValues, Class elementType)
      Merges the contents of collection with hydrated ensuring no duplicates and returns the result as an instance of the given parameter type.
      Parameters:
      collectionType - The type of Iterable or array to return
      newValues - The objects to merge into a collection of the given parameter type, which may not necessarily be of a type assignable from collectionType already
      currentValues - The Iterable to merge into, which may be null if a new collection needs creating
      elementType - The type of the element in the array or collection (After conversion has been applied)
      Returns:
      The result of the merge, as an instance of the specified parameter type
    • getRelationalWriter

      public static FieldInfo getRelationalWriter(ClassInfo classInfo, String relationshipType, Relationship.Direction relationshipDirection, Object scalarValue)
      Returns a FieldWriter for a scalar value represented as a relationship in the graph (i.e. not a primitive property)
      Parameters:
      classInfo - the ClassInfo (or a superclass thereof) declaring the relationship
      relationshipType - the name of the relationship as it is in the graph
      relationshipDirection - the direction of the relationship as it is in the graph
      scalarValue - an Object whose class the relationship is defined for
      Returns:
      a valid FieldWriter or null if none is found
    • getRelationalWriter

      public static FieldInfo getRelationalWriter(ClassInfo classInfo, String relationshipType, Relationship.Direction relationshipDirection, Class<?> objectType)
      Returns a FieldWriter for a scalar type on a ClassInfo that is not a primitive graph property
      Parameters:
      classInfo - the ClassInfo (or a superclass thereof) declaring the relationship
      relationshipType - the name of the relationship as it is in the graph
      relationshipDirection - the direction of the relationship as it is in the graph
      objectType - the class the relationship is defined for
      Returns:
      a valid FieldWriter or null if none is found
    • getRelationalReader

      public static FieldInfo getRelationalReader(ClassInfo classInfo, String relationshipType, Relationship.Direction relationshipDirection)
      Returns a FieldInfo for a scalar type definition on a ClassInfo that is not a primitive graph property
      Parameters:
      classInfo - A ClassInfo declaring the type definition
      relationshipType - The name of the relationship in the graph
      relationshipDirection - The direction of the relationship in the graph
      Returns:
      A FieldInfo or null if none exists
    • getIterableField

      public static FieldInfo getIterableField(ClassInfo classInfo, Class<?> parameterType, String relationshipType, Relationship.Direction relationshipDirection)
      Returns an FieldWriter for an iterable of a non-primitive scalar type defined by a ClassInfo
      Parameters:
      classInfo - the ClassInfo (or a superclass thereof) declaring the iterable relationship
      relationshipType - the name of the relationship as it is in the graph
      relationshipDirection - the direction of the relationship as it is in the graph
      parameterType - the type that will be iterated over
      Returns:
      a valid FieldWriter or null if none is found