Package io.jmix.core

Class FetchPlanBuilder

java.lang.Object
io.jmix.core.FetchPlanBuilder

public class FetchPlanBuilder extends Object
Builds FetchPlans.

Use FetchPlans factory to get the builder.

  • Field Details

  • Constructor Details

  • Method Details

    • build

      public FetchPlan build()
      Builds fetch plan and makes builder immutable.
      Subsequent method invocations returns the same object.
      Returns:
      created FetchPlan
    • createFetchPlan

      protected FetchPlan createFetchPlan(Class<?> entityClass, String name, List<FetchPlanProperty> properties, boolean loadPartialEntities)
    • add

      public FetchPlanBuilder add(String property)
      Adds property.
      Parameters:
      property - name of direct property or dot separated path to indirect property. e.g. "address.country.name"
      Throws:
      RuntimeException - if FetchPlan has been already built
    • add

      public FetchPlanBuilder add(String property, Consumer<FetchPlanBuilder> consumer)
      Adds property.
      Parameters:
      property - property name
      consumer - to build property fetchPlan
      Throws:
      RuntimeException - if FetchPlan has been already built
    • add

      public FetchPlanBuilder add(String property, Consumer<FetchPlanBuilder> consumer, FetchMode fetchMode)
      Adds property.
      Parameters:
      property - property name
      consumer - to build property fetchPlan
      fetchMode - fetch mode for property
      Throws:
      RuntimeException - if FetchPlan has been already built
    • add

      public FetchPlanBuilder add(String property, String fetchPlanName)
      Adds property with FetchPlan specified by fetchPlanName.

      For example:

         FetchPlan orderFP = fetchPlans.builder(Order.class)
             .addFetchPlan(FetchPlan.BASE)
             .add("orderLines", FetchPlan.BASE)
             .add("orderLines.product", FetchPlan.BASE)
             .build();
       
      Parameters:
      property - name of immediate property or dot separated property path, e.g. "address.country.name"
      Throws:
      FetchPlanNotFoundException - if specified by fetchPlanName FetchPlan not found for entity determined by property
      RuntimeException - if FetchPlan has been already built
    • add

      public FetchPlanBuilder add(String property, String fetchPlanName, FetchMode fetchMode)
      Adds property with FetchPlan specified by fetchPlanName and a specific fetch mode.

      For example:

           FetchPlan orderFP = fetchPlans.builder(Order.class)
               .addFetchPlan(FetchPlan.BASE)
               .add("orderLines", FetchPlan.BASE, FetchMode.UNDEFINED)
               .add("orderLines.product", FetchPlan.BASE, FetchMode.UNDEFINED)
               .build();
       
      Parameters:
      property - name of immediate property or dot separated property path, e.g. "address.country.name"
      Throws:
      FetchPlanNotFoundException - if specified by fetchPlanName FetchPlan not found for entity determined by property
      RuntimeException - if FetchPlan has been already built
    • add

      public FetchPlanBuilder add(String property, FetchPlanBuilder builder)
      Adds property with FetchPlan specified by builder.
      Parameters:
      property - property name
      Throws:
      RuntimeException - if FetchPlan has been already built
    • add

      public FetchPlanBuilder add(String property, FetchPlanBuilder builder, FetchMode fetchMode)
      Adds property with FetchPlan specified by builder.
      Parameters:
      property - property name
      fetchMode - fetch mode for property
      Throws:
      RuntimeException - if FetchPlan has been already built
    • addAll

      public FetchPlanBuilder addAll(String... properties)
      Adds all listed properties to FetchPlan
      Parameters:
      properties - list of properties determined as for simple add(String) method
      Throws:
      RuntimeException - if FetchPlan has been already built
      See Also:
    • addSystem

      public FetchPlanBuilder addSystem()
      Adds all system properties determined by MetadataTools.getSystemProperties(MetaClass) to FetchPlan
      Throws:
      RuntimeException - if FetchPlan has been already built
    • addSystemProperties

      protected void addSystemProperties()
    • addFetchPlan

      public FetchPlanBuilder addFetchPlan(FetchPlan fetchPlan)
      Adds all properties from specified fetchPlan. Replaces existing nested fetchPlans.
      Throws:
      RuntimeException - if FetchPlan has been already built
    • addFetchPlan

      public FetchPlanBuilder addFetchPlan(String fetchPlanName)
      Adds all properties from specified by fetchPlanName FetchPlan. Replaces existing nested fetchPlans.
      Throws:
      RuntimeException - if FetchPlan has been already built
    • merge

      public FetchPlanBuilder merge(FetchPlan fetchPlan)
      Deep merges fetchPlan into current fetchPlan by adding all properties recursively.
      Throws:
      RuntimeException - if FetchPlan has been already built
    • mergeProperty

      public FetchPlanBuilder mergeProperty(String propName, @Nullable FetchPlan propFetchPlan, @Nullable FetchMode propFetchMode)
      Deep merges fetchPlan into property's fetchPlan by adding all properties recursively.
      Parameters:
      propName - name of property to merge propFetchPlan to
      Throws:
      RuntimeException - if FetchPlan has been already built
    • mergeNestedProperty

      public FetchPlanBuilder mergeNestedProperty(String propertyPath, @Nullable FetchPlan fetchPlan)
      Deep merges fetchPlan into direct or indirect property's fetchPlan by adding all properties recursively.
      Parameters:
      propertyPath - name of direct property or dot separated path to indirect property to merge propFetchPlan to
      Throws:
      RuntimeException - if FetchPlan has been already built
    • partial

      public FetchPlanBuilder partial()
      Throws:
      RuntimeException - if FetchPlan has been already built
    • partial

      public FetchPlanBuilder partial(boolean partial)
      Throws:
      RuntimeException - if FetchPlan has been already built
    • name

      public FetchPlanBuilder name(String name)
      Throws:
      RuntimeException - if FetchPlan has been already built
    • getEntityClass

      public Class<?> getEntityClass()
    • getName

      public String getName()
      Returns:
      FetchPlan.name for fetchPlan under construction
    • isBuilt

      public boolean isBuilt()
      Returns:
      wheser FetchPlan has been already built and builder is not modifiable anymore
    • checkState

      protected void checkState()
      Checks whether FetchPlan has been built. Builder cannot be modified after build() invocation
      Throws:
      RuntimeException - if FetchPlan is already built
    • getMetaPropertyPath

      protected MetaPropertyPath getMetaPropertyPath(String property)
    • getNestedPropertyBuilder

      protected FetchPlanBuilder getNestedPropertyBuilder(FetchPlanBuilder builder, String name)