Infinispan Distribution 5.2.6.Final-redhat-2

org.infinispan.util
Class InfinispanCollections

java.lang.Object
  extended by org.infinispan.util.InfinispanCollections

public class InfinispanCollections
extends Object

Static helpers for Infinispan-specific collections

Since:
4.0
Author:
Manik Surtani

Nested Class Summary
static class InfinispanCollections.EmptyList
           
static class InfinispanCollections.EmptyMap
           
static class InfinispanCollections.EmptySet
           
static interface InfinispanCollections.Function<E,T>
          A function that converts a type into another one.
static interface InfinispanCollections.MapMakerFunction<K,V,E>
          A function that converts an entry into a key/value pair for use in a map.
 
Constructor Summary
InfinispanCollections()
           
 
Method Summary
static
<E> Set<E>
difference(Set<E> s1, Set<E> s2)
          Returns the elements that are present in s1 but which are not present in s2, without changing the contents of neither s1, nor s2.
static
<T> List<T>
emptyList()
          Returns the empty list (immutable).
static
<K,V> Map<K,V>
emptyMap()
          Returns the empty map (immutable).
static
<T> Set<T>
emptySet()
          Returns the empty set (immutable).
static
<K,V,E> Map<K,V>
transformCollectionToMap(Collection<E> input, InfinispanCollections.MapMakerFunction<K,V,E> f)
          Given a collection, transforms the collection to a map given a InfinispanCollections.MapMakerFunction
static
<K,V,E> Map<K,V>
transformMapValue(Map<K,E> input, InfinispanCollections.Function<E,V> f)
          Given a map of well known key/value types, it makes a shallow copy of it while at the same time transforming it's value type to a desired output type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InfinispanCollections

public InfinispanCollections()
Method Detail

transformMapValue

public static <K,V,E> Map<K,V> transformMapValue(Map<K,E> input,
                                                 InfinispanCollections.Function<E,V> f)
Given a map of well known key/value types, it makes a shallow copy of it while at the same time transforming it's value type to a desired output type. The transformation of the value type is done using a given a function.

Type Parameters:
K - input map's key type
V - desired output type of the map's value
E - input map's value type
Parameters:
input - contains the input key/value pair map
f - function instance to use to transform the value part of the map
Returns:
a shallow copy of the input Map with all its values transformed.

transformCollectionToMap

public static <K,V,E> Map<K,V> transformCollectionToMap(Collection<E> input,
                                                        InfinispanCollections.MapMakerFunction<K,V,E> f)
Given a collection, transforms the collection to a map given a InfinispanCollections.MapMakerFunction

Type Parameters:
K - output map's key type
V - output type of the map's value
E - input collection's entry type
Parameters:
input - contains a collection of type E
f - MapMakerFunction instance to use to transform the collection to a key/value pair
Returns:
a Map with keys and values generated from the input collection

difference

public static <E> Set<E> difference(Set<E> s1,
                                    Set<E> s2)
Returns the elements that are present in s1 but which are not present in s2, without changing the contents of neither s1, nor s2.

Type Parameters:
E - type of objects in Set
Parameters:
s1 - first set
s2 - second set
Returns:
the elements in s1 that are not in s2

emptySet

public static final <T> Set<T> emptySet()
Returns the empty set (immutable). Contrary to Collections.emptySet(), the set returned returns a constant Iterator, rather than create a brand new one in each iterator call. This set is marshallable using Infinispan's Externalizer framework.

See Also:
EMPTY_SET

emptyMap

public static final <K,V> Map<K,V> emptyMap()
Returns the empty map (immutable). Contrary to Collections.emptyMap(), the map returned returns a constant Iterator, rather than create a brand new one in each iterator call. This set is marshallable using Infinispan's Externalizer framework.

See Also:
EMPTY_MAP

emptyList

public static final <T> List<T> emptyList()
Returns the empty list (immutable). Contrary to Collections.emptyList()}, the list returned returns a constant Iterator, rather than create a brand new one in each iterator call. This set is marshallable using Infinispan's Externalizer framework.

See Also:
EMPTY_LIST

Infinispan Distribution 5.2.6.Final-redhat-2

Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.