Class ConstrainedProperty

java.lang.Object
rife.validation.ConstrainedProperty
All Implemented Interfaces:
Cloneable

public class ConstrainedProperty extends Object implements Cloneable
A ConstrainedProperty object makes it possible to easily define all constraints for a named property of a bean.

The property name refers to the actual name of the bean property. However, this sometimes doesn't correspond to its conceptual usage. It can be handy to receive constraint violation reports with another conceptual name: the subject name. Notice that this corresponds to the subject that is used in a ValidationError. If no subject name is specified, the property name will be used instead.

It's possible to add constraints to a ConstrainedProperty instance through regular setters, but chainable setters are also available to make it possible to easily define a series of constraints, for example:

ConstrainedProperty constrained = new ConstrainedProperty("password")
    .maxLength(8)
    .notNull(true);

Constrained properties are typically added to a Constrained bean in its constructor. These are the static constraints that will be set for each and every instance of the bean. You'll however most of the time use the MetaData class that provides the activateMetaData method which initializes the constraints on a need-to-have basis. This dramatically reduces memory usage since otherwise all constraints will be initialized for every bean instance, even though you don't use them, for example:

public class Credentials extends MetaData
 {
    private String login_ = null;
    private String password_ = null;
    private String language_ = null;

    public Credentials() {
    }

    public activateMetaData() {
        addConstraint(new ConstrainedProperty("login").maxLength(6).notNull(true));
        addConstraint(new ConstrainedProperty("password").maxLength(8).notNull(true));
        addConstraint(new ConstrainedProperty("language").notNull(true));
    }

    public void setLogin(String login) { login_ = login; }
    public String getLogin() { return login_; }
    public void setPassword(String password) { password_ = password; }
    public String getPassword() { return password_; }
    public void setLanguage(String language) { language_ = language; }
    public String getLanguage() { return language_; }
 }

It's however also possible to add constraints to a single bean instance whenever they can't be determined beforehand. These are then dynamic constraints than can be populated at runtime, for example:

Credentials credentials = new Credentials();
 credentials.addConstraint(new ConstrainedProperty("language").inList(new String[] {"nl", "fr", "en"}));
 
Since:
1.0
See Also:
  • Field Details

  • Constructor Details

    • ConstrainedProperty

      public ConstrainedProperty(String propertyName)
      Creates a new ConstrainedProperty for the specified property name.
      Parameters:
      propertyName - the name of the property that has to be constrained
      Since:
      1.0
  • Method Details

    • addListener

      public void addListener(ConstrainedPropertyListener listener)
      Adds a new listener.

      Listeners will be notified when events occur that are specified in the ConstrainedPropertyListener interface.

      Parameters:
      listener - the listener instance that will be added
      Since:
      1.0
    • removeListener

      public boolean removeListener(ConstrainedPropertyListener listener)
      Removes a listener.

      Once the listener has been removed, it will not receive any events anymore.

      Parameters:
      listener - the listener instance that will be removed
      Returns:
      true when the listener could be found and has been removed; or

      false when the listener wasn't registered before

      Since:
      1.0
    • subjectName

      public ConstrainedProperty subjectName(String name)
      Sets the subject name.
      Parameters:
      name - the subject name
      Returns:
      this ConstrainedProperty
      Since:
      1.0
    • setSubjectName

      public void setSubjectName(String name)
      Sets the subject name.
      Parameters:
      name - the subject name
      Since:
      1.0
    • getSubjectName

      public String getSubjectName()
      Retrieves the subject name.
      Returns:
      the subject name; or

      the property name if no subject was specified.

      Since:
      1.0
    • getPropertyName

      public String getPropertyName()
      Retrieves the property name.
      Returns:
      the property name
      Since:
      1.0
    • notNull

      public ConstrainedProperty notNull(boolean notNull)
      Set whether the property value can be null.

      Note that this has different meanings in different contexts:

      • for values in java this is only applicable to object references as primitive values are never null,
      • for values that are stored in a database, it's applicable to every column.
      Parameters:
      notNull - true when the value can't be null; or false when the value can be null.
      Returns:
      this ConstrainedProperty
      Since:
      1.0
      See Also:
    • setNotNull

      public void setNotNull(boolean notNull)
      Set whether the property value can be null.
      Since:
      1.0
      See Also:
    • isNotNull

      public boolean isNotNull()
      Retrieves whether the property value can be null.
      Returns:
      true when the value can't be null; or

      false when the value can be null.

      Since:
      1.0
      See Also:
    • notEmpty

      public ConstrainedProperty notEmpty(boolean notEmpty)
      Set whether the property value can be empty.

      Note that this has different meanings for different datatypes

      • for textual types this is an empty string, ie. "",
      • for numeric types this is 0 (zero).
      Parameters:
      notEmpty - true when the value can't be empty; or false when the value can be empty.
      Returns:
      this ConstrainedProperty
      Since:
      1.0
      See Also:
    • setNotEmpty

      public void setNotEmpty(boolean notEmpty)
      Set whether the property value can be empty.
      Since:
      1.0
      See Also:
    • isNotEmpty

      public boolean isNotEmpty()
      Retrieves whether the property value can be empty.
      Returns:
      true when the value can't be empty; or

      false when the value can be empty.

      Since:
      1.0
      See Also:
    • notEqual

      public ConstrainedProperty notEqual(boolean reference)
      Set that the property value can't be equal to a specified boolean reference value.
      Parameters:
      reference - the reference value it will be checked against
      Returns:
      this ConstrainedProperty
      Since:
      1.0
      See Also:
    • notEqual

      public ConstrainedProperty notEqual(Object reference)
      Set that the property value can't be equal to a specified Object reference value.
      Since:
      1.0
      See Also:
    • setNotEqual

      public void setNotEqual(boolean reference)
      Set that the property value can't be equal to a specified boolean reference value.
      Since:
      1.0
      See Also:
    • setNotEqual

      public void setNotEqual(Object reference)
      Set that the property value can't be equal to a specified Object reference value.
      Since:
      1.0
      See Also:
    • isNotEqual

      public boolean isNotEqual()
      Retrieves whether the property can't be equal to a specific reference value.
      Returns:
      true when the value can't be equal; or

      false when the value can be equal.

      Since:
      1.0
      See Also:
    • getNotEqual

      public Object getNotEqual()
      Retrieves the reference object to which the property value can't be equal.
      Returns:
      the requested reference object instance; or

      null when the property has no notEqual constraint.

      Since:
      1.0
      See Also:
    • unique

      public ConstrainedProperty unique(boolean unique)
      Set whether the property value has to be unique.

      Note that this is only applicable to contexts where a collection of the data is stored and that uniqueness can apply against the other entries. In a singular context, uniqueness is always guaranteed.

      Parameters:
      unique - true when the value has to be unique; or false when it doesn't have to be.
      Returns:
      this ConstrainedProperty
      Since:
      1.0
      See Also:
    • setUnique

      public void setUnique(boolean unique)
      Set whether the property value has to be unique.
      Since:
      1.0
      See Also:
    • isUnique

      public boolean isUnique()
      Retrieves whether the property value has to be unique.
      Returns:
      true when the value has to be unique; or

      false it doesn't have to be.

      Since:
      1.0
      See Also:
    • identifier

      public ConstrainedProperty identifier(boolean identifier)
      Set whether the property value is an identifier.

      Note that this is only applicable to contexts where a collection of the data is stored and that identification can apply against the other entries. In a singular context, identification is meaningless.

      Parameters:
      identifier - true when the value is an identifier; or false when it isn't.
      Returns:
      this ConstrainedProperty
      Since:
      1.0
      See Also:
    • setIdentifier

      public void setIdentifier(boolean identifier)
      Set whether the property value is an identifier.
      Since:
      1.0
      See Also:
    • isIdentifier

      public boolean isIdentifier()
      Retrieves whether the property is an identifier.
      Returns:
      true when the property is an identifier; or

      false it isn't.

      Since:
      1.0
      See Also:
    • editable

      public ConstrainedProperty editable(boolean editable)
    • setEditable

      public void setEditable(boolean editable)
    • isEditable

      public boolean isEditable()
    • persistent

      public ConstrainedProperty persistent(boolean persistent)
    • setPersistent

      public void setPersistent(boolean persistent)
    • isPersistent

      public boolean isPersistent()
    • saved

      public ConstrainedProperty saved(boolean saved)
    • setSaved

      public void setSaved(boolean saved)
    • isSaved

      public boolean isSaved()
    • serialized

      public ConstrainedProperty serialized(boolean serialized)
      Sets whether the property takes part in data-interchange representations like JSON.

      When a property isn't serialized, it's not included when such representations are generated and it's not filled in when they are bound back to beans. This doesn't affect Java object serialization.

      Parameters:
      serialized - true when the property takes part in data-interchange representations; or false otherwise
      Returns:
      this ConstrainedProperty instance
      Since:
      1.10
    • setSerialized

      public void setSerialized(boolean serialized)
    • isSerialized

      public boolean isSerialized()
    • displayedRaw

      public ConstrainedProperty displayedRaw(boolean displayedRaw)
    • setDisplayedRaw

      public void setDisplayedRaw(boolean displayedRaw)
    • isDisplayedRaw

      public boolean isDisplayedRaw()
    • hasLimitedLength

      public boolean hasLimitedLength()
    • hasMixLength

      public boolean hasMixLength()
    • hasMaxLength

      public boolean hasMaxLength()
    • minLength

      public ConstrainedProperty minLength(int minLength)
    • setMinLength

      public void setMinLength(int minLength)
    • getMinLength

      public int getMinLength()
    • maxLength

      public ConstrainedProperty maxLength(int maxLength)
    • setMaxLength

      public void setMaxLength(int maxLength)
    • getMaxLength

      public int getMaxLength()
    • hasPrecision

      public boolean hasPrecision()
    • precision

      public ConstrainedProperty precision(int precision)
    • setPrecision

      public void setPrecision(int precision)
    • getPrecision

      public int getPrecision()
    • hasScale

      public boolean hasScale()
    • scale

      public ConstrainedProperty scale(int scale)
    • setScale

      public void setScale(int scale)
    • getScale

      public int getScale()
    • regexp

      public ConstrainedProperty regexp(String regexp)
    • setRegexp

      public void setRegexp(String regexp)
    • getRegexp

      public String getRegexp()
    • matchesRegexp

      public boolean matchesRegexp()
    • email

      public ConstrainedProperty email(boolean email)
    • setEmail

      public void setEmail(boolean email)
    • isEmail

      public boolean isEmail()
    • url

      public ConstrainedProperty url(boolean url)
    • setUrl

      public void setUrl(boolean url)
    • isUrl

      public boolean isUrl()
    • minDate

      public ConstrainedProperty minDate(Date minDate)
    • setMinDate

      public void setMinDate(Date minDate)
    • getMinDate

      public Date getMinDate()
    • maxDate

      public ConstrainedProperty maxDate(Date maxDate)
    • setMaxDate

      public void setMaxDate(Date maxDate)
    • getMaxDate

      public Date getMaxDate()
    • isLimitedDate

      public boolean isLimitedDate()
    • inList

      public ConstrainedProperty inList(String... inList)
    • setInList

      public void setInList(String... inList)
    • inList

      public ConstrainedProperty inList(int... inList)
    • setInList

      public void setInList(int... inList)
    • inList

      public ConstrainedProperty inList(byte... inList)
    • setInList

      public void setInList(byte... inList)
    • inList

      public ConstrainedProperty inList(char... inList)
    • setInList

      public void setInList(char... inList)
    • inList

      public ConstrainedProperty inList(short... inList)
    • setInList

      public void setInList(short... inList)
    • inList

      public ConstrainedProperty inList(long... inList)
    • setInList

      public void setInList(long... inList)
    • inList

      public ConstrainedProperty inList(float... inList)
    • setInList

      public void setInList(float... inList)
    • inList

      public ConstrainedProperty inList(double... inList)
    • setInList

      public void setInList(double... inList)
    • inList

      public ConstrainedProperty inList(Collection inList)
    • setInList

      public void setInList(Collection inList)
    • getInList

      public String[] getInList()
    • isInList

      public boolean isInList()
    • rangeBegin

      public ConstrainedProperty rangeBegin(byte value)
    • rangeBegin

      public ConstrainedProperty rangeBegin(char value)
    • rangeBegin

      public ConstrainedProperty rangeBegin(short value)
    • rangeBegin

      public ConstrainedProperty rangeBegin(int value)
    • rangeBegin

      public ConstrainedProperty rangeBegin(long value)
    • rangeBegin

      public ConstrainedProperty rangeBegin(float value)
    • rangeBegin

      public ConstrainedProperty rangeBegin(double value)
    • rangeBegin

      public ConstrainedProperty rangeBegin(Comparable value)
    • setRangeBegin

      public void setRangeBegin(Comparable rangeBegin)
    • getRangeBegin

      public Comparable getRangeBegin()
    • rangeEnd

      public ConstrainedProperty rangeEnd(char value)
    • rangeEnd

      public ConstrainedProperty rangeEnd(byte value)
    • rangeEnd

      public ConstrainedProperty rangeEnd(double value)
    • rangeEnd

      public ConstrainedProperty rangeEnd(float value)
    • rangeEnd

      public ConstrainedProperty rangeEnd(int value)
    • rangeEnd

      public ConstrainedProperty rangeEnd(long value)
    • rangeEnd

      public ConstrainedProperty rangeEnd(short value)
    • rangeEnd

      public ConstrainedProperty rangeEnd(Comparable value)
    • setRangeEnd

      public void setRangeEnd(Comparable rangeEnd)
    • getRangeEnd

      public Comparable getRangeEnd()
    • isRange

      public boolean isRange()
    • defaultValue

      public ConstrainedProperty defaultValue(boolean value)
    • defaultValue

      public ConstrainedProperty defaultValue(Object value)
    • setDefaultValue

      public void setDefaultValue(Object value)
    • getDefaultValue

      public Object getDefaultValue()
    • hasDefaultValue

      public boolean hasDefaultValue()
    • sameAs

      public ConstrainedProperty sameAs(String reference)
    • setSameAs

      public void setSameAs(String reference)
    • getSameAs

      public String getSameAs()
    • isSameAs

      public boolean isSameAs()
    • setManyToOne

      public void setManyToOne()
    • setManyToOne

      public void setManyToOne(Class klass)
    • setManyToOne

      public void setManyToOne(Class klass, String columnReference)
    • setManyToOne

      public void setManyToOne(String table, String columnReference)
    • setManyToOne

      public void setManyToOne(Class klass, String columnReference, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete)
    • setManyToOne

      public void setManyToOne(String table, String columnReference, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete)
    • getManyToOne

      public ConstrainedProperty.ManyToOne getManyToOne()
    • manyToOne

      public ConstrainedProperty manyToOne()
    • manyToOne

      public ConstrainedProperty manyToOne(Class klass)
    • manyToOne

      public ConstrainedProperty manyToOne(Class klass, String columnReference)
    • manyToOne

      public ConstrainedProperty manyToOne(String table, String columnReference)
    • manyToOne

      public ConstrainedProperty manyToOne(Class klass, String columnReference, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete)
    • manyToOne

      public ConstrainedProperty manyToOne(String table, String columnReference, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete)
    • hasManyToOne

      public boolean hasManyToOne()
    • setManyToOneAssociation

      public void setManyToOneAssociation()
    • setManyToOneAssociation

      public void setManyToOneAssociation(String property)
    • setManyToOneAssociation

      public void setManyToOneAssociation(Class klass, String property)
    • getManyToOneAssociation

      public ConstrainedProperty.ManyToOneAssociation getManyToOneAssociation()
    • manyToOneAssociation

      public ConstrainedProperty manyToOneAssociation()
    • manyToOneAssociation

      public ConstrainedProperty manyToOneAssociation(String property)
    • manyToOneAssociation

      public ConstrainedProperty manyToOneAssociation(Class klass, String property)
    • hasManyToOneAssociation

      public boolean hasManyToOneAssociation()
    • setManyToMany

      public void setManyToMany()
    • setManyToMany

      public void setManyToMany(Class klass)
    • setManyToMany

      public void setManyToMany(CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete)
    • setManyToMany

      public void setManyToMany(Class klass, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete)
    • getManyToMany

      public ConstrainedProperty.ManyToMany getManyToMany()
    • manyToMany

      public ConstrainedProperty manyToMany()
    • manyToMany

      public ConstrainedProperty manyToMany(Class klass)
    • manyToMany

    • manyToMany

      public ConstrainedProperty manyToMany(Class klass, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete)
    • hasManyToMany

      public boolean hasManyToMany()
    • setManyToManyAssociation

      public void setManyToManyAssociation()
    • setManyToManyAssociation

      public void setManyToManyAssociation(String property)
    • setManyToManyAssociation

      public void setManyToManyAssociation(Class klass, String property)
    • getManyToManyAssociation

      public ConstrainedProperty.ManyToManyAssociation getManyToManyAssociation()
    • manyToManyAssociation

      public ConstrainedProperty manyToManyAssociation()
    • manyToManyAssociation

      public ConstrainedProperty manyToManyAssociation(String property)
    • manyToManyAssociation

      public ConstrainedProperty manyToManyAssociation(Class klass, String property)
    • hasManyToManyAssociation

      public boolean hasManyToManyAssociation()
    • format

      public ConstrainedProperty format(Format format)
    • setFormat

      public void setFormat(Format format)
    • getFormat

      public Format getFormat()
    • isFormatted

      public boolean isFormatted()
    • sparse

      public ConstrainedProperty sparse(boolean sparse)
    • setSparse

      public void setSparse(boolean sparse)
    • isSparse

      public boolean isSparse()
    • listed

      public ConstrainedProperty listed(boolean listed)
      Sets whether the property should be included in data lists.

      This is not actually used by the CMF itself, but is very useful when integrating with automatic user interface generation libraries.

      Parameters:
      listed - true if the property should be listed; or

      false if it shouldn't

      Returns:
      the current ConstrainedProperty instance
      Since:
      1.0
      See Also:
    • setListed

      public void setListed(boolean listed)
      Sets whether the property should be included in data lists.
      Parameters:
      listed - true if the property should be listed; or

      false if it shouldn't

      Since:
      1.0
      See Also:
    • isListed

      public boolean isListed()
      Retrieves whether the property should be included in data lists.
      Returns:
      true if the property should be listed; or

      false if it shouldn't

      Since:
      1.0
      See Also:
    • position

      public ConstrainedProperty position(int position)
      Sets the position in which the property should be displayed.

      This is not actually used by the CMF itself, but is very useful when integrating with automatic user interface generation libraries.

      Parameters:
      position - an integer value with the position; or

      -1 if the property shouldn't be positioned

      Returns:
      the current ConstrainedProperty instance
      Since:
      1.0
      See Also:
    • setPosition

      public void setPosition(int position)
      Sets the position in which the property should be displayed.
      Parameters:
      position - an integer value with the position; or

      -1 if the property shouldn't be positioned

      Since:
      1.0
      See Also:
    • hasPosition

      public boolean hasPosition()
      Indicates whether the position of the property is set.
      Returns:
      true if the property has a position; or

      false if it hasn't

      Since:
      1.0
      See Also:
    • getPosition

      public int getPosition()
      Retrieves the position in which the property should be displayed.
      Returns:
      an integer value with the position; or

      -1 if the property shouldn't be positioned

      Since:
      1.0
      See Also:
    • mimeType

      public ConstrainedProperty mimeType(MimeType mimeType)
      Sets the mime type of the property.

      Setting this constraint will make the ContentQueryManager automatically store the data in this property in the content management back-end. This column will not be stored in a regular database table. All this is handled transparently and automatically.

      Parameters:
      mimeType - the MimeType of the property
      Returns:
      the current ConstrainedProperty instance
      Since:
      1.0
      See Also:
    • setMimeType

      public void setMimeType(MimeType mimeType)
      Sets the mime type of the property.
      Parameters:
      mimeType - the MimeType of the property
      Since:
      1.0
      See Also:
    • hasMimeType

      public boolean hasMimeType()
      Indicates whether the property has a mime type.
      Returns:
      true if the property has a mime type; or

      false if it hasn't

      Since:
      1.0
      See Also:
    • getMimeType

      public MimeType getMimeType()
      Retrieves the mime type of the property.
      Returns:
      the mime type of the property; or

      null if the property has no mime type

      Since:
      1.0
      See Also:
    • autoRetrieved

      public ConstrainedProperty autoRetrieved(boolean autoRetrieved)
      Sets whether the content data of this property should be retrieved automatically from the back-end.

      This is only useful when the property also has a mime type constraint.

      It's not recommended to enable this constraint for large data since everything will be stored in memory, only use this for text snippets or something relatively small.

      Parameters:
      autoRetrieved - true if the data should be automatically retrieved; or

      false otherwise

      Returns:
      the current ConstrainedProperty instance
      Since:
      1.0
      See Also:
    • setAutoRetrieved

      public void setAutoRetrieved(boolean autoRetrieved)
      Sets whether the content data of this property should be retrieved automatically from the back-end.
      Parameters:
      autoRetrieved - true if the data should be automatically retrieved; or

      false otherwise

      Since:
      1.0
      See Also:
    • isAutoRetrieved

      public boolean isAutoRetrieved()
      Indicates whether the content data of this property is automatically retrieved from the back-end.
      Returns:
      true if the data should be automatically retrieved; or

      false otherwise

      Since:
      1.0
      See Also:
    • fragment

      public ConstrainedProperty fragment(boolean fragment)
      Sets whether the content data of this property is a fragment.

      This is only useful when the property also has a mime type constraint. A fragment means that it's not a complete document or a file, but rather a small part that is intended to be used within a larger document. For example a HTML snippet. This information is for example important when validating the data.

      Parameters:
      fragment - true if the content is a fragment; or

      false otherwise

      Returns:
      the current ConstrainedProperty instance
      Since:
      1.0
      See Also:
    • setFragment

      public void setFragment(boolean fragment)
      Sets whether the content data of this property is a fragment.
      Parameters:
      fragment - true if the content is a fragment; or

      false otherwise

      Since:
      1.0
      See Also:
    • isFragment

      public boolean isFragment()
      Indicates whether the content data of this property is a fragment.
      Returns:
      true if the content is a fragment; or

      false otherwise

      Since:
      1.0
      See Also:
    • name

      public ConstrainedProperty name(String name)
      Sets the name of the content data of this property.

      This is only useful when the property also has a mime type constraint.

      Parameters:
      name - the name
      Returns:
      the current ConstrainedProperty instance
      Since:
      1.0
      See Also:
    • setName

      public void setName(String name)
      Sets the name of the content data of this property.
      Parameters:
      name - the name
      Since:
      1.0
      See Also:
    • getName

      public String getName()
      Retrieves the name of this property.
      Returns:
      null if the content data has no name; or

      the name of the content

      Since:
      1.0
      See Also:
    • hasName

      public boolean hasName()
      Indicates whether this property has a name.
      Returns:
      true if the property has a name; or

      false otherwise

      Since:
      1.0
      See Also:
    • repository

      public ConstrainedProperty repository(String repository)
      Sets the repository where the content data of this property will be stored.

      This is only useful when the property also has a mime type constraint.

      Parameters:
      repository - the repository
      Returns:
      the current CmrProperty instance
      Since:
      1.0
      See Also:
    • setRepository

      public void setRepository(String repository)
      Sets the repository where the content data of this property will be stored.
      Parameters:
      repository - the repository
      Since:
      1.0
      See Also:
    • getRepository

      public String getRepository()
      Retrieves the repository where the content data of this property will be stored.
      Returns:
      null if no repository has been specified; or

      the name of the repository

      Since:
      1.0
      See Also:
    • hasRepository

      public boolean hasRepository()
      Indicates whether this property will be stored in another repository than the default repository.
      Returns:
      true if the property will be stored in another repository; or

      false otherwise

      Since:
      1.0
      See Also:
    • ordinal

      public ConstrainedProperty ordinal(boolean ordinal)
      Sets whether this property has to be used as an ordinal.

      The value of this property will be handled in the back-end by an OrdinalManager. It will also enable the move, up and down methods in the ContentQueryManager to easily reorder data rows in the back-end.

      Parameters:
      ordinal - true if this property is an ordinal; or

      false otherwise

      Returns:
      the current ConstrainedProperty instance
      Since:
      1.0
      See Also:
    • ordinal

      public ConstrainedProperty ordinal(boolean ordinal, String restriction)
      Sets whether this property has to be used as an ordinal with a restricting column.
      Parameters:
      ordinal - true if this property is an ordinal; or

      false otherwise

      restriction - the name of the restricting column
      Returns:
      the current ConstrainedProperty instance
      Since:
      1.0
      See Also:
    • setOrdinal

      public void setOrdinal(boolean ordinal)
      Sets whether this property has to be used as an ordinal.
      Parameters:
      ordinal - true if this property is an ordinal; or

      false otherwise

      Since:
      1.0
      See Also:
    • setOrdinal

      public void setOrdinal(boolean ordinal, String restriction)
      Sets whether this property has to be used as an ordinal with a restricting column.
      Parameters:
      ordinal - true if this property is an ordinal; or

      false otherwise

      restriction - the name of the restricting column
      Since:
      1.0
      See Also:
    • isOrdinal

      public boolean isOrdinal()
      Indicates whether this property has to be used as an ordinal.
      Returns:
      true if this property is an ordinal; or

      false otherwise

      Since:
      1.0
      See Also:
    • hasOrdinalRestriction

      public boolean hasOrdinalRestriction()
      Indicates whether this property has an ordinal restricting column.
      Returns:
      true if this property has an ordinal restricting column; or

      false otherwise

      Since:
      1.0
      See Also:
    • getOrdinalRestriction

      public String getOrdinalRestriction()
      Retrieves the ordinal restriction of this property.
      Returns:
      the name of the ordinal restricting column; or

      null if no ordinal restricting column has been defined

      Since:
      1.0
      See Also:
    • contentAttribute

      public ConstrainedProperty contentAttribute(String name, boolean value)
      Sets a named content attribute for this property that will be converted internally to a String value.
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • contentAttribute

      public ConstrainedProperty contentAttribute(String name, char value)
      Sets a named content attribute for this property that will be converted internally to a String value.
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • contentAttribute

      public ConstrainedProperty contentAttribute(String name, byte value)
      Sets a named content attribute for this property that will be converted internally to a String value.
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • contentAttribute

      public ConstrainedProperty contentAttribute(String name, short value)
      Sets a named content attribute for this property that will be converted internally to a String value.
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • contentAttribute

      public ConstrainedProperty contentAttribute(String name, int value)
      Sets a named content attribute for this property that will be converted internally to a String value.
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • contentAttribute

      public ConstrainedProperty contentAttribute(String name, long value)
      Sets a named content attribute for this property that will be converted internally to a String value.
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • contentAttribute

      public ConstrainedProperty contentAttribute(String name, float value)
      Sets a named content attribute for this property that will be converted internally to a String value.
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • contentAttribute

      public ConstrainedProperty contentAttribute(String name, double value)
      Sets a named content attribute for this property that will be converted internally to a String value.
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • contentAttribute

      public ConstrainedProperty contentAttribute(String name, String value)
      Sets a named content attribute for this property.

      This is only useful when the property also has a mime type constraint.

      A content attribute provides additional metadata about how you want to store the content data after loading, this can for example be image dimensions.

      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • getContentAttributes

      public Map<String,String> getContentAttributes()
      Retrieves the map of named content attributes for this property.
      Returns:
      the map of named content attributes; or

      null if no attributes are present

      Since:
      1.0
      See Also:
    • transformer

      public ConstrainedProperty transformer(ContentTransformer<?> transformer)
      Sets a content transformer for this property.

      This is only useful when the property also has a mime type constraint.

      Parameters:
      transformer - the content transformer
      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • setTransformer

      public void setTransformer(ContentTransformer<?> transformer)
      Sets a content transformer for this property.
      Parameters:
      transformer - the content transformer
      Since:
      1.0
      See Also:
    • hasTransformer

      public boolean hasTransformer()
      Indicates whether this property has a content transformer.
      Returns:
      true if this property has a content transformer; or

      false otherwise

      Since:
      1.0
      See Also:
    • getTransformer

      public ContentTransformer<?> getTransformer()
      Retrieves the content transformer of this property.
      Returns:
      the requested content transformer; or

      null if no content transformer has been defined

      Since:
      1.0
      See Also:
    • setCachedLoadedData

      public void setCachedLoadedData(Object data)
      Sets the cached loaded data.

      This is used internally and should never be used explicitly by a developer.

      Parameters:
      data - the loaded data
      Since:
      1.0
      See Also:
    • getCachedLoadedData

      public Object getCachedLoadedData()
      Retrieves the cached loaded content data.
      Returns:
      the cached loaded content data; or

      null if no loaded content data has been cached

      Since:
      1.0
      See Also:
    • setConstraint

      public void setConstraint(String name, Object constraintData)
      Sets the data of a particular constraint in a generic fashion.

      Note that it's not recommended to use this to set any of the standard constraints since none of the additional logic and checks are executed.

      Since:
      1.0
      See Also:
    • constraint

      public ConstrainedProperty constraint(String name, Object constraintData)
      Sets the data of a particular constraint in a generic fashion.

      Note that it's not recommended to use this to set any of the standard constraints since none of the additional logic and checks are executed.

      Returns:
      the current Content instance
      Since:
      1.0
      See Also:
    • getConstraint

      public Object getConstraint(String name)
      Retrieves the value of a particular constraint in a generic fashion
      Returns:
      the data of a particular constraint; or

      null if nothing has been registered for that constraint

      Since:
      1.0
      See Also:
    • getConstraints

      public Map<String,Object> getConstraints()
      Retrieves the map of all the constraints.
      Returns:
      the map with all the registered constraints
      Since:
      1.0
      See Also:
    • clone

      public ConstrainedProperty clone()
      Overrides:
      clone in class Object