Class ReferenceDescriptor

  • Direct Known Subclasses:
    CollectionDescriptor

    public class ReferenceDescriptor
    extends FieldDescriptor
    Describes a field that references a single other class (i.e. not a collection of objects). getReverseReferenceDescriptor() allows one to work out the multiplicity of the association's other end.
    Author:
    Richard Smith
    • Field Detail

      • referencedType

        protected final java.lang.String referencedType
      • reverseRefName

        protected final java.lang.String reverseRefName
    • Constructor Detail

      • ReferenceDescriptor

        public ReferenceDescriptor​(java.lang.String name,
                                   java.lang.String referencedType,
                                   java.lang.String reverseRefName)
        Construct a ReferenceDescriptor. Requires the name of Class referenced and the field in the referenced class that refers back to this (will be null in a unidirectional relationship).
        Parameters:
        name - name of the field
        referencedType - fully qualfied class name of another business object
        reverseRefName - name of the field in remote object that refers back to this one
        Throws:
        java.lang.IllegalArgumentException - if fields are null
    • Method Detail

      • getReferencedClassDescriptor

        public ClassDescriptor getReferencedClassDescriptor()
        Returns a ClassDescriptor for the object referenced by this field.
        Returns:
        ClassDescriptor for the referenced object
        Throws:
        java.lang.IllegalStateException - if model has not been set
      • getReverseReferenceFieldName

        public java.lang.String getReverseReferenceFieldName()
        Gets the name of the reverse reference field.
        Returns:
        the name of the reverse reference field
      • getReferencedClassName

        public java.lang.String getReferencedClassName()
        Returns the class name of the object referenced by this field.
        Returns:
        the class name of the object referenced
      • getReverseReferenceDescriptor

        public ReferenceDescriptor getReverseReferenceDescriptor()
        Gets the field in the referenced object that refers back to this class. Note that this will be null in a unidirectional relationship, a ReferenceDescriptor in a 1:1 and a CollectionDescriptor in a 1:N.
        Returns:
        a FieldDescriptor referring back to this class.
        Throws:
        java.lang.IllegalStateException - if model has not been set
      • findReferencedDescriptor

        protected void findReferencedDescriptor()
                                         throws MetaDataException
        sort out references from this class
        Throws:
        MetaDataException - if references not found
      • relationType

        public int relationType()
        Return an integer describing the type of relationship this field represents, where relationship types are 1:1, 1:N, N:1, M:N and "not a relationship".
        Specified by:
        relationType in class FieldDescriptor
        Returns:
        int to describe the relationship type
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toJSONString

        public java.lang.String toJSONString()
        Return the JSON representation of this object.
        Specified by:
        toJSONString in class FieldDescriptor
        Returns:
        a string containing JSON