public class Views
extends java.lang.Object
List
and Map
.Modifier | Constructor and Description |
---|---|
private |
Views() |
Modifier and Type | Method and Description |
---|---|
static <T,R> java.util.List<T> |
listView(java.util.List<R> originalList,
java.util.function.Function<R,T> transformer)
Create a
List view, which transforms the values of provided original list. |
static <K,V,O> java.util.Map<K,V> |
mapView(java.util.Map<K,O> originalMap,
java.util.function.Function<O,V> valuesTransformer)
Create a
Map view, which transforms the values of provided original map. |
static <E> java.util.Set<E> |
setDiffView(java.util.Set<? extends E> set1,
java.util.Set<? extends E> set2)
Create a view of a difference of provided sets.
|
static <E> java.util.Set<E> |
setUnionView(java.util.Set<? extends E> set1,
java.util.Set<? extends E> set2)
Create a view of an union of provided sets.
|
public static <T,R> java.util.List<T> listView(java.util.List<R> originalList, java.util.function.Function<R,T> transformer)
List
view, which transforms the values of provided original list.
Removing elements from the view is supported, adding and setting isn't and
throws UnsupportedOperationException
when invoked.
T
- transformed type parameter.R
- type of the element from provided list.originalList
- original list.transformer
- transforming functions.public static <K,V,O> java.util.Map<K,V> mapView(java.util.Map<K,O> originalMap, java.util.function.Function<O,V> valuesTransformer)
Map
view, which transforms the values of provided original map.
Removing elements from the map view is supported, adding and setting isn't and
throws UnsupportedOperationException
when invoked.
K
- key type.V
- transformed value type.O
- original value type.originalMap
- provided map.valuesTransformer
- values transformer.public static <E> java.util.Set<E> setUnionView(java.util.Set<? extends E> set1, java.util.Set<? extends E> set2)
View is updated whenever any of the provided set changes.
E
- set item type.set1
- first set.set2
- second set.public static <E> java.util.Set<E> setDiffView(java.util.Set<? extends E> set1, java.util.Set<? extends E> set2)
View is updated whenever any of the provided set changes.
E
- set item type.set1
- first set.set2
- second set.