Class CompatUtil

java.lang.Object
io.github.douira.glsl_transformer.util.CompatUtil

public class CompatUtil extends Object
This class contains utility methods that allow maintaining Java 8 API compatability. (Even though the code is at Java 16 source compatability)
  • Constructor Details

    • CompatUtil

      public CompatUtil()
  • Method Details

    • repeat

      public static String repeat(String str, int n)
      Repeats the given string a number of times. From https://stackoverflow.com/a/1235213
      Parameters:
      str - The string to repeat
      n - The number of times to repeat the string
      Returns:
      The given string repeated n times
    • setOf

      @SafeVarargs public static <T> Set<T> setOf(T... items)
      Creates a HashSet that contains the given items. The heap pollution warning is suppressed as it is in Arrays.
      Type Parameters:
      T - The type of the items
      Parameters:
      items - The items to add to the set
      Returns:
      The set with the given items
    • setOf

      public static <T> Set<T> setOf(T item)
      Creates a HashSet that contains the given item.
      Type Parameters:
      T - The type of the item
      Parameters:
      item - The item to add to the set
      Returns:
      The set with the given item
    • setOf

      public static <T> Set<T> setOf(T itemA, T itemB)
      Creates a HashSet that contains the given items.
      Type Parameters:
      T - The type of the items
      Parameters:
      itemA - The first item to add to the set
      itemB - The second item to add to the set
      Returns:
      The set with the given items
    • listOf

      @SafeVarargs public static <T> List<T> listOf(T... items)
      Creates an ArrayList that contains the given items in the same order. This is likely cheaper for making a collection than using setOf(Object...).
      Type Parameters:
      T - The type of the items
      Parameters:
      items - The items to create the list out of
      Returns:
      The list with the given items