Class Views
- java.lang.Object
-
- org.glassfish.jersey.internal.util.collection.Views
-
public class Views extends Object
- Author:
- Pavel Bucek
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,R>
List<T>listView(List<R> originalList, Function<R,T> transformer)Create aListview, which transforms the values of provided original list.static Map<String,List<String>>mapObjectToStringView(Map<String,List<Object>> originalMap, Function<List<Object>,List<String>> valuesTransformer)Create aMapview, which transforms the values of provided original map.static <K,V,O>
Map<K,V>mapView(Map<K,O> originalMap, Function<O,V> valuesTransformer)Create aMapview, which transforms the values of provided original map.static <E> Set<E>setDiffView(Set<? extends E> set1, Set<? extends E> set2)Create a view of a difference of provided sets, i.e. the diff filters out from the first set the items included in the second set.static <E> Set<E>setUnionView(Set<? extends E> set1, Set<? extends E> set2)Create a view of an union of provided sets.
-
-
-
Method Detail
-
listView
public static <T,R> List<T> listView(List<R> originalList, Function<R,T> transformer)
Create aListview, which transforms the values of provided original list.Removing elements from the view is supported, adding and setting isn't and throws
UnsupportedOperationExceptionwhen 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> Map<K,V> mapView(Map<K,O> originalMap, Function<O,V> valuesTransformer)
Create aMapview, which transforms the values of provided original map.Removing elements from the map view is supported, adding and setting isn't and throws
UnsupportedOperationExceptionwhen 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.
-
mapObjectToStringView
public static Map<String,List<String>> mapObjectToStringView(Map<String,List<Object>> originalMap, Function<List<Object>,List<String>> valuesTransformer)
Create aMapview, which transforms the values of provided original map.- Parameters:
originalMap- provided map.valuesTransformer- values transformer.- Returns:
- transformed map view.
-
setUnionView
public static <E> Set<E> setUnionView(Set<? extends E> set1, 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> Set<E> setDiffView(Set<? extends E> set1, Set<? extends E> set2)
Create a view of a difference of provided sets, i.e. the diff filters out from the first set the items included in the second set.View is updated whenever any of the provided set changes.
- Type Parameters:
E- set item type.- Parameters:
set1- first set.set2- second set.- Returns:
- view that is a difference of given sets.
-
-