All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mperry.fg.SqlExtensionJava Maven / Gradle / Ivy

There is a newer version: 0.8
Show newest version
package com.github.mperry.fg;

import fj.F;
import fj.P1;
import fj.data.Stream;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by MarkPerry on 2/02/14.
 */
public class SqlExtensionJava {

    static  Stream toStream(final ResultSet rs, final F f)
            throws SQLException {
        return toStream(rs).map(f);
    }

    static  Stream toStream(final ResultSet rs) throws SQLException {
        boolean b = rs.next();
        if (!b) {
            return Stream.nil();
        } else {
            return Stream.cons(rs, new P1>() {
                @Override
                public Stream _1() {
                    try {
                        return toStream(rs);
                    } catch (SQLException e) {
                        e.printStackTrace();
                        return Stream.nil();
                    }
                }
            });
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy