Module is.codion.framework.domain
Interface ValueAttributeDefinition.Builder<T,B extends ValueAttributeDefinition.Builder<T,B>>
- Type Parameters:
T- the value typeB- the builder type
- All Superinterfaces:
AttributeDefinition.Builder<T,B>
- All Known Subinterfaces:
ColumnDefinition.Builder<T,,B> TransientAttributeDefinition.Builder<T,B>
- Enclosing interface:
ValueAttributeDefinition<T>
public static sealed interface ValueAttributeDefinition.Builder<T,B extends ValueAttributeDefinition.Builder<T,B>>
extends AttributeDefinition.Builder<T,B>
permits ColumnDefinition.Builder<T,B>, TransientAttributeDefinition.Builder<T,B> (not exhaustive)
Builds a ValueAttributeDefinition instance
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a new attribute definition instancedefaultValue(AttributeDefinition.ValueSupplier<T> supplier) Sets the default value supplier, use in case of dynamic default values.defaultValue(T defaultValue) Sets the default value for this attribute, overrides the underlying column default value, if anyNote that by default items are sorted by to their caption, not their value.Only applicable to numerical attributesmaximumLength(int maximumLength) Sets the maximum length of this attribute value, this applies to String (varchar) based attributesOnly applicable to numerical attributesnullable(boolean nullable) Specifies whether this attribute is nullable.Only applicable to numerical attributestrim(boolean trim) Specifies whether string values should be trimmed, this applies to String (varchar) based attributes.Methods inherited from interface is.codion.framework.domain.entity.attribute.AttributeDefinition.Builder
attribute, caption, captionResource, captionResource, comparator, dateTimePattern, dateTimePattern, description, descriptionResource, descriptionResource, format, fractionDigits, hidden, mnemonic, mnemonicResource, mnemonicResource, numberGrouping, roundingMode
-
Method Details
-
nullable
Specifies whether this attribute is nullable. Note that this will not prevent the value from being set to null, only prevent successful validation of the entity.- Parameters:
nullable- specifies whether null is a valid value for this attribute- Returns:
- this builder instance
-
minimum
Only applicable to numerical attributes- Parameters:
minimum- the minimum allowed value for this attribute- Returns:
- this builder instance
- Throws:
IllegalStateException- in case this is not a numerical attribute
-
maximum
Only applicable to numerical attributes- Parameters:
maximum- the maximum allowed value for this attribute- Returns:
- this builder instance
- Throws:
IllegalStateException- in case this is not a numerical attribute
-
range
Only applicable to numerical attributes- Parameters:
minimum- the minimum allowed value for this attributemaximum- the maximum allowed value for this attribute- Returns:
- this builder instance
- Throws:
IllegalStateException- in case this is not a numerical attribute
-
maximumLength
Sets the maximum length of this attribute value, this applies to String (varchar) based attributes- Parameters:
maximumLength- the maximum length- Returns:
- this builder instance
- Throws:
IllegalStateException- in case this is not a String attribute
-
trim
Specifies whether string values should be trimmed, this applies to String (varchar) based attributes.- Parameters:
trim- true if strings values should be trimmed- Returns:
- this builder instance
- Throws:
IllegalStateException- in case this is not a String attribute- See Also:
-
items
Note that by default items are sorted by to their caption, not their value. UseAttributeDefinition.Builder.comparator(java.util.Comparator)to set a custom comparator.- Parameters:
items- theItems representing all the valid values for this attribute- Returns:
- this builder instance
- Throws:
IllegalArgumentException- in case the valid item list contains duplicate values
-
defaultValue
Sets the default value for this attribute, overrides the underlying column default value, if any- Parameters:
defaultValue- the value to use as default- Returns:
- this builder instance
-
defaultValue
Sets the default value supplier, use in case of dynamic default values.- Parameters:
supplier- the default value supplier- Returns:
- this builder instance
-
build
ValueAttributeDefinition<T> build()Description copied from interface:AttributeDefinition.BuilderBuilds a new attribute definition instance- Specified by:
buildin interfaceAttributeDefinition.Builder<T,B extends ValueAttributeDefinition.Builder<T, B>> - Returns:
- a new attribute definition instance based on this builder
-