Class IterableLike

java.lang.Object
org.jdbi.v3.core.internal.IterableLike

public class IterableLike extends Object
Implements Iterator methods for unidentified arrays and Iterable things that do not have a more specific type than Object. Note that its elements will be returned as Object, primitives included (will be autoboxed).
  • Method Summary

    Modifier and Type
    Method
    Description
    static Optional<Type>
    Given an iterable-like object, try to determine its static (i.e, without looking at contents) element type.
    static Optional<Type>
    Given an iterable-like type, try to determine its static (i.e, without looking at contents) element type.
    static boolean
    isIterable(Object maybeIterable)
    Returns true if the given object is iterable.
    iterable(Object iterable)
    Given an iterable object (which may be a iterator, iterable, primitive or reference array), return an iterable over its (possibly boxed) elements.
    of(Object iterable)
    Given an iterable object (which may be a iterator, iterable, primitive or reference array), return an iterator over its (possibly boxed) elements.
    static Stream<Object>
    stream(Object iterable)
    Given an iterable object (which may be a iterator, iterable, primitive or reference array), return a Stream over its (possibly boxed) elements.
    static List<Object>
    toList(Object iterable)
    Collect an iterable-like into a newly allocated ArrayList.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isIterable

      public static boolean isIterable(Object maybeIterable)
      Returns true if the given object is iterable.
      Parameters:
      maybeIterable - the object that might be iterable.
      Returns:
      whether IterableLike can iterate over the given object.
    • of

      public static Iterator<Object> of(Object iterable)
      Given an iterable object (which may be a iterator, iterable, primitive or reference array), return an iterator over its (possibly boxed) elements.
      Parameters:
      iterable - the iterable-like
      Returns:
      an iterator of the given array's elements
    • elementTypeOf

      public static Optional<Type> elementTypeOf(Object iterable)
      Given an iterable-like object, try to determine its static (i.e, without looking at contents) element type.
    • elementTypeOf

      public static Optional<Type> elementTypeOf(Type type)
      Given an iterable-like type, try to determine its static (i.e, without looking at contents) element type.
    • stream

      public static Stream<Object> stream(Object iterable)
      Given an iterable object (which may be a iterator, iterable, primitive or reference array), return a Stream over its (possibly boxed) elements.
      Returns:
      a stream of the given array's elements
    • iterable

      public static Iterable<Object> iterable(Object iterable)
      Given an iterable object (which may be a iterator, iterable, primitive or reference array), return an iterable over its (possibly boxed) elements.
      Parameters:
      iterable - the iterable-like to create a real Iterable for
      Returns:
      the created Iterable
    • toList

      public static List<Object> toList(Object iterable)
      Collect an iterable-like into a newly allocated ArrayList.
      Parameters:
      iterable - the iterable-like to collect
      Returns:
      a new list with the elements