Module is.codion.framework.domain
Interface AttributeDefinition<T>
- Type Parameters:
T
- the underlying type
- All Known Subinterfaces:
AuditColumnDefinition<T>
,ColumnDefinition<T>
,DerivedAttributeDefinition<T>
,ForeignKeyDefinition
,TransientAttributeDefinition<T>
public interface AttributeDefinition<T>
Defines an Attribute. Factory for
AttributeDefinition
instances.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
AttributeDefinition.Builder<T,
B extends AttributeDefinition.Builder<T, B>> Builds a attribute definition instancestatic interface
Supplies values, for example default ones. -
Field Summary
Modifier and TypeFieldDescriptionstatic final PropertyValue<String>
The default date format pattern to use when showing date values in tables and when creating default date input fields Value type: String Default value: dd-MM-yyyy [month/day order is locale specific]static final PropertyValue<String>
The default date/time format pattern to use when showing date/time values in tables and when creating default date/time input fields Value type: String Default value: dd-MM-yyyy HH:mm [month/day order is locale specific]static final PropertyValue<RoundingMode>
Specifies the default rounding mode used for decimal property values Value type:RoundingMode
Default value:RoundingMode.HALF_EVEN
static final PropertyValue<Character>
Specifies the default number decimal separator.static final int
The default maximum fraction digits for floating point numbersstatic final PropertyValue<Character>
Specifies the default number grouping separator Value type: Character Default value: The grouping separator for the default localestatic final PropertyValue<Integer>
Specifies the default maximum number of fraction digits for double property values
Note that values are rounded when set.static final PropertyValue<Boolean>
Specifies whether number format grouping is used by default Value type: Boolean Default value: falsestatic final PropertyValue<String>
The default date format pattern to use when showing time values in tables and when creating default time input fields Value type: String Default value: HH:mmstatic final PropertyValue<Boolean>
Specifies whether String values should use a lexical comparator by default Value type: Boolean Default value: true -
Method Summary
Modifier and TypeMethodDescriptionTheAttribute
this definition is based on, should be unique within an Entity.caption()
Returns the date time formatter used when presenting and inputting values for this attribute.Returns the date time format pattern used when presenting and inputting values for this attribute.static Comparator<AttributeDefinition<?>>
Returns a new Comparator instance for sorting attribute definition instances by caption, or if that is not available, attribute name, ignoring caseboolean
derived()
The value of a derived attribute can not be set, as it's value is derived from other valuesformat()
Returns the Format used when presenting values for this attribute, null if none has been specified.boolean
boolean
hidden()
items()
Returns the valid items for this attribute or an empty list in case this is not an item based attributeint
int
char
mnemonic()
Returns the mnemonic associated with this attribute.boolean
nullable()
Returns a string representation of the given value formatted with this attributes format.boolean
Validates the given value against the valid items for this attribute.
-
Field Details
-
DEFAULT_MAXIMUM_FRACTION_DIGITS
static final int DEFAULT_MAXIMUM_FRACTION_DIGITSThe default maximum fraction digits for floating point numbers- See Also:
-
MAXIMUM_FRACTION_DIGITS
Specifies the default maximum number of fraction digits for double property values
Note that values are rounded when set.- Value type: Integer
- Default value: 10
-
DECIMAL_ROUNDING_MODE
Specifies the default rounding mode used for decimal property values- Value type:
RoundingMode
- Default value:
RoundingMode.HALF_EVEN
- Value type:
-
TIME_FORMAT
The default date format pattern to use when showing time values in tables and when creating default time input fields- Value type: String
- Default value: HH:mm
-
DATE_TIME_FORMAT
The default date/time format pattern to use when showing date/time values in tables and when creating default date/time input fields- Value type: String
- Default value: dd-MM-yyyy HH:mm [month/day order is locale specific]
-
DATE_FORMAT
The default date format pattern to use when showing date values in tables and when creating default date input fields- Value type: String
- Default value: dd-MM-yyyy [month/day order is locale specific]
-
NUMBER_FORMAT_GROUPING
Specifies whether number format grouping is used by default- Value type: Boolean
- Default value: false
-
GROUPING_SEPARATOR
Specifies the default number grouping separator- Value type: Character
- Default value: The grouping separator for the default locale
-
DECIMAL_SEPARATOR
Specifies the default number decimal separator.- Value type: Character
- Default value: The decimal separator for the default locale
-
USE_LEXICAL_STRING_COMPARATOR
Specifies whether String values should use a lexical comparator by default- Value type: Boolean
- Default value: true
-
-
Method Details
-
attribute
TheAttribute
this definition is based on, should be unique within an Entity. By default, theAttribute.name()
serves as column name for database columns.- Returns:
- the attribute this definition is based on
-
entityType
EntityType entityType()- Returns:
- the type of the entity this attribute is associated with
-
description
String description()- Returns:
- a String describing this attribute
-
string
Returns a string representation of the given value formatted with this attributes format. If no format is availableObject.toString()
is used. By default, null values result in an empty string.- Parameters:
value
- the value to format.- Returns:
- the value formatted as a string
- See Also:
-
hasDefaultValue
boolean hasDefaultValue()- Returns:
- true if a default value has been set for this attribute
-
defaultValue
T defaultValue()- Returns:
- the default value for this attribute, if no default value has been set null is returned
- See Also:
-
maximumValue
Number maximumValue()- Returns:
- the maximum allowed value for this attribute, null if none is defined, only applicable to numerical attributes
-
minimumValue
Number minimumValue()- Returns:
- the minimum allowed value for this attribute, null if none is defined, only applicable to numerical attributes
-
maximumFractionDigits
int maximumFractionDigits()- Returns:
- the maximum number of fraction digits to use for this attribute value, -1 if this attribute is not based on Types.DOUBLE or Types.DECIMAL
- See Also:
-
decimalRoundingMode
RoundingMode decimalRoundingMode()- Returns:
- the rounding mode to use when working with decimal values
- See Also:
-
nullable
boolean nullable()- Returns:
- true if null is a valid value for this attribute
-
derived
boolean derived()The value of a derived attribute can not be set, as it's value is derived from other values- Returns:
- true if the value of this attribute is derived from one or more values
-
maximumLength
int maximumLength()- Returns:
- the maximum length of this attribute value, -1 is returned if the maximum length is undefined, this only applies to String (varchar) based attributes
-
mnemonic
char mnemonic()Returns the mnemonic associated with this attribute.- Returns:
- the mnemonic to use when creating a label for this attribute, 0 meaning no mnemonic
-
format
Format format()Returns the Format used when presenting values for this attribute, null if none has been specified.- Returns:
- the Format object used to format the value of attributes when being presented
-
dateTimePattern
String dateTimePattern()Returns the date time format pattern used when presenting and inputting values for this attribute.- Returns:
- the date/time format pattern
-
dateTimeFormatter
DateTimeFormatter dateTimeFormatter()Returns the date time formatter used when presenting and inputting values for this attribute.- Returns:
- the DateTimeFormatter for this attribute or null if this is not a date/time based attribute
-
comparator
Comparator<T> comparator()- Returns:
- the Comparator to use when comparing values associated with this attribute
-
validItem
Validates the given value against the valid items for this attribute. Always returns true if this is not an item based attribute.- Parameters:
value
- the value to validate- Returns:
- true if the given value is a valid item for this attribute
- See Also:
-
items
Returns the valid items for this attribute or an empty list in case this is not an item based attribute- Returns:
- an unmodifiable view of the valid items for this attribute
-
definitionComparator
Returns a new Comparator instance for sorting attribute definition instances by caption, or if that is not available, attribute name, ignoring case- Returns:
- a new Comparator instance
-