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.DenormalizedBuilder<T,,B> DerivedAttributeDefinition.DerivedBuilder<T,,B> ForeignKeyDefinition.Builder,TransientAttributeDefinition.Builder<T,,B> ValueAttributeDefinition.Builder<T,B>
- Enclosing interface:
AttributeDefinition<T>
public static sealed interface AttributeDefinition.Builder<T,B extends AttributeDefinition.Builder<T,B>>
permits DerivedAttributeDefinition.DenormalizedBuilder<T,B>, DerivedAttributeDefinition.DerivedBuilder<T,B>, ForeignKeyDefinition.Builder, ValueAttributeDefinition.Builder<T,B> (not exhaustive)
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).captionResource(String captionResourceKey) Specifies the key to use when retrieving the caption for this attribute from the entity resource bundle, in case it differs from the attribute name (Attribute.name()), which is the default value.captionResource(String resourceBundleName, String captionResourceKey) Specifies the key to use when retrieving the caption for this attribute from the given resource bundle.comparator(Comparator<T> comparator) dateTimePattern(LocaleDateTimePattern dateTimePattern) Sets the locale aware date/time format pattern used when presenting and inputting valuesdateTimePattern(String dateTimePattern) Sets the date/time format pattern used when presenting and inputtind valuesdescription(String description) Sets the description for this attribute, used for tooltips f.ex.descriptionResource(String descriptionResourceKey) Specifies the key to use when retrieving the description for this attribute from the entity resource bundle, in case it differs fromAttribute.name()+AttributeDefinition.DESCRIPTION_RESOURCE_SUFFIX, which is the default value.descriptionResource(String resourceBundleName, String descriptionResourceKey) Specifies the key to use when retrieving the description for this attribute from the entity resource bundle, in case it differs fromAttribute.name()+AttributeDefinition.DESCRIPTION_RESOURCE_SUFFIX, which is the default value.Sets the Format to use when presenting attribute valuesfractionDigits(int fractionDigits) Sets the maximum fraction digits to show for this attribute, only applicable to attributes based on decimal types.hidden(boolean hidden) Specifies whether this attribute should be hidden in table viewsmnemonic(char mnemonic) Sets the mnemonic to use when creating a label for this attributemnemonicResource(String mnemonicResourceKey) Specifies the key to use when retrieving the mnemonic for this attribute from the entity resource bundle, in case it differs fromAttribute.name()+AttributeDefinition.MNEMONIC_RESOURCE_SUFFIX, which is the default value.mnemonicResource(String resourceBundleName, String mnemonicResourceKey) Specifies the key to use when retrieving the mnemonic for this attribute from the given resource bundle.numberGrouping(boolean numberGrouping) Specifies whether to use number grouping when presenting the value associated with this attribute.roundingMode(RoundingMode roundingMode) Sets the rounding mode to use when working with decimals
-
Method Details
-
attribute
- Returns:
- the underying attribute
-
caption
Note 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).- Parameters:
caption- the caption- Returns:
- this builder instance
- See Also:
-
captionResource
Specifies the key to use when retrieving the caption for this attribute from the entity resource bundle, in case it differs from the attribute name (Attribute.name()), which is the default value. Note that this configures the attribute to not be hidden.- Parameters:
captionResourceKey- the caption resource bundle key- Returns:
- this builder instance
- Throws:
IllegalStateException- in case the caption has already been setIllegalStateException- in case no resource bundle is specified for the entityIllegalStateException- in case the caption resource is not found in the entity resource bundle- See Also:
-
captionResource
Specifies the key to use when retrieving the caption for this attribute from the given resource bundle. Note that this configures the attribute to not be hidden.- Parameters:
resourceBundleName- the resource bundle namecaptionResourceKey- the caption resource bundle key- Returns:
- this builder instance
- Throws:
IllegalStateException- in case the caption has already been setIllegalStateException- in case the caption resource is not found in the given resource bundle
-
mnemonicResource
Specifies the key to use when retrieving the mnemonic for this attribute from the entity resource bundle, in case it differs fromAttribute.name()+AttributeDefinition.MNEMONIC_RESOURCE_SUFFIX, which is the default value.- Parameters:
mnemonicResourceKey- the mnemonic resource bundle key- Returns:
- this builder instance
- Throws:
IllegalStateException- in case the mnemonic has already been setIllegalStateException- in case no resource bundle is specified for the entityIllegalStateException- in case the mnemonic resource is not found in the entity resource bundle- See Also:
-
mnemonicResource
Specifies the key to use when retrieving the mnemonic for this attribute from the given resource bundle.- Parameters:
resourceBundleName- the resource bundle namemnemonicResourceKey- the mnemonic resource bundle key- Returns:
- this builder instance
- Throws:
IllegalStateException- in case the mnemonic has already been setIllegalStateException- in case the mnemonic resource is not found in the given resource bundle
-
fractionDigits
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 toAttributeDefinition.fractionDigits()digits.- Parameters:
fractionDigits- the maximum fraction digits- Returns:
- this builder instance
- Throws:
IllegalStateException- in case this is not a decimal attribute- See Also:
-
roundingMode
Sets the rounding mode to use when working with decimals- Parameters:
roundingMode- the rounding mode- Returns:
- this builder instance
- Throws:
IllegalStateException- in case this is not a decimal attribute- See Also:
-
numberGrouping
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:
numberGrouping- if true then number grouping is used- Returns:
- this builder instance
- Throws:
IllegalStateException- in case this is not a numerical attribute
-
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)ordateTimePattern(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 casedateTimePattern(LocaleDateTimePattern)has been set
-
dateTimePattern
Sets the locale aware date/time format pattern used when presenting and inputting values- Parameters:
dateTimePattern- the format pattern- Returns:
- this builder instance
- Throws:
IllegalStateException- in case this is not a temporal attributeIllegalStateException- in casedateTimePattern(String)has been set
-
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
-
descriptionResource
Specifies the key to use when retrieving the description for this attribute from the entity resource bundle, in case it differs fromAttribute.name()+AttributeDefinition.DESCRIPTION_RESOURCE_SUFFIX, which is the default value.- Parameters:
descriptionResourceKey- the description resource bundle key- Returns:
- this builder instance
- Throws:
IllegalStateException- in case the description has already been setIllegalStateException- in case no resource bundle is specified for the entityIllegalStateException- in case the description resource is not found in the entity resource bundle- See Also:
-
descriptionResource
Specifies the key to use when retrieving the description for this attribute from the entity resource bundle, in case it differs fromAttribute.name()+AttributeDefinition.DESCRIPTION_RESOURCE_SUFFIX, which is the default value.- Parameters:
resourceBundleName- the resource bundle namedescriptionResourceKey- the description resource bundle key- Returns:
- this builder instance
- Throws:
IllegalStateException- in case the description has already been setIllegalStateException- in case the description resource is not found in the given resource bundle
-
comparator
- Parameters:
comparator- the Comparator to use when comparing values for this attribute- Returns:
- this builder instance
-
build
AttributeDefinition<T> build()Builds a new attribute definition instance- Returns:
- a new attribute definition instance based on this builder
-