Class CollectionTools

java.lang.Object
rife.bld.extension.tools.CollectionTools

public final class CollectionTools extends Object
Collection Tools.

All public methods accept null varargs arrays or null collection references and will return an empty list in those cases. Individual null elements within collections or varargs are also silently ignored.

combineAndMap(Collection[], Function) and combineAndMapVarargs(Object[], Function) are intentionally package-private implementation details and are not part of the public API.

Since:
1.0
  • Method Details

    • combine

      @SafeVarargs public static <T> List<T> combine(@Nullable @Nullable Collection<T>... collections)
      Combines multiple collections into a single list, ignoring any null collections or null elements.
      Type Parameters:
      T - the type of elements
      Parameters:
      collections - the collections to combine; may be null
      Returns:
      a new list containing all non-null elements from all non-null collections, or an empty list if collections is null
      Since:
      1.0
    • combine

      @SafeVarargs public static <T> List<T> combine(@Nullable @Nullable T... elements)
      Combines varargs elements into a single list, ignoring any null elements.
      Type Parameters:
      T - the type of elements
      Parameters:
      elements - the elements to combine; may be null, and individual elements may also be null (they are silently dropped)
      Returns:
      a new list containing all non-null elements, or an empty list if elements is null
      Since:
      1.0
    • combineFilesToPaths

      @SafeVarargs public static List<Path> combineFilesToPaths(@Nullable @Nullable Collection<File>... collections)
      Combines multiple File collections into a single list of Path objects, ignoring any null collections or null elements.
      Parameters:
      collections - the collections of files to combine; may be null
      Returns:
      a new list of Path objects for all non-null files from all non-null collections, or an empty list if collections is null
      Since:
      1.0
      See Also:
    • combineFilesToPaths

      public static List<Path> combineFilesToPaths(@Nullable @Nullable File... files)
      Combines varargs File elements into a single list of Path objects, ignoring any null elements.
      Parameters:
      files - the files to combine; may be null, and individual elements may also be null (they are silently dropped)
      Returns:
      a new list of Path objects for all non-null files, or an empty list if files is null
      Since:
      1.0
      See Also:
    • combineFilesToStrings

      @SafeVarargs public static List<String> combineFilesToStrings(@Nullable @Nullable Collection<File>... collections)
      Combines multiple File collections into a single list of normalized absolute path strings, ignoring any null collections or null elements.

      Uses Path.toAbsolutePath() followed by Path.normalize() to resolve relative paths and eliminate redundant .. and . segments. This is more robust than File.getAbsolutePath(), which does not normalize the path.

      Parameters:
      collections - the collections of files to combine; may be null
      Returns:
      a new list of normalized absolute path strings for all non-null files from all non-null collections, or an empty list if collections is null
      Since:
      1.0
      See Also:
    • combineFilesToStrings

      public static List<String> combineFilesToStrings(@Nullable @Nullable File... files)
      Combines varargs File elements into a single list of normalized absolute path strings, ignoring any null elements.

      Uses Path.toAbsolutePath() followed by Path.normalize() to resolve relative paths and eliminate redundant .. and . segments. This is more robust than File.getAbsolutePath(), which does not normalize the path.

      Parameters:
      files - the files to combine; may be null, and individual elements may also be null (they are silently dropped)
      Returns:
      a new list of normalized absolute path strings for all non-null files, or an empty list if files is null
      Since:
      1.0
      See Also:
    • combinePathsToFiles

      @SafeVarargs public static List<File> combinePathsToFiles(@Nullable @Nullable Collection<Path>... collections)
      Combines multiple Path collections into a single list of File objects, ignoring any null collections or null elements.
      Parameters:
      collections - the collections of paths to combine; may be null
      Returns:
      a new list of File objects for all non-null paths from all non-null collections, or an empty list if collections is null
      Since:
      1.0
      See Also:
    • combinePathsToFiles

      public static List<File> combinePathsToFiles(@Nullable @Nullable Path... paths)
      Combines varargs Path elements into a single list of File objects, ignoring any null elements.
      Parameters:
      paths - the paths to combine; may be null, and individual elements may also be null (they are silently dropped)
      Returns:
      a new list of File objects for all non-null paths, or an empty list if paths is null
      Since:
      1.0
      See Also:
    • combinePathsToStrings

      @SafeVarargs public static List<String> combinePathsToStrings(@Nullable @Nullable Collection<Path>... collections)
      Combines multiple Path collections into a single list of path strings, ignoring any null collections or null elements.
      Parameters:
      collections - the collections of paths to combine; may be null
      Returns:
      a new list of path strings for all non-null paths from all non-null collections, or an empty list if collections is null
      Since:
      1.0
      See Also:
    • combinePathsToStrings

      public static List<String> combinePathsToStrings(@Nullable @Nullable Path... paths)
      Combines varargs Path elements into a single list of path strings, ignoring any null elements.
      Parameters:
      paths - the paths to combine; may be null, and individual elements may also be null (they are silently dropped)
      Returns:
      a new list of path strings for all non-null paths, or an empty list if paths is null
      Since:
      1.0
      See Also:
    • combineStringsToFiles

      @SafeVarargs public static List<File> combineStringsToFiles(@Nullable @Nullable Collection<String>... collections)
      Combines multiple string collections into a single list of File objects, ignoring any null collections or null elements.
      Parameters:
      collections - the collections of strings to combine; may be null
      Returns:
      a new list of File objects for all non-null strings from all non-null collections, or an empty list if collections is null
      Since:
      1.0
      See Also:
    • combineStringsToFiles

      public static List<File> combineStringsToFiles(@Nullable @Nullable String... strings)
      Combines varargs string elements into a single list of File objects, ignoring any null elements.
      Parameters:
      strings - the strings to combine; may be null, and individual elements may also be null (they are silently dropped)
      Returns:
      a new list of File objects for all non-null strings, or an empty list if strings is null
      Since:
      1.0
      See Also:
    • combineStringsToPaths

      @SafeVarargs public static List<Path> combineStringsToPaths(@Nullable @Nullable Collection<String>... collections)
      Combines multiple string collections into a single list of Path objects, ignoring any null collections or null elements.
      Parameters:
      collections - the collections of strings to combine; may be null
      Returns:
      a new list of Path objects for all non-null strings from all non-null collections, or an empty list if collections is null
      Since:
      1.0
      See Also:
    • combineStringsToPaths

      public static List<Path> combineStringsToPaths(@Nullable @Nullable String... strings)
      Combines varargs string elements into a single list of Path objects, ignoring any null elements.
      Parameters:
      strings - the strings to combine; may be null, and individual elements may also be null (they are silently dropped)
      Returns:
      a new list of Path objects for all non-null strings, or an empty list if strings is null
      Since:
      1.0
      See Also: