Package com.blazebit.persistence.view
Class EntityViewSetting<T,Q extends FullQueryBuilder<T,Q>>
java.lang.Object
com.blazebit.persistence.view.EntityViewSetting<T,Q>
- Type Parameters:
T
- The type of the entity viewQ
- PaginatedCriteriaBuilder if paginated, CriteriaBuilder otherwise
- All Implemented Interfaces:
SubGraph<T>
public final class EntityViewSetting<T,Q extends FullQueryBuilder<T,Q>>
extends Object
implements SubGraph<T>
A EntityViewSetting is a set of filters and sorters that can be
applied to a
CriteriaBuilder
. Filters and sorters are added for
entity view attribute names. It also supports pagination and optional
parameters. Optional parameters are only set on a criteria builder if they
are needed but not satisfied.- Since:
- 1.0.0
- Author:
- Christian Beikov, Moritz Becker
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The activation of a filter. -
Method Summary
Modifier and TypeMethodDescription<FilterValue>
voidaddAttributeFilter
(AttributeFilterMapping<T, FilterValue> attributeFilter, FilterValue filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.<FilterValue>
voidaddAttributeFilter
(AttributeFilterMappingPath<T, FilterValue> attributeFilter, FilterValue filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.void
addAttributeFilter
(String attributeName, Object filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.void
addAttributeFilter
(String attributeName, String filterName, Object filterValue) Adds the attribute's attribute filter with the given name to the attribute filters of this setting or overwrites the filter value of an existing attribute filter with the same attribute name and filter name.void
addAttributeFilters
(Map<String, Object> attributeFilters) Adds the given attribute filters to the attribute filters of this setting.void
addAttributeSorter
(AttributePath<T, ?, ?> attributePath, Sorter sorter) Adds the given attribute sorter to the attribute sorters of this setting.void
addAttributeSorter
(MethodAttribute<T, ?> attribute, Sorter sorter) Adds the given attribute sorter to the attribute sorters of this setting.void
addAttributeSorter
(String attributeName, Sorter sorter) Adds the given attribute sorter to the attribute sorters of this setting.void
addAttributeSorters
(Map<String, Sorter> attributeSorters) Adds the given attribute sorters to the attribute sorters of this setting.void
addOptionalParameter
(String parameterName, Object value) Adds the given optional parameter to the optional parameters of this setting.void
addOptionalParameters
(Map<String, Object> optionalParameters) Adds the given optional parameters to the optional parameters of this setting.void
addViewFilter
(String filterName) Enables and adds the view filter with the given name in this setting.static <T> EntityViewSetting<T,
CriteriaBuilder<T>> Likecreate(java.lang.Class, java.lang.String)
but with theviewConstructorName
set to null.static <T> EntityViewSetting<T,
PaginatedCriteriaBuilder<T>> Likecreate(java.lang.Class, int, int, java.lang.String)
but with theviewConstructorName
set to null.static <T> EntityViewSetting<T,
PaginatedCriteriaBuilder<T>> Creates a new EntityViewSetting that can be applied on criteria builders.static <T> EntityViewSetting<T,
PaginatedCriteriaBuilder<T>> Likecreate(java.lang.Class, java.lang.Object, int, java.lang.String)
but with theviewConstructorName
set to null.static <T> EntityViewSetting<T,
PaginatedCriteriaBuilder<T>> Creates a new EntityViewSetting that can be applied on criteria builders.static <T> EntityViewSetting<T,
CriteriaBuilder<T>> Creates a new EntityViewSetting that can be applied on criteria builders.<X> SubGraph<X>
fetch
(MethodPluralAttribute<T, ?, X> attribute) Adds a fetch for the given attribute and returns theSubGraph
for it.<X> SubGraph<X>
fetch
(MethodSingularAttribute<T, X> attribute) Adds a fetch for the given attribute and returns theSubGraph
for it.<X> SubGraph<X>
Adds a fetch for the given path and returns theSubGraph
for it.<X extends T,
Y extends FullQueryBuilder<X, Y>>
EntityViewSetting<X,Y> forSubtype
(Class<X> subtype) Creates a copy ofthis
EntityViewSetting for the given entity view subtype.Returns a copy of the attribute filters that have been added.Returns a copy of the attribute filters that have been added.Returns a copy of the attribute sorters that have been added.The id of the entity which should be located on the page returned result.Returns the entity view class.Returns the attributes that should be fetched or an empty collection if all should be fetched.int
The first result that the criteria builder should return.Returns the key set of this setting.int
The maximum number of results that the criteria builder should return.Returns a copy of the optional parameters that have been added.Get the properties and hints and associated values that are in effect for the entity view setting.Returns the entity view constructor name.Returns a copy of the named filters for the view that have been added.boolean
Returns true if filters have been added, otherwise false.boolean
Returns true if sorters have been added, otherwise false.boolean
Returns true if optional parameters have been added, otherwise false.boolean
Returns true if named filters for the view have been added, otherwise false.boolean
Returns true if this setting is key set paginated.boolean
Returns true if this entiy view setting applies pagination, false otherwise.void
setProperty
(String propertyName, Object value) Set a entity view property or hint.<FilterValue>
EntityViewSetting<T,Q> withAttributeFilter
(AttributeFilterMapping<T, FilterValue> attributeFilter, FilterValue filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.<FilterValue>
EntityViewSetting<T,Q> withAttributeFilter
(AttributeFilterMappingPath<T, FilterValue> attributeFilter, FilterValue filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.withAttributeFilter
(String attributeName, Object filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.withAttributeFilter
(String attributeName, String filterName, Object filterValue) Adds the attribute's attribute filter with the given name to the attribute filters of this setting or overwrites the filter value of an existing attribute filter with the same attribute name and filter name.withAttributeSorter
(AttributePath<T, ?, ?> attributePath, Sorter sorter) Adds the given attribute sorter to the attribute sorters of this setting.withAttributeSorter
(MethodAttribute<T, ?> attribute, Sorter sorter) Adds the given attribute sorter to the attribute sorters of this setting.withAttributeSorter
(String attributeName, Sorter sorter) Adds the given attribute sorter to the attribute sorters of this setting.withKeysetPage
(KeysetPage keysetPage) Sets the key set of this setting.withOptionalParameter
(String parameterName, Object value) Adds the given optional parameter to the optional parameters of this setting.withProperty
(String propertyName, Object value) Set a entity view property or hint.withViewFilter
(String filterName) Enables and adds the view filter with the given name in this setting.
-
Method Details
-
create
Likecreate(java.lang.Class, java.lang.String)
but with theviewConstructorName
set to null.- Type Parameters:
T
- The type of the entity view- Parameters:
entityViewClass
- The entity view class that should be used for the object builder- Returns:
- A new entity view setting
-
create
public static <T> EntityViewSetting<T,CriteriaBuilder<T>> create(Class<T> entityViewClass, String viewConstructorName) Creates a new EntityViewSetting that can be applied on criteria builders.- Type Parameters:
T
- The type of the entity view- Parameters:
entityViewClass
- The entity view class that should be used for the object builderviewConstructorName
- The name of the view constructor- Returns:
- A new entity view setting
-
create
public static <T> EntityViewSetting<T,PaginatedCriteriaBuilder<T>> create(Class<T> entityViewClass, int firstResult, int maxResults) Likecreate(java.lang.Class, int, int, java.lang.String)
but with theviewConstructorName
set to null.- Type Parameters:
T
- The type of the entity view- Parameters:
entityViewClass
- The entity view class that should be used for the object builderfirstResult
- The position of the first result to retrieve, numbered from 0maxResults
- The maximum number of results to retrieve- Returns:
- A new entity view setting
-
create
public static <T> EntityViewSetting<T,PaginatedCriteriaBuilder<T>> create(Class<T> entityViewClass, Object entityId, int maxResults) Likecreate(java.lang.Class, java.lang.Object, int, java.lang.String)
but with theviewConstructorName
set to null.- Type Parameters:
T
- The type of the entity view- Parameters:
entityViewClass
- The entity view class that should be used for the object builderentityId
- The id of the entity which should be located on a pagemaxResults
- The maximum number of results to retrieve- Returns:
- A new entity view setting
-
create
public static <T> EntityViewSetting<T,PaginatedCriteriaBuilder<T>> create(Class<T> entityViewClass, int firstResult, int maxResults, String viewConstructorName) Creates a new EntityViewSetting that can be applied on criteria builders.- Type Parameters:
T
- The type of the entity view- Parameters:
entityViewClass
- The entity view class that should be used for the object builderfirstResult
- The position of the first result to retrieve, numbered from 0maxResults
- The maximum number of results to retrieveviewConstructorName
- The name of the view constructor- Returns:
- A new entity view setting
-
create
public static <T> EntityViewSetting<T,PaginatedCriteriaBuilder<T>> create(Class<T> entityViewClass, Object entityId, int maxResults, String viewConstructorName) Creates a new EntityViewSetting that can be applied on criteria builders.- Type Parameters:
T
- The type of the entity view- Parameters:
entityViewClass
- The entity view class that should be used for the object builderentityId
- The id of the entity which should be located on a pagemaxResults
- The maximum number of results to retrieveviewConstructorName
- The name of the view constructor- Returns:
- A new entity view setting
-
forSubtype
public <X extends T,Y extends FullQueryBuilder<X, EntityViewSetting<X,Y>> Y> forSubtype(Class<X> subtype) Creates a copy ofthis
EntityViewSetting for the given entity view subtype.- Type Parameters:
X
- Entity view subtypeY
- The query builder type- Parameters:
subtype
- The entity view subtype- Returns:
- A copy for the given subtype
-
getEntityViewClass
Returns the entity view class.- Returns:
- The entity view class
-
getViewConstructorName
Returns the entity view constructor name.- Returns:
- The entity view constructor name
-
getEntityId
The id of the entity which should be located on the page returned result. Returnsnull
if no pagination or a absolute first result will be applied.- Returns:
- The id of the entity which should be located on a page
- See Also:
-
getFirstResult
public int getFirstResult()The first result that the criteria builder should return. Returns 0 if no pagination will be applied. Returns -1 if an entity id was supplied.- Returns:
- The first result
- See Also:
-
getMaxResults
public int getMaxResults()The maximum number of results that the criteria builder should return. Returns Integer.MAX_VALUE if no pagination will be applied.- Returns:
- The maximum number of results
- See Also:
-
isPaginated
public boolean isPaginated()Returns true if this entiy view setting applies pagination, false otherwise.- Returns:
- True if this entiy view setting applies pagination, false otherwise
-
getKeysetPage
Returns the key set of this setting.- Returns:
- The key set of this setting
-
withKeysetPage
Sets the key set of this setting.- Parameters:
keysetPage
- the new key set- Returns:
- this setting for chaining
-
isKeysetPaginated
public boolean isKeysetPaginated()Returns true if this setting is key set paginated.- Returns:
- true if this setting is key set paginated
-
addAttributeSorters
Adds the given attribute sorters to the attribute sorters of this setting. Note that the attribute sorter order is retained.- Parameters:
attributeSorters
- The attribute sorters to add
-
addAttributeSorter
Adds the given attribute sorter to the attribute sorters of this setting. Note that the attribute sorter order is retained.- Parameters:
attributeName
- The name of the attribute sortersorter
- The sorter for the attribute sorter
-
withAttributeSorter
Adds the given attribute sorter to the attribute sorters of this setting. Note that the attribute sorter order is retained.- Parameters:
attributeName
- The name of the attribute sortersorter
- The sorter for the attribute sorter- Returns:
this
for method chaining- Since:
- 1.3.0
-
addAttributeSorter
Adds the given attribute sorter to the attribute sorters of this setting. Note that the attribute sorter order is retained.- Parameters:
attribute
- The attribute for the attribute sortersorter
- The sorter for the attribute sorter- Since:
- 1.5.0
-
withAttributeSorter
Adds the given attribute sorter to the attribute sorters of this setting. Note that the attribute sorter order is retained.- Parameters:
attribute
- The attribute for the attribute sortersorter
- The sorter for the attribute sorter- Returns:
this
for method chaining- Since:
- 1.5.0
-
addAttributeSorter
Adds the given attribute sorter to the attribute sorters of this setting. Note that the attribute sorter order is retained.- Parameters:
attributePath
- The attribute path for the attribute sortersorter
- The sorter for the attribute sorter- Since:
- 1.5.0
-
withAttributeSorter
public EntityViewSetting<T,Q> withAttributeSorter(AttributePath<T, ?, ?> attributePath, Sorter sorter) Adds the given attribute sorter to the attribute sorters of this setting. Note that the attribute sorter order is retained.- Parameters:
attributePath
- The attribute path for the attribute sortersorter
- The sorter for the attribute sorter- Returns:
this
for method chaining- Since:
- 1.5.0
-
hasAttributeSorters
public boolean hasAttributeSorters()Returns true if sorters have been added, otherwise false.- Returns:
- true if sorters have been added, otherwise false
-
getAttributeSorters
Returns a copy of the attribute sorters that have been added.- Returns:
- The attribute sorters
-
addAttributeFilters
Adds the given attribute filters to the attribute filters of this setting.- Parameters:
attributeFilters
- The attribute filters to add
-
addAttributeFilter
Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.- Parameters:
attributeName
- The name of the attribute filterfilterValue
- The filter value for the attribute filter
-
withAttributeFilter
Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.- Parameters:
attributeName
- The name of the attribute filterfilterValue
- The filter value for the attribute filter- Returns:
this
for method chaining- Since:
- 1.3.0
-
addAttributeFilter
Adds the attribute's attribute filter with the given name to the attribute filters of this setting or overwrites the filter value of an existing attribute filter with the same attribute name and filter name.- Parameters:
attributeName
- The attribute namefilterName
- The filter namefilterValue
- The filter value for the attribute filter
-
withAttributeFilter
public EntityViewSetting<T,Q> withAttributeFilter(String attributeName, String filterName, Object filterValue) Adds the attribute's attribute filter with the given name to the attribute filters of this setting or overwrites the filter value of an existing attribute filter with the same attribute name and filter name.- Parameters:
attributeName
- The attribute namefilterName
- The filter namefilterValue
- The filter value for the attribute filter- Returns:
this
for method chaining- Since:
- 1.3.0
-
addAttributeFilter
public <FilterValue> void addAttributeFilter(AttributeFilterMapping<T, FilterValue> attributeFilter, FilterValue filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.- Type Parameters:
FilterValue
- The filter value type- Parameters:
attributeFilter
- The attribute filterfilterValue
- The filter value for the attribute filter- Since:
- 1.5.0
-
withAttributeFilter
public <FilterValue> EntityViewSetting<T,Q> withAttributeFilter(AttributeFilterMapping<T, FilterValue> attributeFilter, FilterValue filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.- Type Parameters:
FilterValue
- The filter value type- Parameters:
attributeFilter
- The attribute filterfilterValue
- The filter value for the attribute filter- Returns:
this
for method chaining- Since:
- 1.5.0
-
addAttributeFilter
public <FilterValue> void addAttributeFilter(AttributeFilterMappingPath<T, FilterValue> attributeFilter, FilterValue filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.- Type Parameters:
FilterValue
- The filter value type- Parameters:
attributeFilter
- The attribute filter mapping pathfilterValue
- The filter value for the attribute filter- Since:
- 1.5.0
-
withAttributeFilter
public <FilterValue> EntityViewSetting<T,Q> withAttributeFilter(AttributeFilterMappingPath<T, FilterValue> attributeFilter, FilterValue filterValue) Adds the attribute's default attribute filter to the attribute filters of this setting or overwrites the filter value of an existing default attribute filter.- Type Parameters:
FilterValue
- The filter value type- Parameters:
attributeFilter
- The attribute filter mapping pathfilterValue
- The filter value for the attribute filter- Returns:
this
for method chaining- Since:
- 1.5.0
-
hasAttributeFilters
public boolean hasAttributeFilters()Returns true if filters have been added, otherwise false.- Returns:
- true if filters have been added, otherwise false
-
getAttributeFilters
Returns a copy of the attribute filters that have been added.- Returns:
- The attribute filters
-
getAttributeFilterActivations
public Map<String,List<EntityViewSetting.AttributeFilterActivation>> getAttributeFilterActivations()Returns a copy of the attribute filters that have been added.- Returns:
- The attribute filters
- Since:
- 1.5.0
-
addViewFilter
Enables and adds the view filter with the given name in this setting.- Parameters:
filterName
- The name of the view filter
-
withViewFilter
Enables and adds the view filter with the given name in this setting.- Parameters:
filterName
- The name of the view filter- Returns:
this
for method chaining- Since:
- 1.3.0
-
hasViewFilters
public boolean hasViewFilters()Returns true if named filters for the view have been added, otherwise false.- Returns:
- true if named filters for the view have been added, otherwise false
-
getViewFilters
Returns a copy of the named filters for the view that have been added.- Returns:
- The named filters for the view
-
addOptionalParameters
Adds the given optional parameters to the optional parameters of this setting.- Parameters:
optionalParameters
- The optional parameters to add
-
addOptionalParameter
Adds the given optional parameter to the optional parameters of this setting.- Parameters:
parameterName
- The name of the optional parametervalue
- The value of the optional parameter
-
withOptionalParameter
Adds the given optional parameter to the optional parameters of this setting.- Parameters:
parameterName
- The name of the optional parametervalue
- The value of the optional parameter- Returns:
this
for method chaining- Since:
- 1.3.0
-
hasOptionalParameters
public boolean hasOptionalParameters()Returns true if optional parameters have been added, otherwise false.- Returns:
- true if optional parameters have been added, otherwise false
-
getOptionalParameters
Returns a copy of the optional parameters that have been added.- Returns:
- The optional parameters
-
setProperty
Set a entity view property or hint. If a property or hint is not recognized, it is silently ignored.- Parameters:
propertyName
- name of property or hintvalue
- value for property or hint- Since:
- 1.2.0
-
withProperty
Set a entity view property or hint. If a property or hint is not recognized, it is silently ignored.- Parameters:
propertyName
- name of property or hintvalue
- value for property or hint- Returns:
this
for method chaining- Since:
- 1.3.0
-
getProperties
Get the properties and hints and associated values that are in effect for the entity view setting.- Returns:
- map of properties and hints in effect for entity view setting
- Since:
- 1.2.0
-
fetch
Description copied from interface:SubGraph
Adds a fetch for the given path and returns theSubGraph
for it. Careful, calling this method will cause that only the attribute paths that are added and reachable object ids will be fetched. Other attributes will be fetched with their default value. -
fetch
Description copied from interface:SubGraph
Adds a fetch for the given attribute and returns theSubGraph
for it. Careful, calling this method will cause that only the attribute paths that are added and reachable object ids will be fetched. Other attributes will be fetched with their default value. -
fetch
Description copied from interface:SubGraph
Adds a fetch for the given attribute and returns theSubGraph
for it. Careful, calling this method will cause that only the attribute paths that are added and reachable object ids will be fetched. Other attributes will be fetched with their default value. -
getFetches
Returns the attributes that should be fetched or an empty collection if all should be fetched.- Returns:
- the attributes that should be fetched or an empty collection if all should be fetched
- Since:
- 1.4.0
-