com.atlassian.jira.entity
Class SelectQueryImpl.ExecutionContextImpl<E>

java.lang.Object
  extended by 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
SelectQueryImpl.ExecutionContextImpl(OfBizDelegator ofBizDelegator, EntityBuilder<E> entityBuilder)
           
 
Method Summary
 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.
<R> R
consumeWith(EntityListConsumer<E,R> consumer)
          Apply an EntityListConsumer to the returned results.
 long count()
          Returns a count of matching items.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectQueryImpl.ExecutionContextImpl

public SelectQueryImpl.ExecutionContextImpl(OfBizDelegator ofBizDelegator,
                                            EntityBuilder<E> entityBuilder)
Method Detail

asList

@Nonnull
public List<E> asList()
Description copied from interface: SelectQuery.ExecutionContext
Returns the selected values in a list.

Specified by:
asList in interface SelectQuery.ExecutionContext<E>
Returns:
the selected values in a list.

asList

@Nonnull
public <R> List<R> asList(@Nonnull
                                  Function<E,R> mappingFunction)
Description copied from interface: SelectQuery.ExecutionContext
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.

Specified by:
asList in interface SelectQuery.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.

singleValue

@Nullable
public E singleValue()
              throws IllegalStateException
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 interface SelectQuery.ExecutionContext<E>
Returns:
the single matching value, or null if no match is found.
Throws:
IllegalStateException - if more than one row is found.

consumeWith

public <R> R consumeWith(@Nonnull
                         EntityListConsumer<E,R> consumer)
Description copied from interface: SelectQuery.ExecutionContext
Apply an EntityListConsumer 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 interface SelectQuery.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.

visitWith

public void visitWith(@Nonnull
                      Visitor<E> visitor)
Description copied from interface: SelectQuery.ExecutionContext
Visits each entity returned by the query.

This is equivalent to calling SelectQuery.ExecutionContext.consumeWith(EntityListConsumer) and ignoring the return value.

Specified by:
visitWith in interface SelectQuery.ExecutionContext<E>
Parameters:
visitor - the visitor to call with each entity that the query returns

count

public long count()
Description copied from interface: SelectQuery.ExecutionContext
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.

Specified by:
count in interface SelectQuery.ExecutionContext<E>
Returns:
count of matching items

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2014 Atlassian. All Rights Reserved.