Class ImmutableKit

java.lang.Object
graphql.collect.ImmutableKit

public final class ImmutableKit extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> com.google.common.collect.ImmutableList<T>
    addToList(Collection<? extends T> existing, T newValue, T... extraValues)
    This constructs a new Immutable list from an existing collection and adds a new element to it.
    static <K, V> com.google.common.collect.ImmutableMap<K,V>
    addToMap(Map<K,V> existing, K newKey, V newVal)
     
    static <T> com.google.common.collect.ImmutableSet<T>
    addToSet(Collection<? extends T> existing, T newValue, T... extraValues)
    This constructs a new Immutable set from an existing collection and adds a new element to it.
    static <T> com.google.common.collect.ImmutableList<T>
    concatLists(List<T> l1, List<T> l2)
     
    static <T> com.google.common.collect.ImmutableList<T>
     
    static <K, V> com.google.common.collect.ImmutableMap<K,V>
     
    static <T, R> com.google.common.collect.ImmutableList<R>
    map(Collection<? extends T> collection, Function<? super T,? extends R> mapper)
    This is more efficient than `c.stream().map().collect()` because it does not create the intermediate objects needed for the flexible style.
    static <T, R> com.google.common.collect.ImmutableList<R>
    mapAndDropNulls(Collection<? extends T> collection, Function<? super T,? extends R> mapper)
    This will map a collection of items but drop any that are null from the input.
    static <T> com.google.common.collect.ImmutableList<T>
    nonNullCopyOf(Collection<T> collection)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ImmutableKit

      public ImmutableKit()
  • Method Details

    • emptyList

      public static <T> com.google.common.collect.ImmutableList<T> emptyList()
    • nonNullCopyOf

      public static <T> com.google.common.collect.ImmutableList<T> nonNullCopyOf(Collection<T> collection)
    • emptyMap

      public static <K, V> com.google.common.collect.ImmutableMap<K,V> emptyMap()
    • addToMap

      public static <K, V> com.google.common.collect.ImmutableMap<K,V> addToMap(Map<K,V> existing, K newKey, V newVal)
    • concatLists

      public static <T> com.google.common.collect.ImmutableList<T> concatLists(List<T> l1, List<T> l2)
    • map

      public static <T, R> com.google.common.collect.ImmutableList<R> map(Collection<? extends T> collection, Function<? super T,? extends R> mapper)
      This is more efficient than `c.stream().map().collect()` because it does not create the intermediate objects needed for the flexible style. Benchmarking has shown this to outperform `stream()`.
      Type Parameters:
      T - for two
      R - for result
      Parameters:
      collection - the collection to map
      mapper - the mapper function
      Returns:
      a map immutable list of results
    • mapAndDropNulls

      public static <T, R> com.google.common.collect.ImmutableList<R> mapAndDropNulls(Collection<? extends T> collection, Function<? super T,? extends R> mapper)
      This will map a collection of items but drop any that are null from the input. This is more efficient than `c.stream().map().collect()` because it does not create the intermediate objects needed for the flexible style. Benchmarking has shown this to outperform `stream()`.
      Type Parameters:
      T - for two
      R - for result
      Parameters:
      collection - the collection to map
      mapper - the mapper function
      Returns:
      a map immutable list of results
    • addToList

      @SafeVarargs public static <T> com.google.common.collect.ImmutableList<T> addToList(Collection<? extends T> existing, T newValue, T... extraValues)
      This constructs a new Immutable list from an existing collection and adds a new element to it.
      Type Parameters:
      T - for two
      Parameters:
      existing - the existing collection
      newValue - the new value to add
      extraValues - more values to add
      Returns:
      an Immutable list with the extra items.
    • addToSet

      @SafeVarargs public static <T> com.google.common.collect.ImmutableSet<T> addToSet(Collection<? extends T> existing, T newValue, T... extraValues)
      This constructs a new Immutable set from an existing collection and adds a new element to it.
      Type Parameters:
      T - for two
      Parameters:
      existing - the existing collection
      newValue - the new value to add
      extraValues - more values to add
      Returns:
      an Immutable Set with the extra items.