public final class SelectQueryImpl.ExecutionContextImpl<E> extends Object implements SelectQuery.ExecutionContext<E>
| Constructor and Description |
|---|
ExecutionContextImpl(OfBizDelegator ofBizDelegator,
EntityBuilder<E> entityBuilder) |
| 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> consumer)
Performs the given action for each entity returned by the query.
|
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.
|
public ExecutionContextImpl(OfBizDelegator ofBizDelegator, EntityBuilder<E> entityBuilder)
@Nonnull public List<E> asList()
SelectQuery.ExecutionContextasList in interface SelectQuery.ExecutionContext<E>@Nonnull public <R> List<R> asList(@Nonnull Function<E,R> mappingFunction)
SelectQuery.ExecutionContextmappingFunction is a Function<GenericValue,String>, then each value is returned
as the String produced by the function instead of the GenericValue itself.asList in interface SelectQuery.ExecutionContext<E>R - the type of value returned by the mapping function@Nonnull public <K,V> Map<K,V> asMap(@Nonnull Function<E,K> keyMapper, @Nonnull Function<E,V> valueMapper)
SelectQuery.ExecutionContextkeyMapper 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.asMap in interface SelectQuery.ExecutionContext<E>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 valuespublic void visitWith(@Nonnull Visitor<E> visitor)
SelectQuery.ExecutionContextvisitWith in interface SelectQuery.ExecutionContext<E>visitor - the visitor to call with each entity that the query returnsSelectQuery.ExecutionContext.forEach(Consumer)@Nullable public E singleValue() throws IllegalStateException
SelectQuery.ExecutionContext
Will return null if no rows were returned by the DB query.
singleValue in interface SelectQuery.ExecutionContext<E>null if no match is found.IllegalStateException - if more than one row is found.public <R> R consumeWith(@Nonnull EntityListConsumer<E,R> consumer)
SelectQuery.ExecutionContextEntityListConsumer to the returned results.
This is equivalent to calling SelectQuery.ExecutionContext.visitWith(Visitor), except that the entity list consumer can
return a value.
consumeWith in interface SelectQuery.ExecutionContext<E>R - the return value of the consumerconsumer - the entity list consumer that will consume the query resultsEntityListConsumer.result() method.public void forEach(@Nonnull java.util.function.Consumer<E> consumer)
SelectQuery.ExecutionContextSelectQuery.ExecutionContext.visitWith(Visitor), but is more consistent with the naming
conventions of the Java 8 streaming interfaces.forEach in interface SelectQuery.ExecutionContext<E>consumer - the action to be performedSelectQuery.ExecutionContext.visitWith(Visitor)public long count()
SelectQuery.ExecutionContextentityName + "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.count in interface SelectQuery.ExecutionContext<E>Copyright © 2002-2019 Atlassian. All Rights Reserved.