Class Views
- java.lang.Object
-
- org.glassfish.jersey.internal.util.collection.Views
-
public class Views extends java.lang.Object
Collections utils, which provide transforming views forList
andMap
.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Views()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,R>
java.util.List<T>listView(java.util.List<R> originalList, java.util.function.Function<R,T> transformer)
Create aList
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 aMap
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.
-
-
-
Method Detail
-
listView
public static <T,R> java.util.List<T> listView(java.util.List<R> originalList, java.util.function.Function<R,T> transformer)
Create aList
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.- Type Parameters:
T
- transformed type parameter.R
- type of the element from provided list.- Parameters:
originalList
- original list.transformer
- transforming functions.- Returns:
- transformed list view.
-
mapView
public static <K,V,O> java.util.Map<K,V> mapView(java.util.Map<K,O> originalMap, java.util.function.Function<O,V> valuesTransformer)
Create aMap
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.- Type Parameters:
K
- key type.V
- transformed value type.O
- original value type.- Parameters:
originalMap
- provided map.valuesTransformer
- values transformer.- Returns:
- transformed map view.
-
setUnionView
public 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.View is updated whenever any of the provided set changes.
- Type Parameters:
E
- set item type.- Parameters:
set1
- first set.set2
- second set.- Returns:
- union view of given sets.
-
setDiffView
public 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.View is updated whenever any of the provided set changes.
- Type Parameters:
E
- set item type.- Parameters:
set1
- first set.set2
- second set.- Returns:
- union view of given sets.
-
-