E
- the type of value yielded by this execution context, as determined by which Select
factory
method was used to begin the query. For example, Select.from(String)
yields GenericValue
and Select.id()
yields Long
.public static interface SelectQuery.ExecutionContext<E>
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.
Modifier and Type | Method and Description |
---|---|
List<E> |
asList()
Returns the selected values in a list.
|
<R> List<R> |
asList(Function<E,R> mappingFunction)
Returns the selected values in a list with the mapping function applied to each of them.
|
<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(java.util.function.Consumer<E> action)
Performs the given action for each entity returned by the query.
|
E |
singleValue()
Returns the single Entity that is the result of this query.
|
void |
visitWith(Visitor<E> visitor)
Visits each entity returned by the query.
|
@Nonnull List<E> asList()
@Nonnull <R> List<R> asList(@Nonnull Function<E,R> mappingFunction)
mappingFunction
is a Function<GenericValue,String>
, then each value is returned
as the String
produced by the function instead of the GenericValue
itself.R
- the type of value returned by the mapping function@Nonnull <K,V> Map<K,V> asMap(@Nonnull Function<E,K> keyMapper, @Nonnull Function<E,V> valueMapper)
keyMapper
is a Function<GenericValue,Long>
, and valueMapper
is a
Function<GenericValue,String>
, then the returned map is of type Map<Long,String>
.
If the same key is returned by the keyMapper
more than once, the last value wins.
The functions are permitted to return null
.K
- the inferred key type for the returned mapV
- the inferred value type for the returned mapkeyMapper
- 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@Nullable E singleValue()
Will return null
if no rows were returned by the DB query.
null
if no match is found.IllegalStateException
- if more than one row is found.<R> R consumeWith(@Nonnull EntityListConsumer<E,R> consumer)
EntityListConsumer
to the returned results.
This is equivalent to calling visitWith(Visitor)
, except that the entity list consumer can
return a value.
R
- the return value of the consumerconsumer
- the entity list consumer that will consume the query resultsEntityListConsumer.result()
method.void visitWith(@Nonnull Visitor<E> visitor)
visitor
- the visitor to call with each entity that the query returnsforEach(Consumer)
void forEach(@Nonnull java.util.function.Consumer<E> action)
visitWith(Visitor)
, but is more consistent with the naming
conventions of the Java 8 streaming interfaces.action
- the action to be performedvisitWith(Visitor)
long count()
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.Copyright © 2002-2015 Atlassian. All Rights Reserved.