com.github.mperry.fg.SqlExtensionJava Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionalgroovy-main Show documentation
Show all versions of functionalgroovy-main Show documentation
FunctionalGroovy enhances FunctionalJava for Groovy
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