Package io.jmix.core
Class FetchPlanBuilder
java.lang.Object
io.jmix.core.FetchPlanBuilder
Builds
FetchPlans.
Use FetchPlans factory to get the builder.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String,FetchPlanBuilder> protected Class<?>protected FetchPlanRepositoryprotected FetchPlansprotected booleanprotected MetaClassprotected MetadataToolsprotected Stringprotected FetchPlanprotected boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFetchPlanBuilder(FetchPlans fetchPlans, Metadata metadata, MetadataTools metadataTools, FetchPlanRepository fetchPlanRepository, Class<?> entityClass) -
Method Summary
Modifier and TypeMethodDescriptionAdds property.add(String property, FetchPlanBuilder builder) Adds property with FetchPlan specified bybuilder.add(String property, FetchPlanBuilder builder, FetchMode fetchMode) Adds property with FetchPlan specified bybuilder.Adds property with FetchPlan specified byfetchPlanName.Adds property with FetchPlan specified byfetchPlanNameand a specific fetch mode.add(String property, Consumer<FetchPlanBuilder> consumer) Adds property.add(String property, Consumer<FetchPlanBuilder> consumer, FetchMode fetchMode) Adds property.Adds all listed properties to FetchPlanaddFetchPlan(FetchPlan fetchPlan) Adds all properties from specifiedfetchPlan.addFetchPlan(String fetchPlanName) Adds all properties from specified byfetchPlanNameFetchPlan.Adds all system properties determined byMetadataTools.getSystemProperties(MetaClass)to FetchPlanprotected voidbuild()Builds fetch plan and makes builder immutable.
Subsequent method invocations returns the same object.protected voidChecks whetherFetchPlanhas been built.protected FetchPlancreateFetchPlan(Class<?> entityClass, String name, List<FetchPlanProperty> properties, boolean loadPartialEntities) Class<?>protected MetaPropertyPathgetMetaPropertyPath(String property) getName()protected FetchPlanBuildergetNestedPropertyBuilder(FetchPlanBuilder builder, String name) booleanisBuilt()Deep mergesfetchPlaninto current fetchPlan by adding all properties recursively.mergeNestedProperty(String propertyPath, FetchPlan fetchPlan) Deep mergesfetchPlaninto direct or indirect property's fetchPlan by adding all properties recursively.mergeProperty(String propName, FetchPlan propFetchPlan, FetchMode propFetchMode) Deep mergesfetchPlaninto property's fetchPlan by adding all properties recursively.SetsFetchPlan.namepartial()SetsFetchPlan.loadPartialEntities()to truepartial(boolean partial) SpecifiesFetchPlan.loadPartialEntities()
-
Field Details
-
fetchPlans
-
metadataTools
-
fetchPlanRepository
-
entityClass
-
metaClass
-
properties
-
builders
-
propertiesToFetchPlans
-
fetchModes
-
systemProperties
protected boolean systemProperties -
loadPartialEntities
protected boolean loadPartialEntities -
name
-
result
-
-
Constructor Details
-
FetchPlanBuilder
protected FetchPlanBuilder(FetchPlans fetchPlans, Metadata metadata, MetadataTools metadataTools, FetchPlanRepository fetchPlanRepository, Class<?> entityClass)
-
-
Method Details
-
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
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
Adds property.- Parameters:
property- property nameconsumer- 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 nameconsumer- to build property fetchPlanfetchMode- fetch mode for property- Throws:
RuntimeException- if FetchPlan has been already built
-
add
Adds property with FetchPlan specified byfetchPlanName.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 byfetchPlanNameFetchPlan not found for entity determined bypropertyRuntimeException- if FetchPlan has been already built
-
add
Adds property with FetchPlan specified byfetchPlanNameand 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 byfetchPlanNameFetchPlan not found for entity determined bypropertyRuntimeException- if FetchPlan has been already built
-
add
Adds property with FetchPlan specified bybuilder.- Parameters:
property- property name- Throws:
RuntimeException- if FetchPlan has been already built
-
add
Adds property with FetchPlan specified bybuilder.- Parameters:
property- property namefetchMode- fetch mode for property- Throws:
RuntimeException- if FetchPlan has been already built
-
addAll
Adds all listed properties to FetchPlan- Parameters:
properties- list of properties determined as for simpleadd(String)method- Throws:
RuntimeException- if FetchPlan has been already built- See Also:
-
addSystem
Adds all system properties determined byMetadataTools.getSystemProperties(MetaClass)to FetchPlan- Throws:
RuntimeException- if FetchPlan has been already built
-
addSystemProperties
protected void addSystemProperties() -
addFetchPlan
Adds all properties from specifiedfetchPlan. Replaces existing nested fetchPlans.- Throws:
RuntimeException- if FetchPlan has been already built
-
addFetchPlan
Adds all properties from specified byfetchPlanNameFetchPlan. Replaces existing nested fetchPlans.- Throws:
RuntimeException- if FetchPlan has been already built
-
merge
Deep mergesfetchPlaninto 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 mergesfetchPlaninto property's fetchPlan by adding all properties recursively.- Parameters:
propName- name of property to mergepropFetchPlanto- Throws:
RuntimeException- if FetchPlan has been already built
-
mergeNestedProperty
Deep mergesfetchPlaninto 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 mergepropFetchPlanto- Throws:
RuntimeException- if FetchPlan has been already built
-
partial
SetsFetchPlan.loadPartialEntities()to true- Throws:
RuntimeException- if FetchPlan has been already built
-
partial
SpecifiesFetchPlan.loadPartialEntities()- Throws:
RuntimeException- if FetchPlan has been already built
-
name
SetsFetchPlan.name- Throws:
RuntimeException- if FetchPlan has been already built
-
getEntityClass
-
getName
- Returns:
FetchPlan.namefor fetchPlan under construction
-
isBuilt
public boolean isBuilt()- Returns:
- wheser
FetchPlanhas been already built and builder is not modifiable anymore
-
checkState
protected void checkState()- Throws:
RuntimeException- if FetchPlan is already built
-
getMetaPropertyPath
-
getNestedPropertyBuilder
-