org.infinispan.util
Class Immutables

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

public class Immutables
extends Object

Factory for generating immutable type wrappers.

Since:
4.0
Author:
Jason T. Greene, Galder ZamarreƱo

Nested Class Summary
static interface Immutables.Immutable
           
static class Immutables.ImmutableMapWrapperExternalizer
           
 
Constructor Summary
Immutables()
           
 
Method Summary
static
<T> Collection<T>
immutableCollectionCopy(Collection<T> collection)
          Creates a new immutable copy of the specified Collection.
static
<T> Collection<T>
immutableCollectionWrap(Collection<? extends T> collection)
          Wraps a collection with an immutable collection.
static
<K,V> Map.Entry<K,V>
immutableEntry(Map.Entry<K,V> entry)
          Wraps a Map.Entry} with an immutable Map.Entry}.
static InternalCacheEntry immutableInternalCacheEntry(InternalCacheEntry entry)
          Wraps a InternalCacheEntry} with an immutable InternalCacheEntry}.
static
<T> List<T>
immutableListConvert(Collection<? extends T> source)
          Converts a Collection to an immutable List by copying it.
static
<T> List<T>
immutableListCopy(List<T> list)
          Creates an immutable copy of the list.
static
<T> List<T>
immutableListMerge(List<? extends T> list1, List<? extends T> list2)
          Creates a new immutable list containing the union (combined entries) of both lists.
static
<T> List<T>
immutableListWrap(T... array)
          Wraps an array with an immutable list.
static
<K,V> Map<K,V>
immutableMapCopy(Map<K,V> map)
          Creates an immutable copy of the specified map.
static
<K,V> Map<K,V>
immutableMapWrap(Map<? extends K,? extends V> map)
          Wraps a map with an immutable map.
static
<T> Set<T>
immutableSetConvert(Collection<? extends T> collection)
          Converts a Collections into an immutable Set by copying it.
static
<T> Set<T>
immutableSetCopy(Set<T> set)
          Creates an immutable copy of the specified set.
static
<T> Set<T>
immutableSetWrap(Set<? extends T> set)
          Wraps a set with an immutable set.
static TypedProperties immutableTypedPropreties(TypedProperties properties)
          Creates an immutable copy of the properties.
static boolean isImmutable(Object o)
          Whether or not this collection type is immutable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Immutables

public Immutables()
Method Detail

isImmutable

public static boolean isImmutable(Object o)
Whether or not this collection type is immutable

Parameters:
o - a Collection, Set, List, or Map
Returns:
true if immutable, false if not

immutableListConvert

public static <T> List<T> immutableListConvert(Collection<? extends T> source)
Converts a Collection to an immutable List by copying it.

Parameters:
source - the collection to convert
Returns:
a copied/converted immutable list

immutableListCopy

public static <T> List<T> immutableListCopy(List<T> list)
Creates an immutable copy of the list.

Parameters:
list - the list to copy
Returns:
the immutable copy

immutableTypedPropreties

public static TypedProperties immutableTypedPropreties(TypedProperties properties)
Creates an immutable copy of the properties.

Parameters:
properties - the TypedProperties to copy
Returns:
the immutable copy

immutableListWrap

public static <T> List<T> immutableListWrap(T... array)
Wraps an array with an immutable list. There is no copying involved.

Type Parameters:
T -
Parameters:
array - the array to wrap
Returns:
a list containing the array

immutableListMerge

public static <T> List<T> immutableListMerge(List<? extends T> list1,
                                             List<? extends T> list2)
Creates a new immutable list containing the union (combined entries) of both lists.

Parameters:
list1 - contains the first elements of the new list
list2 - contains the successor elements of the new list
Returns:
a new immutable merged copy of list1 and list2

immutableSetConvert

public static <T> Set<T> immutableSetConvert(Collection<? extends T> collection)
Converts a Collections into an immutable Set by copying it.

Parameters:
collection - the collection to convert/copy
Returns:
a new immutable set containing the elements in collection

immutableSetWrap

public static <T> Set<T> immutableSetWrap(Set<? extends T> set)
Wraps a set with an immutable set. There is no copying involved.

Parameters:
set - the set to wrap
Returns:
an immutable set wrapper that delegates to the original set

immutableSetCopy

public static <T> Set<T> immutableSetCopy(Set<T> set)
Creates an immutable copy of the specified set.

Parameters:
set - the set to copy from
Returns:
an immutable set copy

immutableMapWrap

public static <K,V> Map<K,V> immutableMapWrap(Map<? extends K,? extends V> map)
Wraps a map with an immutable map. There is no copying involved.

Parameters:
map - the map to wrap
Returns:
an immutable map wrapper that delegates to the original map

immutableMapCopy

public static <K,V> Map<K,V> immutableMapCopy(Map<K,V> map)
Creates an immutable copy of the specified map.

Parameters:
map - the map to copy from
Returns:
an immutable map copy

immutableCollectionCopy

public static <T> Collection<T> immutableCollectionCopy(Collection<T> collection)
Creates a new immutable copy of the specified Collection.

Parameters:
collection - the collection to copy
Returns:
an immutable copy

immutableCollectionWrap

public static <T> Collection<T> immutableCollectionWrap(Collection<? extends T> collection)
Wraps a collection with an immutable collection. There is no copying involved.

Parameters:
collection - the collection to wrap
Returns:
an immutable collection wrapper that delegates to the original collection

immutableEntry

public static <K,V> Map.Entry<K,V> immutableEntry(Map.Entry<K,V> entry)
Wraps a Map.Entry} with an immutable Map.Entry}. There is no copying involved.

Parameters:
entry - the mapping to wrap.
Returns:
an immutable Map.Entry} wrapper that delegates to the original mapping.

immutableInternalCacheEntry

public static InternalCacheEntry immutableInternalCacheEntry(InternalCacheEntry entry)
Wraps a InternalCacheEntry} with an immutable InternalCacheEntry}. There is no copying involved.

Parameters:
entry - the internal cache entry to wrap.
Returns:
an immutable InternalCacheEntry} wrapper that delegates to the original entry.

-->

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