Module is.codion.framework.domain
Interface EntityDefinition.Builder
- Enclosing interface:
EntityDefinition
public static sealed interface EntityDefinition.Builder
Builds a EntityDefinition
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild()cacheToString(boolean cacheToString) Default true.Sets the caption for this entity typecaptionResourceKey(String captionResourceKey) Specifies the resource bundle key associated with the caption.comparator(Comparator<Entity> comparator) Sets the comparator to use when comparing entities of this typecondition(ConditionType conditionType, ConditionString conditionString) Adds aConditionStringwhich provides a dynamic query condition string.description(String description) Specifies a description for this entity.descriptionResourceKey(String descriptionResourceKey) Specifies the resource bundle key associated with the description.Sets the predicate to use when checking if an entity of this type exists in the database.Sets the formatter, based the value of the given attribute.Sets the formatter, that is, the function responsible for creating toString() values for this entity type.optimisticLocking(boolean optimisticLocking) Use this to disable optimistic locking for this entity typeSets the order by clause for this entity type.readOnly(boolean readOnly) Specifies whether this entity should be read-only, that it should not be possible to insert, update or delete entities of this typeselectQuery(EntitySelectQuery selectQuery) Sets the select query to use when selecting entities of this type, use with care.selectTable(String selectTable) Sets the name of the table to use when selecting entities of this type, when it differs from the one used to update/insert, such as a view.smallDataset(boolean smallDataset) Specifies whether this entity should be regarded as being based on a small dataset, which primarily means that combo box models can be based on this entity.validator(EntityValidator validator)
-
Method Details
-
table
- Parameters:
table- the table name- Returns:
- this
EntityDefinition.Builderinstance
-
validator
- Parameters:
validator- the validator for this entity type- Returns:
- this
EntityDefinition.Builderinstance
-
condition
Adds aConditionStringwhich provides a dynamic query condition string. The condition string should not include the WHERE keyword and use the ? substitution character where values should be inserted.- Parameters:
conditionType- the condition typeconditionString- the condition string provider- Returns:
- this
EntityDefinition.Builderinstance
-
caption
Sets the caption for this entity type- Parameters:
caption- the caption- Returns:
- this
EntityDefinition.Builderinstance
-
captionResourceKey
Specifies the resource bundle key associated with the caption. Defaults toentityType.name()- Parameters:
captionResourceKey- the name of the resource bundle key associated with the caption for this entity- Returns:
- this
EntityDefinition.Builderinstance - See Also:
-
descriptionResourceKey
Specifies the resource bundle key associated with the description. Defaults toentityType.name() + ".description"- Parameters:
descriptionResourceKey- the name of the resource bundle key associated with the description for this entity- Returns:
- this
EntityDefinition.Builderinstance - See Also:
-
description
Specifies a description for this entity.- Parameters:
description- the description- Returns:
- this
EntityDefinition.Builderinstance
-
smallDataset
Specifies whether this entity should be regarded as being based on a small dataset, which primarily means that combo box models can be based on this entity.- Parameters:
smallDataset- true if this entity is based on a small dataset- Returns:
- this
EntityDefinition.Builderinstance
-
readOnly
Specifies whether this entity should be read-only, that it should not be possible to insert, update or delete entities of this type- Parameters:
readOnly- true if this entity is read-only- Returns:
- this
EntityDefinition.Builderinstance
-
optimisticLocking
Use this to disable optimistic locking for this entity type- Parameters:
optimisticLocking- true if optimistic locking should be used during updates, false to disable- Returns:
- this
EntityDefinition.Builderinstance - See Also:
-
orderBy
Sets the order by clause for this entity type.- Parameters:
orderBy- the order by clause- Returns:
- this
EntityDefinition.Builderinstance
-
selectTable
Sets the name of the table to use when selecting entities of this type, when it differs from the one used to update/insert, such as a view.- Parameters:
selectTable- the name of the table- Returns:
- this
EntityDefinition.Builderinstance
-
selectQuery
Sets the select query to use when selecting entities of this type, use with care.- Parameters:
selectQuery- the select query to use for this entity type- Returns:
- this
EntityDefinition.Builderinstance
-
formatter
Sets the formatter, based the value of the given attribute. Shortcut for:formatter(EntityFormatter.builder() .value(attribute) .build())- Parameters:
attribute- the attribute which value to use when formatting- Returns:
- this
EntityDefinition.Builderinstance
-
formatter
Sets the formatter, that is, the function responsible for creating toString() values for this entity type. Note that if for some reason this formatter returns null, the default formatter is used as fallback, which simply returns the entity type name and primary key value.- Parameters:
formatter- the formatter- Returns:
- this
EntityDefinition.Builderinstance - See Also:
-
cacheToString
Default true.- Parameters:
cacheToString- true if the result of toString() should be cached- Returns:
- this
EntityDefinition.Builderinstance
-
comparator
Sets the comparator to use when comparing entities of this type- Parameters:
comparator- the comparator- Returns:
- this
EntityDefinition.Builderinstance
-
exists
Sets the predicate to use when checking if an entity of this type exists in the database. The default predicate returns true if the entity has a non-null original primary key, which is a best-guess about an entity existing in a database.- Parameters:
exists- the entity exists predicate- Returns:
- this
EntityDefinition.Builderinstance
-
build
EntityDefinition build()- Returns:
- a new
EntityDefinitioninstance based on this builder
-