Class RelationshipUtils

java.lang.Object
org.neo4j.ogm.utils.RelationshipUtils

public class RelationshipUtils extends Object
Contains helper methods to facilitate inference of relationship types from field and methods and vice versa.

All methods follow the same convention that relationship types are UPPER_SNAKE_CASE and that fields appear in lowerCamelCase. The de-facto Java Bean getter/setter pattern is also assumed when inferring accessor methods.

The utility methods here will all throw a NullPointerException if invoked with null.
Author:
Adam George
  • Constructor Details

    • RelationshipUtils

      public RelationshipUtils()
  • Method Details

    • inferRelationshipType

      public static String inferRelationshipType(String memberName)
      Infers the relationship type that corresponds to the given field or access method name. This method is called when no annotation exists by which to determine the relationship type between two nodes.
      Parameters:
      memberName - The member name from which to infer the relationship type
      Returns:
      The resolved relationship type
    • inferSetterName

      public static String inferSetterName(String relationshipType)
      Infers the name of the setter method that corresponds to the given relationship type.
      Parameters:
      relationshipType - The relationship type from which to infer the setter name
      Returns:
      The inferred setter method name
    • inferGetterName

      public static String inferGetterName(String relationshipType)
      Infers the name of the getter method that corresponds to the given relationship type.
      Parameters:
      relationshipType - The relationship type from which to infer the getter name
      Returns:
      The inferred getter method name
    • inferFieldName

      public static String inferFieldName(String relationshipType)
      Infers the name of the instance variable that corresponds to the given relationship type.
      Parameters:
      relationshipType - The relationship type from which to infer the name of the field
      Returns:
      The inferred field name