Package org.intermine.metadata
Class FieldDescriptor
- java.lang.Object
-
- org.intermine.metadata.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
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassDescriptor
cld
static int
M_N_RELATION
A M:N relationship.static int
N_ONE_RELATION
A N:1 relationship.protected java.lang.String
name
static int
NOT_RELATION
Not a relationship between objectsstatic int
ONE_N_RELATION
A 1:N relationship.static int
ONE_ONE_RELATION
A 1:1 relationship
-
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.
-
-
-
Field Detail
-
NOT_RELATION
public static final int NOT_RELATION
Not a relationship between objects- See Also:
- Constant Field Values
-
ONE_ONE_RELATION
public static final int ONE_ONE_RELATION
A 1:1 relationship- See Also:
- Constant Field Values
-
ONE_N_RELATION
public static final int ONE_N_RELATION
A 1:N relationship.- See Also:
- Constant Field Values
-
N_ONE_RELATION
public static final int N_ONE_RELATION
A N:1 relationship.- See Also:
- Constant Field Values
-
M_N_RELATION
public static final int M_N_RELATION
A M:N relationship.- See Also:
- Constant Field Values
-
name
protected final java.lang.String name
-
cld
protected ClassDescriptor cld
-
-
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
-
-