-
Notifications
You must be signed in to change notification settings - Fork 0
EntityType operation
Most utilities that operate on a single type and instance use a common infrastructure. The usage of the utilities follow the following steps (View as an example):
-
create a builder for a type The operation is applied to instances of a type (EntityA):
EntityType<EntityA> entityType = entityTypeRepository.getEntityType(EntityA.class); ViewBuilder viewBuilder = viewBuilderFactory.create(entityType); -
include relevant attributes in the type
The operation is not applied to all attributes in a typeviewBuilder.include("relevantProperty");Instead of specifying each attribute individually one can also include allprimitives and then remove the once that shold not be included:
viewBuilder.includePrimitives(false); viewBuilder.remove("excludedProperty"); -
cascade the operation to associated types
If the target type of an attribute is not primitive then it is usually necessary to define the relevant attributes in the target type:ViewBuilder subViewBuilder = viewBuilder.include("list").cascade(); subViewBuilder.include("integer"); -
include super and sub types
The handling of sub and super types is not possible yet.
-
create the operation
The Operation is created and can now be applied:View view = viewBuilder.create(); -
apply the operation
The operation can be applied many times and is usually threadsafe:view.visit(visitor, ctx);