Package org.intermine.metadata
Class ReferenceDescriptor
- java.lang.Object
-
- org.intermine.metadata.FieldDescriptor
-
- org.intermine.metadata.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 Summary
Fields Modifier and Type Field Description protected ClassDescriptorreferencedClassDescprotected java.lang.StringreferencedTypeprotected ReferenceDescriptorreverseRefDescprotected java.lang.StringreverseRefName-
Fields inherited from class org.intermine.metadata.FieldDescriptor
cld, M_N_RELATION, N_ONE_RELATION, name, NOT_RELATION, ONE_N_RELATION, ONE_ONE_RELATION
-
-
Constructor Summary
Constructors Constructor Description ReferenceDescriptor(java.lang.String name, java.lang.String referencedType, java.lang.String reverseRefName)Construct a ReferenceDescriptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)protected voidfindReferencedDescriptor()sort out references from this classClassDescriptorgetReferencedClassDescriptor()Returns a ClassDescriptor for the object referenced by this field.java.lang.StringgetReferencedClassName()Returns the class name of the object referenced by this field.ReferenceDescriptorgetReverseReferenceDescriptor()Gets the field in the referenced object that refers back to this class.java.lang.StringgetReverseReferenceFieldName()Gets the name of the reverse reference field.inthashCode()intrelationType()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".java.lang.StringtoJSONString()Return the JSON representation of this object.java.lang.StringtoString()-
Methods inherited from class org.intermine.metadata.FieldDescriptor
getClassDescriptor, getName, isAttribute, isCollection, isReference, setClassDescriptor
-
-
-
-
Field Detail
-
referencedType
protected final java.lang.String referencedType
-
referencedClassDesc
protected ClassDescriptor referencedClassDesc
-
reverseRefName
protected final java.lang.String reverseRefName
-
reverseRefDesc
protected ReferenceDescriptor reverseRefDesc
-
-
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 fieldreferencedType- fully qualfied class name of another business objectreverseRefName- 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 MetaDataExceptionsort 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:
relationTypein classFieldDescriptor- Returns:
- int to describe the relationship type
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toJSONString
public java.lang.String toJSONString()
Return the JSON representation of this object.- Specified by:
toJSONStringin classFieldDescriptor- Returns:
- a string containing JSON
-
-