Class ResultSetResultIterable<T>

  • All Implemented Interfaces:
    java.lang.Iterable<T>, ResultIterable<T>

    public class ResultSetResultIterable<T>
    extends java.lang.Object
    implements ResultIterable<T>
    • Field Detail

      • resultSetSupplier

        private final java.util.function.Supplier<java.sql.ResultSet> resultSetSupplier
    • Constructor Detail

      • ResultSetResultIterable

        public ResultSetResultIterable​(RowMapper<T> mapper,
                                       StatementContext ctx,
                                       java.util.function.Supplier<java.sql.ResultSet> resultSetSupplier)
    • Method Detail

      • iterator

        public ResultIterator<T> iterator()
        Description copied from interface: ResultIterable
        Stream all the rows of the result set out with an Iterator. The Iterator must be closed to release database resources.
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Specified by:
        iterator in interface ResultIterable<T>
        Returns:
        the results as a streaming Iterator
      • collectInto

        public <R extends java.util.Collection<? super T>> R collectInto​(java.lang.reflect.Type containerType)
        Description copied from interface: ResultIterable
        Collect the results into a container type.
        Specified by:
        collectInto in interface ResultIterable<T>
        Parameters:
        containerType - A Type object that must describe a container type
        Returns:
        A new collection implementing the container type with all results inserted
      • collectIntoList

        public java.util.List<T> collectIntoList()
        Description copied from interface: ResultIterable
        Returns results in a List. The implementation of the list can be changed by registering a Collector:

        
             jdbi.getConfig(JdbiCollectors.class).registerCollector(List.class, Collectors.toCollection(LinkedList::new));
         
        or
        
             handle.registerCollector(List.class, Collectors.toCollection(LinkedList::new));
         

        If no collector is registered, then this method behaves like ResultIterable.list().
        Specified by:
        collectIntoList in interface ResultIterable<T>
        Returns:
        results in a List
        See Also:
        ResultIterable.list(), ResultIterable.toCollection(Supplier)
      • collectIntoSet

        public java.util.Set<T> collectIntoSet()
        Description copied from interface: ResultIterable
        Returns results in a Set. The implementation of the set can be changed by registering a Collector:

        
             jdbi.getConfig(JdbiCollectors.class).registerCollector(Set.class, Collectors.toCollection(LinkedHashSet::new));
         
        or
        
             handle.registerCollector(Set.class, Collectors.toCollection(LinkedHashSet::new));
         

        If no collector is registered, then this method behaves like ResultIterable.set().
        Specified by:
        collectIntoSet in interface ResultIterable<T>
        Returns:
        results in a Set
        See Also:
        ResultIterable.set(), ResultIterable.toCollection(Supplier)