Module is.codion.framework.domain
Interface ValueAttributeDefinition<T>
- Type Parameters:
T- the value type
- All Superinterfaces:
AttributeDefinition<T>
- All Known Subinterfaces:
ColumnDefinition<T>,TransientAttributeDefinition<T>
public sealed interface ValueAttributeDefinition<T>
extends AttributeDefinition<T>
permits ColumnDefinition<T>, TransientAttributeDefinition<T> (not exhaustive)
Defines an Attribute that holds concrete values (String, Integer, BigDecimal, etc.)
requiring type-specific validation, formatting, and constraints.
Contrast with ForeignKeyDefinition which holds Entity references and delegates
formatting to the referenced entity's stringFactory.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceBuilds a ValueAttributeDefinition instanceNested classes/interfaces inherited from interface is.codion.framework.domain.entity.attribute.AttributeDefinition
AttributeDefinition.ValueSupplier<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyValue<Boolean> Specifies whether String values should be trimmed by default Value type: Boolean Default value: trueFields inherited from interface is.codion.framework.domain.entity.attribute.AttributeDefinition
DECIMAL_SEPARATOR, DEFAULT_FRACTION_DIGITS, DESCRIPTION_RESOURCE_SUFFIX, FRACTION_DIGITS, GROUPING_SEPARATOR, MNEMONIC_RESOURCE_SUFFIX, NUMBER_GROUPING, ROUNDING_MODE, USE_LEXICAL_STRING_COMPARATOR -
Method Summary
Modifier and TypeMethodDescriptionbooleanitems()Returns the valid items for this attribute or an empty list in case this is not an item based attributemaximum()intminimum()booleannullable()booleantrim()voidValidates the value of this attribute as found in the given entity.booleanValidates the given value against the valid items for this attribute.Methods inherited from interface is.codion.framework.domain.entity.attribute.AttributeDefinition
attribute, caption, comparator, dateTimeFormatter, dateTimePattern, derived, description, entityType, format, format, fractionDigits, hidden, mnemonic, roundingMode
-
Field Details
-
TRIM_STRINGS
Specifies whether String values should be trimmed by default- Value type: Boolean
- Default value: true
- See Also:
-
-
Method Details
-
nullable
boolean nullable()- Returns:
- true if null is a valid value for this attribute
-
maximum
- Returns:
- the maximum allowed value for this attribute, an empty Optional if none is defined, only applicable to numerical attributes
-
minimum
- Returns:
- the minimum allowed value for this attribute, an empty Optional if none is defined, only applicable to numerical attributes
-
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
-
trim
boolean trim()- Returns:
- if string values should be trimmed, this applies to String (varchar) based attributes
-
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
-
hasDefaultValue
boolean hasDefaultValue()- Returns:
- true if a default value has been set for this attribute
-
defaultValue
- Returns:
- the default value for this attribute, if no default value has been set null is returned
- See Also:
-
validate
Validates the value of this attribute as found in the given entity.Note: When validating non-nullable attributes during entity insertion (when the entity does not exist), null values are allowed for:
- Columns with default values - the database will provide the default value
- Generated primary key columns - the database will generate the key value
- Parameters:
entity- the entity containing the value to validatenullable- true if null values are allowed in this validation context, false if null should trigger aNullValidationException- Throws:
ValidationException- in case of an invalid value
-