Module is.codion.framework.domain
Interface EntityDefinition.Builder
- Enclosing interface:
- EntityDefinition
public static interface EntityDefinition.Builder
Builds a EntityDefinition
-
Method Summary
Modifier and TypeMethodDescriptionbackgroundColorProvider
(ColorProvider backgroundColorProvider) build()
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, ConditionProvider conditionProvider) Adds aConditionProvider
which provides a dynamic query condition string.description
(String description) Specifies a description for this entity.Sets the predicate to use when checking if an entity of this type exists in the database.foregroundColorProvider
(ColorProvider foregroundColorProvider) keyGenerator
(KeyGenerator keyGenerator) Sets the primary key generatoroptimisticLocking
(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
(SelectQuery selectQuery) Sets the select query to use when selecting entities of this type, use with care.selectTableName
(String selectTableName) 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.stringFactory
(Attribute<?> attribute) Sets the string factory, using the value of the given attribute.stringFactory
(Function<Entity, String> stringFactory) Sets the string factory, that is, the function responsible for creating toString() values for this entity type.validator
(EntityValidator validator)
-
Method Details
-
tableName
- Parameters:
tableName
- the table name- Returns:
- this
EntityDefinition.Builder
instance
-
validator
- Parameters:
validator
- the validator for this entity type- Returns:
- this
EntityDefinition.Builder
instance
-
condition
EntityDefinition.Builder condition(ConditionType conditionType, ConditionProvider conditionProvider) Adds aConditionProvider
which 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 typeconditionProvider
- the condition provider- Returns:
- this
EntityDefinition.Builder
instance
-
backgroundColorProvider
- Parameters:
backgroundColorProvider
- the background color provider- Returns:
- this
EntityDefinition.Builder
instance
-
foregroundColorProvider
- Parameters:
foregroundColorProvider
- the foreground color provider- Returns:
- this
EntityDefinition.Builder
instance
-
caption
Sets the caption for this entity type- Parameters:
caption
- the caption- Returns:
- this
EntityDefinition.Builder
instance
-
captionResourceKey
Specifies the resource bundle key associated with the caption.- Parameters:
captionResourceKey
- the name of the resource bundle key associated with the caption for this entity- Returns:
- this
EntityDefinition.Builder
instance - See Also:
-
description
Specifies a description for this entity.- Parameters:
description
- the description- Returns:
- this
EntityDefinition.Builder
instance
-
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.Builder
instance
-
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.Builder
instance
-
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.Builder
instance
-
keyGenerator
Sets the primary key generator- Parameters:
keyGenerator
- the primary key generator- Returns:
- this
EntityDefinition.Builder
instance - See Also:
-
orderBy
Sets the order by clause for this entity type.- Parameters:
orderBy
- the order by clause- Returns:
- this
EntityDefinition.Builder
instance
-
selectTableName
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:
selectTableName
- the name of the table- Returns:
- this
EntityDefinition.Builder
instance
-
selectQuery
Sets the select query to use when selecting entities of this type, use with care. If the query contains a columns clause, the order of the attributes when defining the entity must match the column order in the given query.- Parameters:
selectQuery
- the select query to use for this entity type- Returns:
- this
EntityDefinition.Builder
instance
-
stringFactory
Sets the string factory, using the value of the given attribute. Shortcut for:stringFactory(StringFactory.builder() .value(attribute) .build())
- Parameters:
attribute
- the attribute which value to use- Returns:
- this
EntityDefinition.Builder
instance
-
stringFactory
Sets the string factory, that is, the function responsible for creating toString() values for this entity type. Note that if for some reason this function returns null, the default string factory is used as fallback, which simply returns the entity type name and primary key value.- Parameters:
stringFactory
- the string factory function- Returns:
- this
EntityDefinition.Builder
instance
-
comparator
Sets the comparator to use when comparing entities of this type- Parameters:
comparator
- the comparator- Returns:
- this
EntityDefinition.Builder
instance
-
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.Builder
instance
-
build
EntityDefinition build()- Returns:
- a new
EntityDefinition
instance based on this builder
-