Module is.codion.framework.domain
Interface EntityDefinition.Builder
-
- Enclosing interface:
- EntityDefinition
public static interface EntityDefinition.Builder
Builds a EntityDefinition
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description EntityDefinition.Builder
backgroundColorProvider(ColorProvider backgroundColorProvider)
EntityDefinition
build()
EntityDefinition.Builder
caption(String caption)
Sets the caption for this entity typeEntityDefinition.Builder
captionResourceKey(String captionResourceKey)
Specifies the resource bundle key associated with the caption.EntityDefinition.Builder
comparator(Comparator<Entity> comparator)
Sets the comparator to use when comparing entities of this typeEntityDefinition.Builder
conditionProvider(ConditionType conditionType, ConditionProvider conditionProvider)
Adds aConditionProvider
which provides a dynamic query condition string.EntityDefinition.Builder
description(String description)
Specifies a description for this entity.EntityDefinition.Builder
foregroundColorProvider(ColorProvider foregroundColorProvider)
EntityDefinition.Builder
keyGenerator(KeyGenerator keyGenerator)
Sets the primary key generatorEntityDefinition.Builder
optimisticLockingEnabled(boolean optimisticLockingEnabled)
Use this to disable optimistic locking for this entity typeEntityDefinition.Builder
orderBy(OrderBy orderBy)
Sets the order by clause for this entity type.EntityDefinition.Builder
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 typeEntityDefinition.Builder
selectQuery(SelectQuery selectQuery)
Sets the select query to use when selecting entities of this type, use with care.EntityDefinition.Builder
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.EntityDefinition.Builder
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.EntityDefinition.Builder
staticData(boolean staticData)
Specifies whether this entity should be regarded as based on a static dataset, that is, one that rarely changes.EntityDefinition.Builder
stringFactory(Attribute<?> attribute)
Sets the string factory, using the value of the given attribute.EntityDefinition.Builder
stringFactory(Function<Entity,String> stringFactory)
Sets the string factory, that is, the function responsible for creating toString() values for this entity type.EntityDefinition.Builder
tableName(String tableName)
EntityDefinition.Builder
validator(EntityValidator validator)
-
-
-
Method Detail
-
tableName
EntityDefinition.Builder tableName(String tableName)
- Parameters:
tableName
- the table name- Returns:
- this
EntityDefinition.Builder
instance
-
validator
EntityDefinition.Builder validator(EntityValidator validator)
- Parameters:
validator
- the validator for this entity type- Returns:
- this
EntityDefinition.Builder
instance
-
conditionProvider
EntityDefinition.Builder conditionProvider(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
EntityDefinition.Builder backgroundColorProvider(ColorProvider backgroundColorProvider)
- Parameters:
backgroundColorProvider
- the background color provider- Returns:
- this
EntityDefinition.Builder
instance
-
foregroundColorProvider
EntityDefinition.Builder foregroundColorProvider(ColorProvider foregroundColorProvider)
- Parameters:
foregroundColorProvider
- the foreground color provider- Returns:
- this
EntityDefinition.Builder
instance
-
caption
EntityDefinition.Builder caption(String caption)
Sets the caption for this entity type- Parameters:
caption
- the caption- Returns:
- this
EntityDefinition.Builder
instance
-
captionResourceKey
EntityDefinition.Builder captionResourceKey(String 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:
EntityType.resourceBundleName()
-
description
EntityDefinition.Builder description(String description)
Specifies a description for this entity.- Parameters:
description
- the description- Returns:
- this
EntityDefinition.Builder
instance
-
smallDataset
EntityDefinition.Builder 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.- Parameters:
smallDataset
- true if this entity is based on a small dataset- Returns:
- this
EntityDefinition.Builder
instance
-
staticData
EntityDefinition.Builder staticData(boolean staticData)
Specifies whether this entity should be regarded as based on a static dataset, that is, one that rarely changes. This is useful in deciding how often to refresh, say, a combo box based on the entity.- Parameters:
staticData
- true if the underlying data should be regarded as static- Returns:
- this
EntityDefinition.Builder
instance
-
readOnly
EntityDefinition.Builder 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 type- Parameters:
readOnly
- true if this entity is read-only- Returns:
- this
EntityDefinition.Builder
instance
-
optimisticLockingEnabled
EntityDefinition.Builder optimisticLockingEnabled(boolean optimisticLockingEnabled)
Use this to disable optimistic locking for this entity type- Parameters:
optimisticLockingEnabled
- true if optimistic locking should be used during updates, false to disable- Returns:
- this
EntityDefinition.Builder
instance
-
keyGenerator
EntityDefinition.Builder keyGenerator(KeyGenerator keyGenerator)
Sets the primary key generator- Parameters:
keyGenerator
- the primary key generator- Returns:
- this
EntityDefinition.Builder
instance - See Also:
EntityDefinition.isKeyGenerated()
-
orderBy
EntityDefinition.Builder orderBy(OrderBy orderBy)
Sets the order by clause for this entity type.- Parameters:
orderBy
- the order by clause- Returns:
- this
EntityDefinition.Builder
instance
-
selectTableName
EntityDefinition.Builder 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.- Parameters:
selectTableName
- the name of the table- Returns:
- this
EntityDefinition.Builder
instance
-
selectQuery
EntityDefinition.Builder selectQuery(SelectQuery 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 properties 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
EntityDefinition.Builder stringFactory(Attribute<?> attribute)
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
EntityDefinition.Builder stringFactory(Function<Entity,String> 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
EntityDefinition.Builder comparator(Comparator<Entity> comparator)
Sets the comparator to use when comparing entities of this type- Parameters:
comparator
- the comparator- Returns:
- this
EntityDefinition.Builder
instance
-
build
EntityDefinition build()
- Returns:
- a new
EntityDefinition
instance based on this builder
-
-