Package com.atlassian.jira.entity
Interface SelectQuery.ExecutionContext<E>
- Type Parameters:
E- the type of value yielded by this execution context, as determined by whichSelectfactory method was used to begin the query. For example,Select.from(String)yieldsGenericValueandSelect.id()yieldsLong.
- All Known Implementing Classes:
SelectQueryImpl.ExecutionContextImpl
- Enclosing interface:
- SelectQuery<E>
public static interface SelectQuery.ExecutionContext<E>
The parser context for entity engine
Select queries that is available after calling
Select.ExecutableContext.runWith(EntityEngine) or
Select.ExecutableContext.runWith(com.atlassian.jira.ofbiz.OfBizDelegator).
The methods available through the execution context specify how the selected entities should be returned
to the caller. For example, asList() will return a list of values, or count() will return
only a count of them.
-
Method Summary
Modifier and TypeMethodDescriptionasList()Returns the selected values in a list.<R> List<R>Returns the selected values in a list with the mapping function applied to each of them.<K,V> Map<K, V> Returns the selected values in a map with the mapping functions applies to each of them.<R> RconsumeWith(EntityListConsumer<E, R> consumer) Apply anEntityListConsumerto the returned results.longcount()Returns a count of matching items.voidPerforms the given action for each entity returned by the query.Returns the single Entity that is the result of this query.voidVisits each entity returned by the query.
-
Method Details
-
asList
Returns the selected values in a list.- Returns:
- the selected values in a list.
-
asList
Returns the selected values in a list with the mapping function applied to each of them. For example, ifmappingFunctionis aFunction<GenericValue,String>, then each value is returned as theStringproduced by the function instead of theGenericValueitself.- Type Parameters:
R- the type of value returned by the mapping function- Returns:
- the selected values as a list of the yielded values.
-
asMap
@Nonnull <K,V> Map<K,V> asMap(@Nonnull Function<E, K> keyMapper, @Nonnull Function<E, V> valueMapper) Returns the selected values in a map with the mapping functions applies to each of them. For example, ifkeyMapperis aFunction<GenericValue,Long>, andvalueMapperis aFunction<GenericValue,String>, then the returned map is of typeMap<Long,String>. If the same key is returned by thekeyMappermore than once, the last value wins. The functions are permitted to returnnull.- Type Parameters:
K- the inferred key type for the returned mapV- the inferred value type for the returned map- Parameters:
keyMapper- the function that maps the queries values to the returned map's keysvalueMapper- the function that maps the queries values to the returned map's values- Returns:
- the map produced by the query
-
singleValue
Returns the single Entity that is the result of this query.Will return
nullif no rows were returned by the DB query.- Returns:
- the single matching value, or
nullif no match is found. - Throws:
IllegalStateException- if more than one row is found.
-
consumeWith
Apply anEntityListConsumerto the returned results.This is equivalent to calling
visitWith(Visitor), except that the entity list consumer can return a value.- Type Parameters:
R- the return value of the consumer- Parameters:
consumer- the entity list consumer that will consume the query results- Returns:
- the result returned by the consumer's
EntityListConsumer.result()method.
-
visitWith
Visits each entity returned by the query.- Parameters:
visitor- the visitor to call with each entity that the query returns- See Also:
-
forEach
Performs the given action for each entity returned by the query. This is morally equivalent tovisitWith(Visitor), but is more consistent with the naming conventions of the Java 8 streaming interfaces.- Parameters:
action- the action to be performed- See Also:
-
count
long count()Returns a count of matching items. Note that this does not go through the theentityName + "Count"pseudo-view stuff in the entity model, but rather generates a count function directly in the query that it executes, so you should be able to use it with arbitrary entities.- Returns:
- count of matching items
- Since:
- 6.1
-