|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> com.trendmicro.grid.acl.l0.BatchCollection<E>
public class BatchCollection<E>
Defines a collection that fails if more than Limits.MAX_INCOMING_REQUEST_BATCH_SIZE
elements are added.
Nested Class Summary | |
---|---|
static interface |
BatchCollection.Invoker<E,R>
Defines an invoker that may be used to handle chunks of batch collections. |
Constructor Summary | |
---|---|
BatchCollection()
Creates a new modifiable instance. |
|
BatchCollection(int batchSize)
Creates a new modifiable instance with the given batch size limit. |
Method Summary | ||
---|---|---|
boolean |
add(E e)
|
|
boolean |
addAll(Collection<? extends E> c)
|
|
static
|
chunksOf(List<? extends E> elements)
Creates chunks of batch collections that honor the built-in batch limit using the given elements. |
|
static
|
chunksOf(List<? extends E> elements,
int batchSize)
Creates chunks of batch collections that honor the given batch limit using the given elements. |
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
boolean |
equals(Object o)
|
|
static int |
getDefaultInvocationBatchSize()
Returns the batch size that is used to build chunks within the method invokeOnChunksOf(java.util.Collection extends E>, com.trendmicro.grid.acl.l0.BatchCollection.Invoker . |
|
int |
hashCode()
|
|
static
|
invokeOnChunksOf(Collection<? extends E> elements,
BatchCollection.Invoker<E,T> invoker)
Is a helper method that can be used to invoke a certain call on all batch chunks of a larger input list. |
|
boolean |
isEmpty()
|
|
Iterator<E> |
iterator()
|
|
static
|
of(Collection<? extends E> elements)
Creates a new final batch collection using the given elements. |
|
static
|
of(E... elements)
Creates a new final batch collection using the given elements. |
|
static
|
of(E element)
Creates a new final singleton batch collection using the given element. |
|
static void |
setDefaultInvocationBatchSize(int defaultInvocationBatchSize)
Sets the batch size that is used to build chunks within the method invokeOnChunksOf(java.util.Collection extends E>, com.trendmicro.grid.acl.l0.BatchCollection.Invoker . |
|
int |
size()
|
|
Object[] |
toArray()
|
|
|
toArray(T[] a)
|
Methods inherited from class java.util.AbstractCollection |
---|
clear, remove, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BatchCollection()
public BatchCollection(int batchSize)
batchSize
- The non-default batch size limit to use.Method Detail |
---|
public static <E> BatchCollection<E> of(E element)
element
- the element to add.
public static <E> BatchCollection<E> of(E... elements)
elements
- the elements to add.
BatchSizeExceededException
- If more elements than allowed are specified.public static <E> BatchCollection<E> of(Collection<? extends E> elements)
elements
- the elements to add.
BatchSizeExceededException
- If more elements than allowed are specified.public static <E> List<BatchCollection<E>> chunksOf(List<? extends E> elements)
elements
- the elements to add (may be larger than the actual batch size).
public static <E> List<BatchCollection<E>> chunksOf(List<? extends E> elements, int batchSize)
elements
- the elements to add (may be larger than the actual batch size).batchSize
- Sets a custom limit for the batch size of a chunk.
public static <E,R,T extends Collection<R>> T invokeOnChunksOf(Collection<? extends E> elements, BatchCollection.Invoker<E,T> invoker) throws WebException
Collection<FileIdentifier> identifiers = ...
Collection<FileDetails> details = BatchCollection.invokeOnChunksOf(identifiers,
new BatchCollection.Invoker<FileIdentifier, Collection<FileDetails>>() {
public Collection<FileDetails> invoke(BatchCollection<FileIdentifier> chunk) {
return fileService.getFileDetailsList(BatchCollection.of(chunk));
}
});
E
- The type of the input collection elements.R
- The return type of collection or list elements.T
- The type of collection or list implementation that is returned by the invoked method.elements
- The elements to convert to batch chunks.invoker
- The invoker implemented as anonymous inner class that walks all batch chunks
to produce a final result.
WebException
- May be thrown inside the invoker.public static int getDefaultInvocationBatchSize()
invokeOnChunksOf(java.util.Collection extends E>, com.trendmicro.grid.acl.l0.BatchCollection.Invoker)
.
invokeOnChunksOf(java.util.Collection extends E>, com.trendmicro.grid.acl.l0.BatchCollection.Invoker)
.public static void setDefaultInvocationBatchSize(int defaultInvocationBatchSize)
invokeOnChunksOf(java.util.Collection extends E>, com.trendmicro.grid.acl.l0.BatchCollection.Invoker)
.
defaultInvocationBatchSize
- the batch size that is used to build chunks
within the method invokeOnChunksOf(java.util.Collection extends E>, com.trendmicro.grid.acl.l0.BatchCollection.Invoker)
.public boolean add(E e)
add
in interface Collection<E>
add
in class AbstractCollection<E>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in class AbstractCollection<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
public int size()
size
in interface Collection<E>
size
in class AbstractCollection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in class AbstractCollection<E>
public boolean contains(Object o)
contains
in interface Collection<E>
contains
in class AbstractCollection<E>
public Object[] toArray()
toArray
in interface Collection<E>
toArray
in class AbstractCollection<E>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<E>
toArray
in class AbstractCollection<E>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
containsAll
in class AbstractCollection<E>
public boolean equals(Object o)
equals
in interface Collection<E>
equals
in class Object
public int hashCode()
hashCode
in interface Collection<E>
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |