Class Property

All Implemented Interfaces:
Archivable, RMJSONArchiver.GetKeys, RMPropertyChanger, Cloneable, Comparable

public class Property extends RMObject implements Comparable, RMJSONArchiver.GetKeys, Archivable
This class describes an attribute of an entity.
  • Constructor Details

    • Property

      public Property()
      Creates a new property.
    • Property

      public Property(String aName)
      Creates a new property with given name.
    • Property

      public Property(String aName, Property.Type aType)
      Creates a new property with given name and type.
    • Property

      public Property(String aName, Object aType)
      Creates a new property with given name and type.
  • Method Details

    • getEntity

      public Entity getEntity()
      Returns the entity that owns this property.
    • setEntity

      public void setEntity(Entity anEntity)
      Sets the entity that owns this property.
    • getName

      @Nonnull public String getName()
      Returns the name of this property.
    • setName

      public void setName(String aName)
      Sets the name of this property.
    • getStandardName

      public String getStandardName()
      Returns the name in a standard format (strip is/get prefix and start with capital letter).
    • getType

      public Property.Type getType()
      Returns the type of this property.
    • setType

      public void setType(Property.Type aType)
      Sets the type of this property.
    • setTypeName

      public void setTypeName(String aName)
      Sets the type from a given name.
    • setTypeFromSample

      public void setTypeFromSample(String aSample)
      Sets property type from sample string - tries to discern whether string represents a date or number.
    • isPrimary

      public boolean isPrimary()
      Returns whether this property is a primary key.
    • setPrimary

      public void setPrimary(boolean isPrimary)
      Sets whether this property is a primary key.
    • isPrivate

      public boolean isPrivate()
      Returns whether this property is private.
    • setPrivate

      public void setPrivate(boolean isPrivate)
      Sets whether this property is private.
    • getStringSize

      public Property.StringSize getStringSize()
      Returns the string size.
    • setStringSize

      public void setStringSize(Property.StringSize aSize)
      Sets the string size.
    • getStringSizeDefault

      public Property.StringSize getStringSizeDefault()
      Return default string size.
    • getNumberType

      public Property.NumberType getNumberType()
      Returns the number type.
    • setNumberType

      public void setNumberType(Property.NumberType aNumberType)
      Sets the number type.
    • getNumberTypeDefault

      public Property.NumberType getNumberTypeDefault()
      Return default number type.
    • getDateType

      public Property.DateType getDateType()
      Returns the date type.
    • setDateType

      public void setDateType(Property.DateType aDateType)
      Sets the date type.
    • getDateTypeDefault

      public Property.DateType getDateTypeDefault()
      Returns the default date type.
    • isAutoGenerated

      public boolean isAutoGenerated()
      Returns whether column is automatically generated (numbered), thus read-only.
    • setAutoGenerated

      public void setAutoGenerated(boolean aValue)
      Sets whether column is automatically generated (numbered), thus read-only.
    • isNullable

      public boolean isNullable()
      Returns whether property allows nulls.
    • setNullable

      public void setNullable(boolean aValue)
      Sets whether property allows nulls.
    • getNullableDefault

      public boolean getNullableDefault()
      Returns the nullable default.
    • getDefaultValue

      public Object getDefaultValue()
      Returns default value for this property.
    • setDefaultValue

      public void setDefaultValue(Object aValue)
      Sets default value for this property.
    • getEnumStrings

      public List<String> getEnumStrings()
      Returns the enum strings (for type Enum).
    • setEnumStrings

      public void setEnumStrings(List<String> theValues)
      Sets the enum strings (for type Enum).
    • getEnumsString

      public String getEnumsString()
      Returns the enum strings as a single string (comma separated).
    • setEnumsString

      public void setEnumsString(String aValue)
      Sets the enum strings as a single string (comma separated).
    • isAttribute

      public boolean isAttribute()
      Returns whether this property is a simple attribute.
    • isRelation

      public boolean isRelation()
      Returns whether this property is a relation.
    • isToMany

      public boolean isToMany()
      Returns whether this property is a to many relation.
    • isDerived

      public boolean isDerived()
      Returns whether property value is derived from other properties and doesn't require persistence. A common (though advanced) example is a relationship that references the primary key against a foreign table/key. A less sophisticated example would be a property based on an expression comprised of other properties.
    • setToMany

      public void setToMany(boolean aValue)
      Sets whether this property is a to many relation.
    • getRelationEntity

      public Entity getRelationEntity()
      Returns the relation entity.
    • setRelationEntity

      public void setRelationEntity(Entity anEntity)
      Sets the relation entity.
    • getRelationEntityName

      public String getRelationEntityName()
      Returns the name of the entity that this relation property points to.
    • setRelationEntityName

      public void setRelationEntityName(String aName)
      Sets the name of the entity that this relation property points to.
    • getRelationLocalPropertyName

      public String getRelationLocalPropertyName()
      Returns the property name local to this property's entity that the relation uses as a key (primary or foreign).
    • setRelationLocalPropertyName

      public void setRelationLocalPropertyName(String aName)
      Sets the property name local to this property's entity that the relation uses as a key (primary or foreign).
    • getRelationRemotePropertyName

      public String getRelationRemotePropertyName()
      Returns the property name that the relation uses as a key in the remote table (primary or foreign).
    • setRelationRemotePropertyName

      public void setRelationRemotePropertyName(String aName)
      Sets the property name that the relation uses as a key in the remote table (primary or foreign).
    • getRelationLocalProperty

      public Property getRelationLocalProperty()
      Returns the relation local property.
    • getRelationRemoteProperty

      public Property getRelationRemoteProperty()
      Returns the relation remote property.
    • convertValue

      public Object convertValue(Object anObj)
      Converts an arbitrary object to property type.
    • getKeyValue

      public Object getKeyValue(String aKey)
      RMKey.Get implementation to return Property for key from RelationEntity (if found).
    • toString

      public String toString(Object aValue)
      Returns a string representation of given value according to property type.
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • clone

      public Property clone()
      Standard clone implementation.
      Overrides:
      clone in class RMListenerList
    • compareTo

      public int compareTo(Object anObj)
      Implements comparable to compare based on name.
      Specified by:
      compareTo in interface Comparable
    • toXML

      public RXElement toXML(RXArchiver anArchiver)
      XML archival.
      Specified by:
      toXML in interface Archivable
    • fromXML

      public Property fromXML(RXArchiver anArchiver, RXElement anElement)
      XML unarchival.
      Specified by:
      fromXML in interface Archivable
    • getJSONKeys

      public List<String> getJSONKeys()
      Returns JSON keys.
      Specified by:
      getJSONKeys in interface RMJSONArchiver.GetKeys
    • toString

      public String toString()
      Returns a string representation of this property (its name).
      Overrides:
      toString in class RMObject