Class CollectionTools

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

@NullMarked public final class CollectionTools extends Object
Collection Tools.

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

The internal methods combineAndMap and combineAndMapVarargs are implementation details and not part of the public API.

Since:
1.0
Author:
Erik C. Thauvin
  • Method Details

    • combine

      @SafeVarargs public static <T> List<T> combine(@Nullable Collection<T> @Nullable ... collections)
      Combines multiple collections into a single list, ignoring any null collections, empty collections, or null elements.

      Returns an unmodifiable list. Returns an empty list if the input array is null.

      Type Parameters:
      T - the element type
      Parameters:
      collections - the collections to combine, may be null
      Returns:
      an unmodifiable list containing all non-null elements
      Since:
      1.0
    • combine

      @SafeVarargs public static <T> List<T> combine(@Nullable T @Nullable ... elements)
      Combines varargs elements into a single list, ignoring any null elements.

      Returns an unmodifiable list. Returns an empty list if the input array is null.

      Type Parameters:
      T - the element type
      Parameters:
      elements - the elements to combine, may be null
      Returns:
      an unmodifiable list containing all non-null elements
      Since:
      1.0
    • combineFilesToPaths

      @SafeVarargs public static List<Path> combineFilesToPaths(@Nullable Collection<File> @Nullable ... collections)
      Combines multiple File collections into a list of Path objects.

      Null collections, empty collections, and null elements are ignored. Returns an unmodifiable list.

      Parameters:
      collections - the file collections to combine
      Returns:
      an unmodifiable list of paths
      Since:
      1.0
    • combineFilesToPaths

      public static List<Path> combineFilesToPaths(@Nullable File @Nullable ... files)
      Combines varargs File elements into a list of Path objects.

      Null elements are ignored. Returns an unmodifiable list.

      Parameters:
      files - the files to combine
      Returns:
      an unmodifiable list of paths
      Since:
      1.0
    • combineFilesToStrings

      @SafeVarargs public static List<String> combineFilesToStrings(@Nullable Collection<File> @Nullable ... collections)
      Combines multiple File collections into a list of normalized absolute path strings.

      Uses Path.toAbsolutePath() and Path.normalize(). Returns an unmodifiable list.

      Parameters:
      collections - the file collections to combine
      Returns:
      an unmodifiable list of normalized path strings
      Since:
      1.0
    • combineFilesToStrings

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

      Uses Path.toAbsolutePath() and Path.normalize(). Returns an unmodifiable list.

      Parameters:
      files - the files to combine
      Returns:
      an unmodifiable list of normalized path strings
      Since:
      1.0
    • combinePathsToFiles

      @SafeVarargs public static List<File> combinePathsToFiles(@Nullable Collection<Path> @Nullable ... collections)
      Combines multiple Path collections into a list of File objects.

      Null collections, empty collections, and null elements are ignored. Returns an unmodifiable list.

      Parameters:
      collections - the path collections to combine
      Returns:
      an unmodifiable list of files
      Since:
      1.0
    • combinePathsToFiles

      public static List<File> combinePathsToFiles(@Nullable Path @Nullable ... paths)
      Combines varargs Path elements into a list of File objects.

      Null elements are ignored. Returns an unmodifiable list.

      Parameters:
      paths - the paths to combine
      Returns:
      an unmodifiable list of files
      Since:
      1.0
    • combinePathsToStrings

      @SafeVarargs public static List<String> combinePathsToStrings(@Nullable Collection<Path> @Nullable ... collections)
      Combines multiple Path collections into a list of normalized absolute path strings.

      Uses Path.toAbsolutePath() and Path.normalize(). Returns an unmodifiable list.

      Parameters:
      collections - the path collections to combine
      Returns:
      an unmodifiable list of normalized path strings
      Since:
      1.0
    • combinePathsToStrings

      public static List<String> combinePathsToStrings(@Nullable Path @Nullable ... paths)
      Combines varargs Path elements into a list of normalized absolute path strings.

      Uses Path.toAbsolutePath() and Path.normalize(). Returns an unmodifiable list.

      Parameters:
      paths - the paths to combine
      Returns:
      an unmodifiable list of normalized path strings
      Since:
      1.0
    • combineStringsToFiles

      @SafeVarargs public static List<File> combineStringsToFiles(@Nullable Collection<String> @Nullable ... collections)
      Combines multiple string collections into a list of File objects.

      Null collections, empty collections, and null elements are ignored. Returns an unmodifiable list.

      Parameters:
      collections - the string collections to combine
      Returns:
      an unmodifiable list of files
      Since:
      1.0
    • combineStringsToFiles

      public static List<File> combineStringsToFiles(@Nullable String @Nullable ... strings)
      Combines varargs string elements into a list of File objects.

      Null elements are ignored. Returns an unmodifiable list.

      Parameters:
      strings - the strings to combine
      Returns:
      an unmodifiable list of files
      Since:
      1.0
    • combineStringsToPaths

      @SafeVarargs public static List<Path> combineStringsToPaths(@Nullable Collection<String> @Nullable ... collections)
      Combines multiple string collections into a list of Path objects.

      Null collections, empty collections, and null elements are ignored. Returns an unmodifiable list.

      Parameters:
      collections - the string collections to combine
      Returns:
      an unmodifiable list of paths
      Since:
      1.0
    • combineStringsToPaths

      public static List<Path> combineStringsToPaths(@Nullable String @Nullable ... strings)
      Combines varargs string elements into a list of Path objects.

      Null elements are ignored. Returns an unmodifiable list.

      Parameters:
      strings - the strings to combine
      Returns:
      an unmodifiable list of paths
      Since:
      1.0