Package org.jdbi.v3.core.internal
Class IterableLike
- java.lang.Object
-
- org.jdbi.v3.core.internal.IterableLike
-
public class IterableLike extends java.lang.ObjectImplements 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).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classIterableLike.PrimitiveArrayIterator
-
Constructor Summary
Constructors Modifier Constructor Description privateIterableLike()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Optional<java.lang.reflect.Type>elementTypeOf(java.lang.Object iterable)Given an iterable-like object, try to determine its static (i.e, without looking at contents) element type.static java.util.Optional<java.lang.reflect.Type>elementTypeOf(java.lang.reflect.Type type)Given an iterable-like type, try to determine its static (i.e, without looking at contents) element type.private static java.lang.StringgetTypeWarning(java.lang.Class<?> type)static booleanisIterable(java.lang.Object maybeIterable)Returns true if the given object is iterable.static java.lang.Iterable<java.lang.Object>iterable(java.lang.Object iterable)Given an iterable object (which may be a iterator, iterable, primitive or reference array), return an iterable over its (possibly boxed) elements.static java.util.Iterator<java.lang.Object>of(java.lang.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 java.util.stream.Stream<java.lang.Object>stream(java.lang.Object iterable)Given an iterable object (which may be a iterator, iterable, primitive or reference array), return aStreamover its (possibly boxed) elements.static java.util.List<java.lang.Object>toList(java.lang.Object iterable)Collect an iterable-like into a newly allocated ArrayList.
-
-
-
Method Detail
-
isIterable
public static boolean isIterable(java.lang.Object maybeIterable)
Returns true if the given object is iterable.- Parameters:
maybeIterable- the object that might be iterable.- Returns:
- whether
IterableLikecan iterate over the given object.
-
of
public static java.util.Iterator<java.lang.Object> of(java.lang.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 java.util.Optional<java.lang.reflect.Type> elementTypeOf(java.lang.Object iterable)
Given an iterable-like object, try to determine its static (i.e, without looking at contents) element type.
-
elementTypeOf
public static java.util.Optional<java.lang.reflect.Type> elementTypeOf(java.lang.reflect.Type type)
Given an iterable-like type, try to determine its static (i.e, without looking at contents) element type.
-
stream
public static java.util.stream.Stream<java.lang.Object> stream(java.lang.Object iterable)
Given an iterable object (which may be a iterator, iterable, primitive or reference array), return aStreamover its (possibly boxed) elements.- Returns:
- a stream of the given array's elements
-
iterable
public static java.lang.Iterable<java.lang.Object> iterable(java.lang.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 java.util.List<java.lang.Object> toList(java.lang.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
-
getTypeWarning
private static java.lang.String getTypeWarning(java.lang.Class<?> type)
-
-