Class Filter
- All Implemented Interfaces:
PropertyMapping
- Author:
- tesarst, poirigui
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Filterby(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, Collection<T> requiredValues) Create a new filter without an original property and a collection right hand side.static <T> Filterby(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, Collection<T> requiredValues, String originalProperty) Create a new filter with a collection right hand side.static <T> Filterby(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, T requiredValue) Create a new filter without an original property.static <T> Filterby(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, T requiredValue, String originalProperty) Create a new filter.static <T> Filterby(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, Subquery requiredValues) static <T> Filterby(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, Subquery requiredValues, String originalProperty) Create a new filter with a subquery right hand side.booleanstatic org.springframework.core.convert.ConversionServiceObtain the conversion service used for parsing values.Alias in the query/criteria space, if applicable.The origin, if known.Property name in the query/criteria space.Class<?> inthashCode()booleanisNegative(Filter f) Check if a filter is negative.static FilterNegate the given filter.static Filterparse(String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, String requiredValue) static Filterparse(String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, String requiredValue, String originalProperty) Parse filter where the right-hand side is a scalar.static Filterparse(String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, Collection<String> requiredValues) static Filterparse(String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, Collection<String> requiredValues, String originalProperty) Parse a filter where the right-hand side is aCollectionof scalar right-hand side to be parsed.Render this with its original property.toString()Render this with itsPropertyMapping.getObjectAlias()andPropertyMapping.getPropertyName().withPropertyName(String newPropertyName, String newOriginalProperty) Create a copy of this filter with a new property name and original property.
-
Method Details
-
getConversionService
public static org.springframework.core.convert.ConversionService getConversionService()Obtain the conversion service used for parsing values. -
by
public static <T> Filter by(@Nullable String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, @Nullable T requiredValue, @Nullable String originalProperty) Create a new filter.If you need to parse the right-hand side, consider using
parse(String, String, Class, Operator, String, String)for a scalar orparse(String, String, Class, Operator, Collection, String)for a collection type.- Parameters:
objectAlias- the alias that refers to the entity subject to the filterpropertyName- the property in the entitypropertyType- the type of the propertyoperator- a valid operator for the property and the requiredValuerequiredValue- a required value, or null to perform a null-check (i.e.objectAlias.propertyName is null)originalProperty- the original property name, or null if not applicable- Throws:
IllegalArgumentException- if the type of the requiredValue does not match the propertyType
-
by
public static <T> Filter by(@Nullable String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, Collection<T> requiredValues, @Nullable String originalProperty) Create a new filter with a collection right hand side. -
by
public static <T> Filter by(@Nullable String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, Subquery requiredValues, @Nullable String originalProperty) Create a new filter with a subquery right hand side. -
by
public static <T> Filter by(@Nullable String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, @Nullable T requiredValue) Create a new filter without an original property.- See Also:
-
by
public static <T> Filter by(@Nullable String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, Collection<T> requiredValues) Create a new filter without an original property and a collection right hand side.- See Also:
-
by
-
parse
public static Filter parse(@Nullable String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, String requiredValue, String originalProperty) throws IllegalArgumentException Parse filter where the right-hand side is a scalar.- Parameters:
requiredValue- a right-hand side to be parsed according to the propertyType and operator- Throws:
IllegalArgumentException- if the right-hand side cannot be parsed, which is generally caused by aConversionExceptionwhen attempting to convert the requiredValue to the desired propertyType.- See Also:
-
parse
public static Filter parse(@Nullable String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, String requiredValue) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
parse
public static Filter parse(@Nullable String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, Collection<String> requiredValues, String originalProperty) throws IllegalArgumentException Parse a filter where the right-hand side is aCollectionof scalar right-hand side to be parsed.If you need to parse a collection held in a
String(i.e."(1,2,3,4)"), you should useparse(String, String, Class, Operator, String, String)instead.- Parameters:
requiredValues- a collection of right-hand side to be parsed- Throws:
IllegalArgumentException- if the right-hand side cannot be parsed, which is generally caused by aConversionExceptionwhen attempting to convert the requiredValue to the desired propertyType.- See Also:
-
parse
public static Filter parse(@Nullable String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, Collection<String> requiredValues) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
not
Negate the given filter.If the required value is a subquery, the subquery itself is negated.
-
withPropertyName
Create a copy of this filter with a new property name and original property.If the filter's right hand side is a
Subquery, the operation is propagated to the subquery via invalid input: '{@link /*missing*/}'This can be used to apply this filter to a different property. For example, if you have a filter on a
Statementoverobject, you could create a filter over asecondObject.- Throws:
IllegalArgumentException- if the type of the resulting property is not compatible with the required value- See Also:
-
toString
Description copied from interface:PropertyMappingRender this with itsPropertyMapping.getObjectAlias()andPropertyMapping.getPropertyName().- Specified by:
toStringin interfacePropertyMapping- Overrides:
toStringin classObject
-
toOriginalString
Description copied from interface:PropertyMappingRender this with its original property.If no original property are attached to this mapping, this method should return the same as
PropertyMapping.toString().- Specified by:
toOriginalStringin interfacePropertyMapping
-
isNegative
Check if a filter is negative. -
getObjectAlias
Description copied from interface:PropertyMappingAlias in the query/criteria space, if applicable.Null implies a reference to the root alias.
- Specified by:
getObjectAliasin interfacePropertyMapping
-
getPropertyName
Description copied from interface:PropertyMappingProperty name in the query/criteria space.- Specified by:
getPropertyNamein interfacePropertyMapping
-
getPropertyType
-
getOperator
-
getRequiredValue
-
getOriginalProperty
The origin, if known.- Specified by:
getOriginalPropertyin interfacePropertyMapping
-
equals
-
hashCode
public int hashCode()
-