Class EntityConfigurationBuilder<T>
java.lang.Object
com.foreach.across.modules.entity.config.builders.AbstractWritableAttributesBuilder<T>
com.foreach.across.modules.entity.config.builders.AbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
com.foreach.across.modules.entity.config.builders.EntityConfigurationBuilder<T>
@Component
@Scope("prototype")
public class EntityConfigurationBuilder<T>
extends AbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Author:
- Arne Vandamme
-
Constructor Summary
ConstructorDescriptionEntityConfigurationBuilder
(org.springframework.beans.factory.config.AutowireCapableBeanFactory beanFactory) -
Method Summary
Modifier and TypeMethodDescriptionallowableActionsBuilder
(@NonNull EntityConfigurationAllowableActionsBuilder allowableActionsBuilder) Configure theEntityConfigurationAllowableActionsBuilder
to be used.and
(@NonNull Consumer<EntityConfigurationBuilder<T>> consumer) Apply an additional consumer to this builder.void
apply
(MutableEntityConfiguration<T> configuration) Apply the builder to the given entity configuration.protected void
applyAttributes
(EntityConfiguration<T> owner, com.foreach.across.core.support.WritableAttributes attributes) <U extends T>
EntityConfigurationBuilder<U>Downcast the current builder as managing anEntityConfiguration
of a specific type.association
(Consumer<EntityAssociationBuilder> consumer) Configure an association builder.attribute
(AttributeRegistrar<EntityConfiguration<T>> attributeRegistrar) Add an attribute registrar for one or more attributes that should be added.Add a custom attribute this builder should add to the entity.Add a custom attribute this builder should add to the entity.build()
Build a newEntityConfigurationImpl
with the settings specified.Configure a default create form view builder for the entity being configured.createFormView
(Consumer<EntityViewFactoryBuilder> consumer) Configure the create form view builder for the entity being configured.Configure the form view builder for the default create and update forms of the entity being configured.protected <U extends EntityViewFactoryBuilder>
UcreateViewFactoryBuilder
(Class<U> builderType) Configure a default delete view builder for the entity being configured.deleteFormView
(Consumer<EntityViewFactoryBuilder> consumer) Configure the default delete form view builder for the entity being configured.Configure a default detail view builder for the entity being configured.detailView
(Consumer<EntityViewFactoryBuilder> consumer) Configure the default detail view builder for the entity being configured.displayName
(String displayName) Set the default display name of the entity configuration in UI implementations.entityModel
(EntityModel<T, Serializable> entityModel) Sets a customEntityModel
for this configuration.entityModel
(Consumer<EntityModelBuilder<T>> entityModelConsumer) Add a consumer to customize theEntityModel
.<U extends T>
EntityConfigurationBuilder<U>entityType
(Class<U> entityType, boolean registerForClass) Set the entity type of the entity configuration.formView
(String viewName, Consumer<EntityViewFactoryBuilder> consumer) Configure the named form view builder for the entity being configured.hidden
(boolean hidden) Should theEntityConfiguration
be hidden from UI implementations.hide()
Ensures the configuration will be labeled as hidden for UI implementations.protected <U extends EntityViewFactoryBuilder>
voidinitializeViewFactoryBuilder
(String viewName, String templateName, U builder) Configure the label property based on another registered property.listView()
Configure a default list view builder for the entity being configured.listView
(String viewName, Consumer<EntityListViewFactoryBuilder> consumer) Returns the named list view builder for the entity being configured.listView
(Consumer<EntityListViewFactoryBuilder> consumer) Configure the default list view builder for the entity being configured.Set the internal name of the entity configuration.postProcessor
(@NonNull Consumer<MutableEntityConfiguration<T>> postProcessor) Add a post processor instance.properties
(@NonNull Consumer<EntityPropertyRegistryBuilder> registryConsumer) Customize the property registry builder.show()
Ensures the configuration will not be labeled as hidden for UI implementations.Configure a default update form view builder for the entity being configured.updateFormView
(Consumer<EntityViewFactoryBuilder> consumer) Configure the default update form view builder for the entity being configured.view
(String viewName, Consumer<EntityViewFactoryBuilder> consumer) Configure the named simple view builder for the entity being configured.viewElementBuilder
(ViewElementMode mode, com.foreach.across.modules.web.ui.ViewElementBuilder viewElementBuilder) Set the defaultViewElementBuilder
properties with this entity as type should use for a particularViewElementMode
.<U extends com.foreach.across.modules.web.ui.ViewElement>
EntityConfigurationBuilder<T>viewElementPostProcessor
(ViewElementMode mode, com.foreach.across.modules.web.ui.ViewElementPostProcessor<U> viewElementPostProcessor) Add aViewElementPostProcessor
to apply to the defaultViewElementBuilder
.viewElementType
(ViewElementMode mode, String viewElementType) Set theViewElement
type of a particularViewElementMode
.Methods inherited from class com.foreach.across.modules.entity.config.builders.AbstractWritableAttributesAndViewsBuilder
applyViews
Methods inherited from class com.foreach.across.modules.entity.config.builders.AbstractWritableAttributesBuilder
getAttributes
-
Constructor Details
-
EntityConfigurationBuilder
@Autowired public EntityConfigurationBuilder(org.springframework.beans.factory.config.AutowireCapableBeanFactory beanFactory)
-
-
Method Details
-
as
Downcast the current builder as managing anEntityConfiguration
of a specific type. Note this can throw class cast exceptions if the types doe not match.- Type Parameters:
U
- subType of the original generic type- Parameters:
subType
- of the original generic type- Returns:
- downcast version of the current builder
-
name
Set the internal name of the entity configuration. Must be unique within a registry. Can only be used along withbuild()
, cannot be modified on an existing configuration.- Parameters:
name
- of the configuration- Returns:
- current builder
-
displayName
Set the default display name of the entity configuration in UI implementations.- Parameters:
displayName
- of the configuration- Returns:
- current builder
-
entityType
public <U extends T> EntityConfigurationBuilder<U> entityType(Class<U> entityType, boolean registerForClass) Set the entity type of the entity configuration. Can only be used along withbuild()
. Cannot be modified on an existing configuration. The registerForClass parameter determines if the property registry of the class should be the main registry in theEntityPropertyRegistryProvider
. If that is the case, nested properties on this type will be resolved against this configuration. If you're expecting to have only one entity configuration using this entity type, then you most likely want to register this configuration for that type it.- Parameters:
entityType
- for the configurationregisterForClass
- true if the property registry should be the main registry for that class- Returns:
- current builder
-
properties
public EntityConfigurationBuilder<T> properties(@NonNull @NonNull Consumer<EntityPropertyRegistryBuilder> registryConsumer) Customize the property registry builder.- Parameters:
registryConsumer
- to customize the registry builder- Returns:
- current builder
-
show
Ensures the configuration will not be labeled as hidden for UI implementations.- Returns:
- current builder
-
hide
Ensures the configuration will be labeled as hidden for UI implementations.- Returns:
- current builder
-
allowableActionsBuilder
public EntityConfigurationBuilder<T> allowableActionsBuilder(@NonNull @NonNull EntityConfigurationAllowableActionsBuilder allowableActionsBuilder) Configure theEntityConfigurationAllowableActionsBuilder
to be used.- Parameters:
allowableActionsBuilder
- instance- Returns:
- current builder
-
label
Configure the label property based on another registered property. This is a shortcut for configuring a properties builder setting the label.- Parameters:
propertyName
- of the registered property to use as a base of the label- Returns:
- current builder
-
entityModel
Sets a customEntityModel
for this configuration.- Parameters:
entityModel
- implementation- Returns:
- current builder
-
entityModel
public EntityConfigurationBuilder<T> entityModel(Consumer<EntityModelBuilder<T>> entityModelConsumer) Add a consumer to customize theEntityModel
.- Returns:
- current builder
-
postProcessor
public EntityConfigurationBuilder<T> postProcessor(@NonNull @NonNull Consumer<MutableEntityConfiguration<T>> postProcessor) Add a post processor instance. The post processor will only be executed after the rest of the builder has been applied. It can be used to modify the configuration directly.- Parameters:
postProcessor
- instance- Returns:
- current builder
-
association
Configure an association builder.- Parameters:
consumer
- to configure the association builder- Returns:
- current builder
-
viewElementType
Set theViewElement
type of a particularViewElementMode
.- Parameters:
mode
- to set the type forviewElementType
- to use- Returns:
- current builder
-
viewElementBuilder
public EntityConfigurationBuilder<T> viewElementBuilder(ViewElementMode mode, com.foreach.across.modules.web.ui.ViewElementBuilder viewElementBuilder) Set the defaultViewElementBuilder
properties with this entity as type should use for a particularViewElementMode
.- Parameters:
mode
- to set the builder forviewElementBuilder
- to use- Returns:
- current builder
-
viewElementPostProcessor
public <U extends com.foreach.across.modules.web.ui.ViewElement> EntityConfigurationBuilder<T> viewElementPostProcessor(ViewElementMode mode, com.foreach.across.modules.web.ui.ViewElementPostProcessor<U> viewElementPostProcessor) Add aViewElementPostProcessor
to apply to the defaultViewElementBuilder
. Note that postprocessor will be ignored if a customViewElementBuilder
was set usingviewElementBuilder(ViewElementMode, ViewElementBuilder)
.- Parameters:
mode
- to add the postprocessor forviewElementPostProcessor
- to add- Returns:
- current builder
-
attribute
Description copied from class:AbstractWritableAttributesBuilder
Add a custom attribute this builder should add to the entity.- Overrides:
attribute
in classAbstractWritableAttributesBuilder<EntityConfiguration<T>>
- Parameters:
name
- Name of the attribute.value
- Value of the attribute.- Returns:
- current builder
-
attribute
Description copied from class:AbstractWritableAttributesBuilder
Add a custom attribute this builder should add to the entity.- Overrides:
attribute
in classAbstractWritableAttributesBuilder<EntityConfiguration<T>>
- Type Parameters:
S
- Class that is both key and value type of the attribute- Parameters:
type
- Type of the attribute.value
- Value of the attribute.- Returns:
- current builder
-
attribute
public EntityConfigurationBuilder<T> attribute(AttributeRegistrar<EntityConfiguration<T>> attributeRegistrar) Description copied from class:AbstractWritableAttributesBuilder
Add an attribute registrar for one or more attributes that should be added. Provides a mechanism to get the owner (eg.EntityConfiguration
...) to be made accessible to the attribute values.- Overrides:
attribute
in classAbstractWritableAttributesBuilder<EntityConfiguration<T>>
- Parameters:
attributeRegistrar
- registrar- Returns:
- current builder
-
listView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure the default list view builder for the entity being configured. A default list view is usually available.- Overrides:
listView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Parameters:
consumer
- for configuring the view builder- Returns:
- current builder
-
listView
public EntityConfigurationBuilder<T> listView(String viewName, Consumer<EntityListViewFactoryBuilder> consumer) Description copied from class:AbstractWritableAttributesAndViewsBuilder
Returns the named list view builder for the entity being configured. If the view is not available, it will be created.- Overrides:
listView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Parameters:
viewName
- name of the viewconsumer
- for configuring the view builder- Returns:
- builder instance
-
createOrUpdateFormView
public EntityConfigurationBuilder<T> createOrUpdateFormView(Consumer<EntityViewFactoryBuilder> consumer) Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure the form view builder for the default create and update forms of the entity being configured. Create and update forms are usually available.- Overrides:
createOrUpdateFormView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Parameters:
consumer
- for configuring the view builder- Returns:
- current builder
-
createFormView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure the create form view builder for the entity being configured. A default create form view is usually available.- Overrides:
createFormView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Parameters:
consumer
- for configuring the view builder- Returns:
- current builder
-
updateFormView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure the default update form view builder for the entity being configured. A default update form view is usually available.- Overrides:
updateFormView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Parameters:
consumer
- for configuring the view builder- Returns:
- current builder
-
deleteFormView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure the default delete form view builder for the entity being configured. A default delete form view is usually available.- Overrides:
deleteFormView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Parameters:
consumer
- for configuring the view builder- Returns:
- current builder
-
detailView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure the default detail view builder for the entity being configured. A default detail view is usually available.- Overrides:
detailView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Parameters:
consumer
- for configuring the view builder- Returns:
- current builder
-
formView
public EntityConfigurationBuilder<T> formView(String viewName, Consumer<EntityViewFactoryBuilder> consumer) Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure the named form view builder for the entity being configured. If the view is not available, it will be created.- Overrides:
formView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Parameters:
viewName
- name of the viewconsumer
- for configuring the view builder- Returns:
- current builder
-
view
public EntityConfigurationBuilder<T> view(String viewName, Consumer<EntityViewFactoryBuilder> consumer) Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure the named simple view builder for the entity being configured. If the view is not available, it will be created.- Overrides:
view
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Parameters:
viewName
- name of the viewconsumer
- for configuring the view builder- Returns:
- current builder
-
listView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure a default list view builder for the entity being configured. Does not customize the builder but ensures the view gets created using the default builder.- Overrides:
listView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Returns:
- current builder
-
createFormView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure a default create form view builder for the entity being configured. Does not customize the builder but ensures the view gets created using the default builder.- Overrides:
createFormView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Returns:
- current builder
-
updateFormView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure a default update form view builder for the entity being configured. Does not customize the builder but ensures the view gets created using the default builder.- Overrides:
updateFormView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Returns:
- current builder
-
deleteFormView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure a default delete view builder for the entity being configured. Does not customize the builder but ensures the view gets created using the default builder.- Overrides:
deleteFormView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Returns:
- current builder
-
detailView
Description copied from class:AbstractWritableAttributesAndViewsBuilder
Configure a default detail view builder for the entity being configured. Does not customize the builder but ensures the view gets created using the default builder.- Overrides:
detailView
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
- Returns:
- current builder
-
and
public EntityConfigurationBuilder<T> and(@NonNull @NonNull Consumer<EntityConfigurationBuilder<T>> consumer) Apply an additional consumer to this builder.- Parameters:
consumer
- to apply- Returns:
- current builder
-
build
Build a newEntityConfigurationImpl
with the settings specified. Allows setting both name and entity type. Will apply the post processors after initial creation.- Returns:
- built configuration
-
apply
Apply the builder to the given entity configuration.- Parameters:
configuration
- to apply the builder to
-
applyAttributes
protected void applyAttributes(EntityConfiguration<T> owner, com.foreach.across.core.support.WritableAttributes attributes) - Overrides:
applyAttributes
in classAbstractWritableAttributesBuilder<EntityConfiguration<T>>
-
createViewFactoryBuilder
- Specified by:
createViewFactoryBuilder
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
-
initializeViewFactoryBuilder
protected <U extends EntityViewFactoryBuilder> void initializeViewFactoryBuilder(String viewName, String templateName, U builder) - Specified by:
initializeViewFactoryBuilder
in classAbstractWritableAttributesAndViewsBuilder<EntityConfiguration<T>>
-