Class BuiltInCollectorFactory

java.lang.Object
org.jdbi.v3.core.collector.BuiltInCollectorFactory
All Implemented Interfaces:
CollectorFactory

@Deprecated public class BuiltInCollectorFactory extends Object implements CollectorFactory
Deprecated.
will be replaced by plugin
Provides Collectors for built in JDK container types.

Supported container types:

  • java.util.Optional<T> (throws an exception if more than one row in result)
  • java.util.Collection<T>
  • java.util.List<T>
  • java.util.ArrayList<T>
  • java.util.LinkedList<T>
  • java.util.concurrent.CopyOnWriteArrayList<T>
  • java.util.Set<T>
  • java.util.HashSet<T>
  • java.util.LinkedHashSet<T>
  • java.util.SortedSet<T>
  • java.util.TreeSet<T>

Supported Map types - for rows mapped to Map.Entry<K, V>

  • java.util.Map<K, V>
  • java.util.HashMap<K, V>
  • java.util.LinkedHashMap<K, V>
  • java.util.SortedMap<K, V>
  • java.util.TreeMap<K, V>
  • java.util.concurrent.ConcurrentMap<K, V>
  • java.util.concurrent.ConcurrentHashMap<K, V>
  • java.util.WeakHashMap<K, V>
  • Constructor Details

    • BuiltInCollectorFactory

      public BuiltInCollectorFactory()
      Deprecated.
  • Method Details

    • accepts

      public boolean accepts(Type containerType)
      Deprecated.
      Description copied from interface: CollectorFactory
      Accept a Type as a collector.
      Specified by:
      accepts in interface CollectorFactory
      Parameters:
      containerType - the container type.
      Returns:
      whether this factory can produce a collector for the given container type.
    • elementType

      public Optional<Type> elementType(Type containerType)
      Deprecated.
      Description copied from interface: CollectorFactory
      Returns the element type for a given container type.
      Specified by:
      elementType in interface CollectorFactory
      Parameters:
      containerType - the container type.
      Returns:
      the container element type if it can be discovered through reflection; empty otherwise.
      See Also:
    • build

      public Collector<?,?,?> build(Type containerType)
      Deprecated.
      Description copied from interface: CollectorFactory
      Creates a collector for a given container type.
      Specified by:
      build in interface CollectorFactory
      Parameters:
      containerType - the container type.
      Returns:
      a Collector for the given container type.
      See Also:
    • toOptional

      @Deprecated public static <T> Collector<T,?,Optional<T>> toOptional()
      Deprecated.
      Returns a Collector that accumulates 0 or 1 input elements into an Optional<T>. The returned collector will throw IllegalStateException whenever 2 or more elements are present in a stream.
      Type Parameters:
      T - the collected type
      Returns:
      a Collector which collects 0 or 1 input elements into an Optional<T>.
    • toMap

      @Deprecated public static <K, V, M extends Map<K, V>> Collector<Map.Entry<K,V>,?,M> toMap(Supplier<M> mapFactory)
      Deprecated.
      Returns a Collector that accumulates Map.Entry<K, V> input elements into a map of the supplied type. The returned collector will throw IllegalStateException whenever a set of input elements contains multiple entries with the same key.
      Type Parameters:
      K - the type of map keys
      V - the type of map values
      M - the type of the resulting Map
      Parameters:
      mapFactory - a Supplier which returns a new, empty Map of the appropriate type.
      Returns:
      a Collector which collects map entry elements into a Map, in encounter order.