Class FL

java.lang.Object
org.fastily.jwiki.util.FL

public final class FL
extends Object
Static Collections and Stream utilities.
Author:
Fastily
  • Method Details

    • toAL

      public static <T1> ArrayList<T1> toAL​(Stream<T1> s)
      Collects the elements of a Stream into an ArrayList.
      Type Parameters:
      T1 - The resulting ArrayList will be created containing this type.
      Parameters:
      s - The target Stream
      Returns:
      An ArrayList containing the elements of the s
    • toSet

      public static <T1> HashSet<T1> toSet​(Stream<T1> s)
      Collects the elements of a Stream into a HashSet.
      Type Parameters:
      T1 - The resulting HashSet will be created containing this type.
      Parameters:
      s - The target Stream
      Returns:
      A HashSet containing the elements of the s
    • toHM

      public static <K,​ V,​ T1> HashMap<K,​V> toHM​(Stream<T1> s, Function<T1,​K> keyMapper, Function<T1,​V> valueMapper)
      Creates a HashMap from a Stream. If duplicate keys are encountered, only the latest value will be retained.
      Type Parameters:
      K - The type of the key in the resulting HashMap.
      V - The type of the value in the resulting HashMap.
      T1 - The type of Object in the Stream.
      Parameters:
      s - The Stream to reduce into a Map.
      keyMapper - The function mapping each element of s to a key in the resulting Map.
      valueMapper - The function mapping each element of s to a value in the resulting Map.
      Returns:
      A HashMap, as specified.
    • toSAL

      public static ArrayList<String> toSAL​(String... strings)
      Shortcut to turn an array of String objects into an ArrayList of String objects.
      Parameters:
      strings - The list of Strings to put into the resulting ArrayList.
      Returns:
      The array as an ArrayList
    • toSHS

      public static HashSet<String> toSHS​(String... strings)
      Shortcut to turn an array of String objects into a HashSet of String objects.
      Parameters:
      strings - The list of Strings to put into the resulting HashSet.
      Returns:
      The array as a HashSet
    • mapToList

      public static <T1,​ T2> ArrayList<Tuple<T1,​T2>> mapToList​(Map<T1,​T2> h)
      Extracts each key-value pair from a Map and return the pairs as an ArrayList of Tuple objects.
      Type Parameters:
      T1 - The key type of the Map
      T2 - The value type of the Map
      Parameters:
      h - The Map to work with
      Returns:
      An ArrayList of Tuples extracted from h.
    • pMap

      public static HashMap<String,​String> pMap​(String... sl)
      Creates a HashMap with String keys and values. Pass in each pair and value (in that order) into sl. This will be one pair entered into resulting HashMap.
      Parameters:
      sl - The list of elements to turn into a HashMap.
      Returns:
      The resulting HashMap, or null if you specified an odd number of elements.
    • streamFrom

      public static <T> Stream<T> streamFrom​(Iterable<T> i)
      Creates a Stream from an Iterable.
      Type Parameters:
      T - i's type
      Parameters:
      i - The Iterable to make into a Stream
      Returns:
      The Stream
    • pipeFence

      public static String pipeFence​(Collection<String> planks)
      Makes a fence with pipe characters as posts
      Parameters:
      planks - The planks to use, in order.
      Returns:
      A String with the specified planks and pipe characters as posts
    • containsNull

      public static <T> boolean containsNull​(Collection<T> l)
      Check if a Collection contains null.
      Type Parameters:
      T - The type of l
      Parameters:
      l - The Collection to check.
      Returns:
      True if there are no null elements in the Collection.