public final class

SelectQueryImpl.ExecutionContextImpl

extends Object
implements SelectQuery.ExecutionContext<E>
java.lang.Object
   ↳ com.atlassian.jira.entity.SelectQueryImpl.ExecutionContextImpl<E>

Summary

Public Constructors
ExecutionContextImpl(OfBizDelegator ofBizDelegator, EntityBuilder<E> entityBuilder)
Public Methods
@Nonnull <R> List<R> asList(Function<E, R> mappingFunction)
Returns the selected values in a list with the mapping function applied to each of them.
@Nonnull List<E> asList()
Returns the selected values in a list.
@Nonnull <K, V> Map<K, V> asMap(Function<E, K> keyMapper, Function<E, V> valueMapper)
Returns the selected values in a map with the mapping functions applies to each of them.
<R> R consumeWith(EntityListConsumer<E, R> consumer)
Apply an EntityListConsumer to the returned results.
long count()
Returns a count of matching items.
void forEach(Consumer<E> consumer)
Performs the given action for each entity returned by the query.
@Nullable E singleValue()
Returns the single Entity that is the result of this query.
String toString()
void visitWith(Visitor<E> visitor)
Visits each entity returned by the query.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.entity.SelectQuery.ExecutionContext

Public Constructors

public ExecutionContextImpl (OfBizDelegator ofBizDelegator, EntityBuilder<E> entityBuilder)

Public Methods

@Nonnull public List<R> asList (Function<E, R> mappingFunction)

Returns the selected values in a list with the mapping function applied to each of them. For example, if mappingFunction is a Function&lt;GenericValue,String&gt;, then each value is returned as the String produced by the function instead of the GenericValue itself.

Returns
  • the selected values as a list of the yielded values.

@Nonnull public List<E> asList ()

Returns the selected values in a list.

Returns
  • the selected values in a list.

@Nonnull public Map<K, V> asMap (Function<E, K> keyMapper, Function<E, V> valueMapper)

Returns the selected values in a map with the mapping functions applies to each of them. For example, if keyMapper is a Function&lt;GenericValue,Long&gt;, and valueMapper is a Function&lt;GenericValue,String&gt;, then the returned map is of type Map&lt;Long,String&gt;. If the same key is returned by the keyMapper more than once, the last value wins. The functions are permitted to return null.

Parameters
keyMapper the function that maps the queries values to the returned map's keys
valueMapper the function that maps the queries values to the returned map's values
Returns
  • the map produced by the query

public R consumeWith (EntityListConsumer<E, R> consumer)

Apply an EntityListConsumer to the returned results.

This is equivalent to calling visitWith(Visitor), except that the entity list consumer can return a value.

Parameters
consumer the entity list consumer that will consume the query results
Returns
  • the result returned by the consumer's result() method.

public long count ()

Returns a count of matching items. Note that this does not go through the the entityName + "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

public void forEach (Consumer<E> consumer)

Performs the given action for each entity returned by the query. This is morally equivalent to visitWith(Visitor), but is more consistent with the naming conventions of the Java 8 streaming interfaces.

Parameters
consumer the action to be performed

@Nullable public E singleValue ()

Returns the single Entity that is the result of this query.

Will return null if no rows were returned by the DB query.

Returns
  • the single matching value, or null if no match is found.

public String toString ()

public void visitWith (Visitor<E> visitor)

Visits each entity returned by the query.

Parameters
visitor the visitor to call with each entity that the query returns