Class Collections2


  • public final class Collections2
    extends Object
    Additional Collection based utility methods.
    • Method Detail

      • transformedCollection

        public static <M,​N,​E0 extends RuntimeException,​E1 extends RuntimeException> Collection<N> transformedCollection​(Collection<M> collection,
                                                                                                                                          org.forgerock.util.Function<? super M,​? extends N,​E0> funcMtoN,
                                                                                                                                          org.forgerock.util.Function<? super N,​? extends M,​E1> funcNtoM)
        Returns a view of collection whose values have been mapped to elements of type N using funcMtoN. The returned collection supports all operations.
        Type Parameters:
        M - The type of elements contained in collection.
        N - The type of elements contained in the returned collection.
        E0 - The type of exception thrown by funcMtoN.
        E1 - The type of exception thrown by funcNtoM.
        Parameters:
        collection - The collection to be transformed.
        funcMtoN - A function which maps values of type M to values of type N. This function will be used when retrieving values from collection.
        funcNtoM - A function which maps values of type N to values of type M. This function will be used when performing queries and adding values to collection .
        Returns:
        A view of collection whose values have been mapped to elements of type N using funcMtoN.
      • transformedList

        public static <M,​N,​E0 extends RuntimeException,​E1 extends RuntimeException> List<N> transformedList​(List<M> list,
                                                                                                                              org.forgerock.util.Function<? super M,​? extends N,​E0> funcMtoN,
                                                                                                                              org.forgerock.util.Function<? super N,​? extends M,​E1> funcNtoM)
        Returns a view of list whose values have been mapped to elements of type N using funcMtoN. The returned list supports all operations.
        Type Parameters:
        M - The type of elements contained in list.
        N - The type of elements contained in the returned list.
        E0 - The type of exception thrown by funcMtoN.
        E1 - The type of exception thrown by funcNtoM.
        Parameters:
        list - The list to be transformed.
        funcMtoN - A function which maps values of type M to values of type N. This function will be used when retrieving values from list.
        funcNtoM - A function which maps values of type N to values of type M. This function will be used when performing queries and adding values to list .
        Returns:
        A view of list whose values have been mapped to elements of type N using funcMtoN.