Package io.jmix.core
Class FetchPlanBuilder
java.lang.Object
io.jmix.core.FetchPlanBuilder
Builds
FetchPlan
s.
Use FetchPlans
factory to get the builder.
-
Field Summary
Modifier and TypeFieldDescriptionprotected Map<String,
FetchPlanBuilder> protected Class<?>
protected FetchPlanRepository
protected FetchPlans
protected boolean
protected MetaClass
protected MetadataTools
protected String
protected FetchPlan
protected boolean
-
Constructor Summary
ModifierConstructorDescriptionprotected
FetchPlanBuilder
(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 byfetchPlanName
and 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 byfetchPlanName
FetchPlan.Adds all system properties determined byMetadataTools.getSystemProperties(MetaClass)
to FetchPlanprotected void
build()
Builds fetch plan and makes builder immutable.
Subsequent method invocations returns the same object.protected void
Checks whetherFetchPlan
has been built.protected FetchPlan
createFetchPlan
(Class<?> entityClass, String name, List<FetchPlanProperty> properties, boolean loadPartialEntities) Class<?>
protected MetaPropertyPath
getMetaPropertyPath
(String property) getName()
protected FetchPlanBuilder
getNestedPropertyBuilder
(FetchPlanBuilder builder, String name) boolean
isBuilt()
Deep mergesfetchPlan
into current fetchPlan by adding all properties recursively.mergeNestedProperty
(String propertyPath, FetchPlan fetchPlan) Deep mergesfetchPlan
into direct or indirect property's fetchPlan by adding all properties recursively.mergeProperty
(String propName, FetchPlan propFetchPlan, FetchMode propFetchMode) Deep mergesfetchPlan
into property's fetchPlan by adding all properties recursively.SetsFetchPlan.name
partial()
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 byfetchPlanName
FetchPlan not found for entity determined byproperty
RuntimeException
- if FetchPlan has been already built
-
add
Adds property with FetchPlan specified byfetchPlanName
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 byfetchPlanName
FetchPlan not found for entity determined byproperty
RuntimeException
- 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 byfetchPlanName
FetchPlan. Replaces existing nested fetchPlans.- Throws:
RuntimeException
- if FetchPlan has been already built
-
merge
Deep mergesfetchPlan
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 mergesfetchPlan
into property's fetchPlan by adding all properties recursively.- Parameters:
propName
- name of property to mergepropFetchPlan
to- Throws:
RuntimeException
- if FetchPlan has been already built
-
mergeNestedProperty
Deep mergesfetchPlan
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 mergepropFetchPlan
to- 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.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()- Throws:
RuntimeException
- if FetchPlan is already built
-
getMetaPropertyPath
-
getNestedPropertyBuilder
-