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 ValueAttributeDefinition.Builder<T,B>, ForeignKeyDefinition.Builder (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) defaultValue(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.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.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.nullable(boolean nullable) Specifies whether this attribute is nullable.
-
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
-
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
-
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
-
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
-