Class EntityViewCommand
java.lang.Object
com.foreach.across.modules.entity.views.request.EntityViewCommand
Represents an entity view command object. In case of a form view will usually hold the DTO of the
entity being created or updated. Additionally extension objects can be registered that
will be bound and validated as well.
Apart from the extension data itself, a list of custom validators for that extension can be added.
This is the central object exchanged between the view and allows for form-binding.
- Since:
- 2.0.0
- Author:
- Arne Vandamme
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addExtension
(String name, Object extension) Add an extension object under the given key.void
addExtensionValidator
(String extensionName, org.springframework.validation.Validator... validators) Add one or more custom validators for an extension.void
addExtensionWithValidator
(String extensionName, Object extension, org.springframework.validation.Validator... validators) Shorthand for adding an extension with custom validators.<V> V
<Y> Y
getExtension
(String extensionName) Return the extension with the given name and coerce it to the expected type.<Y> Y
getExtension
(String extensionName, Class<Y> extensionType) Return the extension with the given name and coerce it to the expected type.Collection<org.springframework.validation.Validator>
getExtensionValidators
(String extensionName) Get the collections of additionalValidator
instances that should be applied when validating the extension data.A binder object for custom property binding throughEntityPropertyController
.boolean
hasExtension
(String extensionName) Check if an extension was registered under the given name.boolean
void
removeExtension
(String extensionName) Remove the extension with that name.void
void
setProperties
(EntityPropertiesBinder properties) A binder object for custom property binding throughEntityPropertyController
.
-
Constructor Details
-
EntityViewCommand
public EntityViewCommand()
-
-
Method Details
-
setEntity
-
getEntity
- Returns:
- The entity (dto) instance for the command.
-
getEntity
- Returns:
- the entity cast as type
-
getExtensions
- Returns:
- Map of possible command extensions that have been registered.
-
addExtensionWithValidator
public void addExtensionWithValidator(String extensionName, Object extension, org.springframework.validation.Validator... validators) Shorthand for adding an extension with custom validators.- Parameters:
extensionName
- name of the extensionextension
- objectvalidators
- for the extension
-
addExtension
Add an extension object under the given key. Will replace any previously registered extension.- Parameters:
name
- of the extension objectextension
- object - data binding will also happen on this extension as well as validation if default binding occurs
-
addExtensionValidator
public void addExtensionValidator(String extensionName, org.springframework.validation.Validator... validators) Add one or more custom validators for an extension.- Parameters:
extensionName
- name of the extensionvalidators
- to add
-
getExtension
Return the extension with the given name and coerce it to the expected type.- Type Parameters:
Y
- type of the extension object- Parameters:
extensionName
- name of the extension- Returns:
- extension value
-
getExtension
Return the extension with the given name and coerce it to the expected type.- Type Parameters:
Y
- type of the extension object- Parameters:
extensionName
- name of the extensionextensionType
- type of the extension object- Returns:
- extension value
-
getExtensionValidators
public Collection<org.springframework.validation.Validator> getExtensionValidators(String extensionName) Get the collections of additionalValidator
instances that should be applied when validating the extension data.- Parameters:
extensionName
- name of the extension- Returns:
- collection of validators
-
holdsEntity
public boolean holdsEntity()- Returns:
true
if an entity is set on this command
-
hasExtension
Check if an extension was registered under the given name. Note that the extension value can benull
.- Parameters:
extensionName
- name of the extension- Returns:
true
if extension was registered
-
removeExtension
Remove the extension with that name. This will also remove the validators for that extension.- Parameters:
extensionName
- name of the extension
-
getProperties
A binder object for custom property binding throughEntityPropertyController
. -
setProperties
A binder object for custom property binding throughEntityPropertyController
.
-