Package com.atlassian.jira.entity
Class SelectQueryImpl.ExecutionContextImpl<E>
java.lang.Object
com.atlassian.jira.entity.SelectQueryImpl.ExecutionContextImpl<E>
- All Implemented Interfaces:
SelectQuery.ExecutionContext<E>
- Enclosing class:
- SelectQueryImpl<E>
public final class SelectQueryImpl.ExecutionContextImpl<E>
extends Object
implements SelectQuery.ExecutionContext<E>
-
Constructor Summary
ConstructorsConstructorDescriptionExecutionContextImpl
(OfBizDelegator ofBizDelegator, EntityBuilder<E> entityBuilder) -
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> R
consumeWith
(EntityListConsumer<E, R> consumer) Apply anEntityListConsumer
to the returned results.long
count()
Returns a count of matching items.void
Performs the given action for each entity returned by the query.Returns the single Entity that is the result of this query.toString()
void
Visits each entity returned by the query.
-
Constructor Details
-
ExecutionContextImpl
-
-
Method Details
-
asList
Description copied from interface:SelectQuery.ExecutionContext
Returns the selected values in a list.- Specified by:
asList
in interfaceSelectQuery.ExecutionContext<E>
- Returns:
- the selected values in a list.
-
asList
Description copied from interface:SelectQuery.ExecutionContext
Returns the selected values in a list with the mapping function applied to each of them. For example, ifmappingFunction
is aFunction<GenericValue,String>
, then each value is returned as theString
produced by the function instead of theGenericValue
itself.- Specified by:
asList
in interfaceSelectQuery.ExecutionContext<E>
- 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 public <K,V> Map<K,V> asMap(@Nonnull Function<E, K> keyMapper, @Nonnull Function<E, V> valueMapper) Description copied from interface:SelectQuery.ExecutionContext
Returns the selected values in a map with the mapping functions applies to each of them. For example, ifkeyMapper
is aFunction<GenericValue,Long>
, andvalueMapper
is aFunction<GenericValue,String>
, then the returned map is of typeMap<Long,String>
. If the same key is returned by thekeyMapper
more than once, the last value wins. The functions are permitted to returnnull
.- Specified by:
asMap
in interfaceSelectQuery.ExecutionContext<E>
- 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
-
visitWith
Description copied from interface:SelectQuery.ExecutionContext
Visits each entity returned by the query.- Specified by:
visitWith
in interfaceSelectQuery.ExecutionContext<E>
- Parameters:
visitor
- the visitor to call with each entity that the query returns- See Also:
-
singleValue
Description copied from interface:SelectQuery.ExecutionContext
Returns the single Entity that is the result of this query.Will return
null
if no rows were returned by the DB query.- Specified by:
singleValue
in interfaceSelectQuery.ExecutionContext<E>
- Returns:
- the single matching value, or
null
if no match is found. - Throws:
IllegalStateException
- if more than one row is found.
-
consumeWith
Description copied from interface:SelectQuery.ExecutionContext
Apply anEntityListConsumer
to the returned results.This is equivalent to calling
SelectQuery.ExecutionContext.visitWith(Visitor)
, except that the entity list consumer can return a value.- Specified by:
consumeWith
in interfaceSelectQuery.ExecutionContext<E>
- 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.
-
forEach
Description copied from interface:SelectQuery.ExecutionContext
Performs the given action for each entity returned by the query. This is morally equivalent toSelectQuery.ExecutionContext.visitWith(Visitor)
, but is more consistent with the naming conventions of the Java 8 streaming interfaces.- Specified by:
forEach
in interfaceSelectQuery.ExecutionContext<E>
- Parameters:
consumer
- the action to be performed- See Also:
-
count
public long count()Description copied from interface:SelectQuery.ExecutionContext
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.- Specified by:
count
in interfaceSelectQuery.ExecutionContext<E>
- Returns:
- count of matching items
-
toString
-