Package de.esoco.entity
Klasse EntityPredicates
java.lang.Object
de.esoco.entity.EntityPredicates
This class defines several factory methods that create entity-specific
predicates. These methods provide a way to create predicates in a better
readable way, especially when concatenating predicates.
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic <E> de.esoco.lib.expression.Predicate
<E> createWildcardFilter
(String wildcard, org.obrel.core.RelationType<String>... filteredAttributes) Creates a wildcard filter predicate for certain text attributes of an entity type.static <E extends Entity>
de.esoco.storage.QueryPredicate<E> A variant ofStoragePredicates.forType(Class, Predicate)
for entity queries.static <E extends Entity,
V>
de.esoco.lib.expression.Predicate<E> hasExtraAttribute
(Class<E> entityType, de.esoco.lib.expression.Predicate<? super ExtraAttribute> criteria) Creates an entity predicate to query for entities that have an extra attribute that fulfill certain criteria.static <E extends Entity,
V>
de.esoco.lib.expression.predicate.ElementPredicate<E, V> ifAttribute
(org.obrel.core.RelationType<V> type, de.esoco.lib.expression.Predicate<? super V> predicate) APredicates.ifRelation(RelationType, Predicate)
variant that provides better readability for entity attributes.static <E extends Entity,
V>
de.esoco.lib.expression.Predicate<E> ifExtraAttribute
(org.obrel.core.RelationType<V> extraAttribute, V defaultValue, de.esoco.lib.expression.Predicate<? super V> predicate) Creates anElementPredicate
to evaluate a predicate on a certain extra attribute in entities.
-
Methodendetails
-
createWildcardFilter
public static <E> de.esoco.lib.expression.Predicate<E> createWildcardFilter(String wildcard, org.obrel.core.RelationType<String>... filteredAttributes) Creates a wildcard filter predicate for certain text attributes of an entity type. The search string may contain wildcards as defined forStoragePredicates.createWildcardFilter(String)
. This method accepts NULL and empty arguments so that it can be invoked without the need to check the arguments. Such empty arguments will result in NULL being returned (which can then for example be fed intoPredicates.and(Predicate, Predicate)
).- Parameter:
wildcard
- The wildcard filter string (can be NULL or empty)filteredAttributes
- The text attributes to filter (can be NULL or empty)- Gibt zurück:
- The resulting predicate (may be NULL if arguments are NULL or empty)
-
forEntity
public static <E extends Entity> de.esoco.storage.QueryPredicate<E> forEntity(Class<E> entityClass, de.esoco.lib.expression.Predicate<? super E> criteria) A variant ofStoragePredicates.forType(Class, Predicate)
for entity queries.- Siehe auch:
-
hasExtraAttribute
public static <E extends Entity,V> de.esoco.lib.expression.Predicate<E> hasExtraAttribute(Class<E> entityType, de.esoco.lib.expression.Predicate<? super ExtraAttribute> criteria) Creates an entity predicate to query for entities that have an extra attribute that fulfill certain criteria.- Parameter:
entityType
- The entity type to query forcriteria
- The extra attribute criteria- Gibt zurück:
- A new predicate for the given extra attribute
-
ifAttribute
public static <E extends Entity,V> de.esoco.lib.expression.predicate.ElementPredicate<E,V> ifAttribute(org.obrel.core.RelationType<V> type, de.esoco.lib.expression.Predicate<? super V> predicate) APredicates.ifRelation(RelationType, Predicate)
variant that provides better readability for entity attributes.- Siehe auch:
-
ifExtraAttribute
public static <E extends Entity,V> de.esoco.lib.expression.Predicate<E> ifExtraAttribute(org.obrel.core.RelationType<V> extraAttribute, V defaultValue, de.esoco.lib.expression.Predicate<? super V> predicate) Creates anElementPredicate
to evaluate a predicate on a certain extra attribute in entities. It creates an instance of the functionGetElement.GetRelationValue
to retrieve the relation target from objects.This predicate cannot be used for entity queries. It is only intended for the use in predicate evaluation on entities that have already been loaded. For queries the
hasExtraAttribute(Class, Predicate)
method should be used instead.- Parameter:
extraAttribute
- The relation type of the extra attributedefaultValue
- The default value if the attribute doesn't existpredicate
- The predicate to evaluate the extra attribute with- Gibt zurück:
- A new predicate for the given extra attribute
-