Skip to content

EntityType operation

stemey edited this page Oct 20, 2012 · 1 revision

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):

  1. 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);
    
  2. include relevant attributes in the type
    The operation is not applied to all attributes in a type

    viewBuilder.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");
    
  3. 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");
    
  4. include super and sub types

    The handling of sub and super types is not possible yet.

  5. create the operation
    The Operation is created and can now be applied:

     View view = viewBuilder.create();
    
  6. apply the operation
    The operation can be applied many times and is usually threadsafe:

     view.visit(visitor, ctx);
    

Clone this wiki locally