Package ubic.gemma.persistence.util
Class Filter
java.lang.Object
ubic.gemma.persistence.util.Filter
- All Implemented Interfaces:
PropertyMapping
Holds the necessary information to filter an entity with a property, operator and right-hand side value.
- Author:
- tesarst, poirigui
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Filter
by
(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> Filter
by
(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> Filter
by
(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, T requiredValue) Create a new filter without an original property.static <T> Filter
by
(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, T requiredValue, String originalProperty) Create a new filter.static <T> Filter
by
(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, Subquery requiredValues) static <T> Filter
by
(String objectAlias, String propertyName, Class<T> propertyType, Filter.Operator operator, Subquery requiredValues, String originalProperty) static org.springframework.core.convert.ConversionService
Obtain the conversion service used for parsing values.boolean
isNegative
(Filter f) Check if a filter is negative.static Filter
Negate the given filter.static Filter
parse
(String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, String requiredValue) static Filter
parse
(String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, String requiredValue, String originalProperty) Parse filter where the right-hand side is a scalar.static Filter
parse
(String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, Collection<String> requiredValues) static Filter
parse
(String objectAlias, String propertyName, Class<?> propertyType, Filter.Operator operator, Collection<String> requiredValues, String originalProperty) Parse a filter where the right-hand side is aCollection
of scalar right-hand side to be parsed.Render this with its original property.toString()
Render this with itsPropertyMapping.getObjectAlias()
andPropertyMapping.getPropertyName()
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ubic.gemma.persistence.util.PropertyMapping
getObjectAlias, getOriginalProperty, getPropertyName
-
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
-
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 aConversionException
when 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 aCollection
of 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 aConversionException
when 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.
-
toString
Description copied from interface:PropertyMapping
Render this with itsPropertyMapping.getObjectAlias()
andPropertyMapping.getPropertyName()
.- Specified by:
toString
in interfacePropertyMapping
- Overrides:
toString
in classObject
-
toOriginalString
Description copied from interface:PropertyMapping
Render 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:
toOriginalString
in interfacePropertyMapping
-
isNegative
Check if a filter is negative.
-