Class FieldDescriptor

  • Direct Known Subclasses:
    AttributeDescriptor, ReferenceDescriptor

    public abstract class FieldDescriptor
    extends java.lang.Object
    Abstract representation of a field within a class - could be an attribute, an object reference or a collection.
    Author:
    Richard Smith
    • Constructor Summary

      Constructors 
      Constructor Description
      FieldDescriptor​(java.lang.String name)
      Construct, name of field must not be null and must be a valid Java variable name.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      ClassDescriptor getClassDescriptor()
      Get the ClassDescriptor for this field's class.
      java.lang.String getName()
      Get the name of the described field.
      boolean isAttribute()
      Is this FieldDescriptor an attribute?
      boolean isCollection()
      Is this FieldDescriptor a collection?
      boolean isReference()
      Is this FieldDescriptor a reference?
      abstract 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".
      protected void setClassDescriptor​(ClassDescriptor cld)
      Set the parent ClassDescriptor - should be called when this is added to a ClassDescriptor.
      abstract java.lang.String toJSONString()
      Return the JSON representation of this object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FieldDescriptor

        public FieldDescriptor​(java.lang.String name)
        Construct, name of field must not be null and must be a valid Java variable name.
        Parameters:
        name - name of field in class
        Throws:
        java.lang.IllegalArgumentException - if name argument is null
    • Method Detail

      • getClassDescriptor

        public ClassDescriptor getClassDescriptor()
        Get the ClassDescriptor for this field's class.
        Returns:
        a the ClassDescriptor for this field's class
      • getName

        public java.lang.String getName()
        Get the name of the described field.
        Returns:
        name of the field
      • setClassDescriptor

        protected void setClassDescriptor​(ClassDescriptor cld)
        Set the parent ClassDescriptor - should be called when this is added to a ClassDescriptor. ClassDescriptor in this class is final so a MetadataException is thrown if method called again.
        Parameters:
        cld - the parent ClassDescriptor
        Throws:
        java.lang.IllegalStateException - if the parent ClassDescriptor is not set
      • relationType

        public abstract 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".
        Returns:
        int to describe the relationship type
      • isAttribute

        public boolean isAttribute()
        Is this FieldDescriptor an attribute?
        Returns:
        true if this FieldDescriptor describes an attribute
      • isReference

        public boolean isReference()
        Is this FieldDescriptor a reference?
        Returns:
        true if this FieldDescriptor describes a reference
      • isCollection

        public boolean isCollection()
        Is this FieldDescriptor a collection?
        Returns:
        true if this FieldDescriptor describes a collection
      • toJSONString

        public abstract java.lang.String toJSONString()
        Return the JSON representation of this object.
        Returns:
        a string containing JSON