public class Immutables
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Immutables.Immutable |
private static class |
Immutables.ImmutableCollectionWrapper<E> |
private static class |
Immutables.ImmutableEntry<K,V>
Immutable version of Map.Entry for traversing immutable collections.
|
private static class |
Immutables.ImmutableEntrySetWrapper<K,V> |
private static class |
Immutables.ImmutableIteratorWrapper<E> |
private static class |
Immutables.ImmutableMapWrapper<K,V> |
static class |
Immutables.ImmutableMapWrapperExternalizer |
private static class |
Immutables.ImmutableReversibleOrderedSetWrapper<E> |
private static class |
Immutables.ImmutableSetWrapper<E> |
private static class |
Immutables.ImmutableTypedProperties |
Constructor and Description |
---|
Immutables() |
Modifier and Type | Method and Description |
---|---|
private static <T> T |
attemptCopyConstructor(T source,
java.lang.Class<? super T> clazz) |
static <T> java.util.Collection<T> |
immutableCollectionCopy(java.util.Collection<T> collection)
Creates a new immutable copy of the specified Collection.
|
static <T> java.util.Collection<T> |
immutableCollectionWrap(java.util.Collection<? extends T> collection)
Wraps a collection with an immutable collection.
|
static <K,V> java.util.Map.Entry<K,V> |
immutableEntry(java.util.Map.Entry<K,V> entry)
Wraps a
Map.Entry } with an immutable Map.Entry }. |
static <T> java.util.List<T> |
immutableListConvert(java.util.Collection<? extends T> source)
Converts a Collection to an immutable List by copying it.
|
static <T> java.util.List<T> |
immutableListCopy(java.util.List<T> list)
Creates an immutable copy of the list.
|
static <T> java.util.List<T> |
immutableListMerge(java.util.List<? extends T> list1,
java.util.List<? extends T> list2)
Creates a new immutable list containing the union (combined entries) of both lists.
|
static <T> java.util.List<T> |
immutableListWrap(T... array)
Wraps an array with an immutable list.
|
static <K,V> java.util.Map<K,V> |
immutableMapCopy(java.util.Map<K,V> map)
Creates an immutable copy of the specified map.
|
static <K,V> java.util.Map<K,V> |
immutableMapWrap(java.util.Map<? extends K,? extends V> map)
Wraps a map with an immutable map.
|
static <T> java.util.Set<T> |
immutableSetConvert(java.util.Collection<? extends T> collection)
Converts a Collections into an immutable Set by copying it.
|
static <T> java.util.Set<T> |
immutableSetCopy(java.util.Set<T> set)
Creates an immutable copy of the specified set.
|
static <T> java.util.Set<T> |
immutableSetWrap(java.util.Set<? extends T> set)
Wraps a set with an immutable set.
|
static TypedProperties |
immutableTypedProperties(TypedProperties properties)
Creates an immutable copy of the properties.
|
static boolean |
isImmutable(java.lang.Object o)
Whether or not this collection type is immutable
|
public static boolean isImmutable(java.lang.Object o)
o
- a Collection, Set, List, or Mappublic static <T> java.util.List<T> immutableListConvert(java.util.Collection<? extends T> source)
source
- the collection to convertpublic static <T> java.util.List<T> immutableListCopy(java.util.List<T> list)
list
- the list to copypublic static TypedProperties immutableTypedProperties(TypedProperties properties)
properties
- the TypedProperties to copypublic static <T> java.util.List<T> immutableListWrap(T... array)
T
- array
- the array to wrappublic static <T> java.util.List<T> immutableListMerge(java.util.List<? extends T> list1, java.util.List<? extends T> list2)
list1
- contains the first elements of the new listlist2
- contains the successor elements of the new listpublic static <T> java.util.Set<T> immutableSetConvert(java.util.Collection<? extends T> collection)
collection
- the collection to convert/copypublic static <T> java.util.Set<T> immutableSetWrap(java.util.Set<? extends T> set)
set
- the set to wrappublic static <T> java.util.Set<T> immutableSetCopy(java.util.Set<T> set)
set
- the set to copy frompublic static <K,V> java.util.Map<K,V> immutableMapWrap(java.util.Map<? extends K,? extends V> map)
map
- the map to wrappublic static <K,V> java.util.Map<K,V> immutableMapCopy(java.util.Map<K,V> map)
map
- the map to copy frompublic static <T> java.util.Collection<T> immutableCollectionCopy(java.util.Collection<T> collection)
collection
- the collection to copypublic static <T> java.util.Collection<T> immutableCollectionWrap(java.util.Collection<? extends T> collection)
collection
- the collection to wrapprivate static <T> T attemptCopyConstructor(T source, java.lang.Class<? super T> clazz)
public static <K,V> java.util.Map.Entry<K,V> immutableEntry(java.util.Map.Entry<K,V> entry)
Map.Entry
} with an immutable Map.Entry
}. There is no copying involved.entry
- the mapping to wrap.Map.Entry
} wrapper that delegates to the original mapping.