Class ListBuilders


  • public final class ListBuilders
    extends Object
    Helper functions for building lists with examples.
    • Method Detail

      • buildListOfAtLeastOne

        @SafeVarargs
        public static <T> List<T> buildListOfAtLeastOne​(T first,
                                                        T... more)
        Builds a list with at least one example.
        Type Parameters:
        T - The type of example.
        Parameters:
        first - The first example.
        more - Zero or more additional examples.
        Returns:
        A list with at least one example.
      • buildListOfAtLeastTwo

        @SafeVarargs
        public static <T> List<T> buildListOfAtLeastTwo​(T first,
                                                        T second,
                                                        T... more)
        Builds a list with at least two examples.
        Type Parameters:
        T - The type of example.
        Parameters:
        first - The first example.
        second - The second example.
        more - Zero or more additional examples.
        Returns:
        A list with at least two examples.
      • fromIterable

        public static <T> List<T> fromIterable​(Iterable<T> iterable)
        Builds a list from the elements of an Iterable.
        Type Parameters:
        T - The type of the elements.
        Parameters:
        iterable - The iterable containing the elements.
        Returns:
        A list with the elements of the Iterable.
      • listContainsDuplicates

        public static <T> boolean listContainsDuplicates​(List<T> list)
        Determines whether a list contains the same example more than once.
        Type Parameters:
        T - The type of example.
        Parameters:
        list - The list that may or may not contain duplicates.
        Returns:
        Whether the given list contains duplicates.