Module is.codion.framework.domain
Interface AttributeDefinition.Builder<T,B extends AttributeDefinition.Builder<T,B>>
- Type Parameters:
T
- the value typeB
- the builder type
- All Known Subinterfaces:
ColumnDefinition.Builder<T,
,B> DerivedAttributeDefinition.Builder<T,
,B> ForeignKeyDefinition.Builder
,TransientAttributeDefinition.Builder<T,
B>
- Enclosing interface:
- AttributeDefinition<T>
public static interface AttributeDefinition.Builder<T,B extends AttributeDefinition.Builder<T,B>>
Builds a attribute definition instance
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a new attribute definition instanceNote that this method has a side-effect, when setting the caption to a null value this attribute is automatically hidden viahidden(boolean)
, when a non-null value is used it is automatically made visible (as in, not hidden).captionResourceKey
(String captionResourceKey) Specifies the key to use when retrieving the caption for this attribute from the entity resource bundle, in case it differes from the attribute name (Attribute.name()
), which is the default value.comparator
(Comparator<T> comparator) dateTimePattern
(String dateTimePattern) Sets the date/time format pattern used when presenting and inputtind valuesdecimalRoundingMode
(RoundingMode decimalRoundingMode) Sets the rounding mode to use when working with decimalsdefaultValue
(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 anydescription
(String description) Sets the description for this attribute, used for tooltips f.ex.Sets the Format to use when presenting attribute valueshidden
(boolean hidden) Specifies whether this attribute should be hidden in table viewslocaleDateTimePattern
(LocaleDateTimePattern localeDateTimePattern) Sets the locale aware date/time format pattern used when presenting and inputting valuesmaximumFractionDigits
(int maximumFractionDigits) Sets the maximum fraction digits to show for this attribute, only applicable to attributes based on decimal types.maximumLength
(int maximumLength) Sets the maximum length of this attribute value, this applies to String (varchar) based attributesmaximumValue
(Number maximumValue) Only applicable to numerical attributesminimumValue
(Number minimumValue) Only applicable to numerical attributesmnemonic
(char mnemonic) Sets the mnemonic to use when creating a label for this attributenullable
(boolean nullable) Specifies whether this attribute is nullable.numberFormatGrouping
(boolean numberFormatGrouping) Specifies whether to use number grouping when presenting the value associated with this attribute.valueRange
(Number minimumValue, Number maximumValue) Only applicable to numerical attributes
-
Method Details
-
attribute
- Returns:
- the underying attribute
-
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
-
minimumValue
Only applicable to numerical attributes- Parameters:
minimumValue
- the minimum allowed value for this attribute- Returns:
- this builder instance
- Throws:
IllegalStateException
- in case this is not a numerical attribute
-
maximumValue
Only applicable to numerical attributes- Parameters:
maximumValue
- the maximum allowed value for this attribute- Returns:
- this builder instance
- Throws:
IllegalStateException
- in case this is not a numerical attribute
-
valueRange
Only applicable to numerical attributes- Parameters:
minimumValue
- the minimum allowed value for this attributemaximumValue
- the maximum allowed value for this attribute- Returns:
- this builder instance
- Throws:
IllegalStateException
- in case this is not a numerical attribute
-
maximumFractionDigits
Sets the maximum fraction digits to show for this attribute, only applicable to attributes based on decimal types. This setting is overridden during subsequent calls toformat(Format)
. Note that values associated with this attribute are automatically rounded tomaximumFractionDigits
digits.- Parameters:
maximumFractionDigits
- the maximum fraction digits- Returns:
- this builder instance
- Throws:
IllegalStateException
- in case this is not a decimal attribute- See Also:
-
decimalRoundingMode
Sets the rounding mode to use when working with decimals- Parameters:
decimalRoundingMode
- the rounding mode- Returns:
- this builder instance
- Throws:
IllegalStateException
- in case this is not a decimal attribute- See Also:
-
numberFormatGrouping
Specifies whether to use number grouping when presenting the value associated with this attribute. i.e. 1234567 shown as 1.234.567 or 1,234,567 depending on locale. By default, grouping is not used. Only applicable to numerical attributes. This setting is overridden during subsequent calls toformat(Format)
- Parameters:
numberFormatGrouping
- if true then number grouping is used- Returns:
- this builder instance
- Throws:
IllegalStateException
- in case this is not a numerical attribute
-
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
-
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
-
mnemonic
Sets the mnemonic to use when creating a label for this attribute- Parameters:
mnemonic
- the mnemonic character- Returns:
- this builder instance
-
description
Sets the description for this attribute, used for tooltips f.ex.- Parameters:
description
- a String describing this attribute- Returns:
- this builder instance
-
comparator
- Parameters:
comparator
- the Comparator to use when comparing values for this attribute- Returns:
- this builder instance
-
format
Sets the Format to use when presenting attribute values- Parameters:
format
- the format to use- Returns:
- this builder instance
- Throws:
NullPointerException
- in case format is nullIllegalArgumentException
- in case this is a numerical attribute and the given format is not a NumberFormat.IllegalStateException
- if the underlying attribute is temporal, in which casedateTimePattern(String)
orlocaleDateTimePattern(LocaleDateTimePattern)
should be used.
-
dateTimePattern
Sets the date/time format pattern used when presenting and inputtind values- Parameters:
dateTimePattern
- the format pattern- Returns:
- this builder instance
- Throws:
IllegalArgumentException
- in case the pattern is invalidIllegalStateException
- in case this is not a temporal attributeIllegalStateException
- in caselocaleDateTimePattern(LocaleDateTimePattern)
has been set
-
localeDateTimePattern
Sets the locale aware date/time format pattern used when presenting and inputting values- Parameters:
localeDateTimePattern
- the format pattern- Returns:
- this builder instance
- Throws:
IllegalStateException
- in case this is not a temporal attributeIllegalStateException
- in casedateTimePattern(String)
has been set
-
items
- Parameters:
items
- the Items representing all the valid values for this attribute- Returns:
- this builder instance
- Throws:
IllegalArgumentException
- in case the valid item list contains duplicate values
-
build
AttributeDefinition<T> build()Builds a new attribute definition instance- Returns:
- a new attribute definition instance based on this builder
-