Interface EntityDefinition.Builder
- Enclosing interface:
EntityDefinition
A client connecting to a server fetches the entity definitions from it, serialized, an RMI client always
and an HTTP client unless given its domain. What a definition is given must therefore be serializable
in a domain served that way: its validator, comparator,
exists predicate and formatter, and the
comparators of its attributes. A class implements
Serializable and a lambda expression is cast to a serializable type,
(Comparator<Entity> & Serializable) (entity1, entity2) -> .... Otherwise no client can connect,
the server logging a warning for such a domain when it starts. A domain no client fetches needs none of this.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceSpecifies the attributes to base an entity on. -
Method Summary
Modifier and TypeMethodDescriptionbuild()cacheToString(boolean cacheToString) Default true.Sets the caption for this entity type.captionResource(String captionResource) 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.descriptionResource(String descriptionResource) 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.formatter(EntityFormatter formatter) Sets the formatter, that is, the function responsible for creating toString() values for this entity type.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) Must be serializable where clients fetch the entity definitions from a server, seeEntityDefinition.Builder.
-
Method Details
-
table
- Parameters:
table- the table name- Returns:
- this
EntityDefinition.Builderinstance
-
validator
Must be serializable where clients fetch the entity definitions from a server, see
EntityDefinition.Builder.- 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. A caption specified via this method takes precedence over any caption available from the entity resource bundle, and is mutually exclusive withcaptionResource(String).- Parameters:
caption- the caption- Returns:
- this
EntityDefinition.Builderinstance - Throws:
IllegalStateException- in case a caption resource key has already been specified viacaptionResource(String)- See Also:
-
captionResource
Specifies the resource bundle key associated with the caption. Defaults toentityType.name(). Mutually exclusive withcaption(String).- Parameters:
captionResource- the name of the resource bundle key associated with the caption for this entity- Returns:
- this
EntityDefinition.Builderinstance - Throws:
IllegalStateException- in case the caption has already been set viacaption(String)- See Also:
-
descriptionResource
Specifies the resource bundle key associated with the description. Defaults toentityType.name() + ".description"- Parameters:
descriptionResource- 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:builder.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.Must be serializable where clients fetch the entity definitions from a server, see
EntityDefinition.Builder. A lambda expression given in place is, being taken as anEntityFormatter.- Parameters:
formatter- the formatter- Returns:
- this
EntityDefinition.Builderinstance - See Also:
-
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 typeMust be serializable where clients fetch the entity definitions from a server, see
EntityDefinition.Builder.- 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.Must be serializable where clients fetch the entity definitions from a server, see
EntityDefinition.Builder.- Parameters:
exists- the entity exists predicate- Returns:
- this
EntityDefinition.Builderinstance
-
build
EntityDefinition build()- Returns:
- a new
EntityDefinitioninstance based on this builder
-