diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-21 22:24:41 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-21 22:24:41 +0100 |
commit | a63ec924e5440b17434ecc91e84d1419ae39ef2a (patch) | |
tree | 933459602e0fcfd76a5f0d98d5465dc9f4aabed9 /src/main/java/io/trygvis/esper/testing/sql | |
parent | e7b1958ce5e93ead2d7d3c74eabe00a4186a048a (diff) | |
download | esper-testing-a63ec924e5440b17434ecc91e84d1419ae39ef2a.tar.gz esper-testing-a63ec924e5440b17434ecc91e84d1419ae39ef2a.tar.bz2 esper-testing-a63ec924e5440b17434ecc91e84d1419ae39ef2a.tar.xz esper-testing-a63ec924e5440b17434ecc91e84d1419ae39ef2a.zip |
o Adding a sequence number to jenkins_build.
o Making the table poller poll based on a sequence number instead.
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing/sql')
-rw-r--r-- | src/main/java/io/trygvis/esper/testing/sql/ResultSetF.java | 18 | ||||
-rw-r--r-- | src/main/java/io/trygvis/esper/testing/sql/SqlOption.java | 26 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/sql/ResultSetF.java b/src/main/java/io/trygvis/esper/testing/sql/ResultSetF.java new file mode 100644 index 0000000..e5a9e4e --- /dev/null +++ b/src/main/java/io/trygvis/esper/testing/sql/ResultSetF.java @@ -0,0 +1,18 @@ +package io.trygvis.esper.testing.sql; + +import java.sql.*; + +public class ResultSetF { + public static final SqlF<ResultSet, Integer> getInt = new SqlF<ResultSet, Integer>() { + public Integer apply(ResultSet rs) throws SQLException { + return rs.getInt(1); + } + }; + + public static final SqlF<ResultSet, Integer> getInteger = new SqlF<ResultSet, Integer>() { + public Integer apply(ResultSet rs) throws SQLException { + int i = rs.getInt(1); + return rs.wasNull() ? null : i; + } + }; +} diff --git a/src/main/java/io/trygvis/esper/testing/sql/SqlOption.java b/src/main/java/io/trygvis/esper/testing/sql/SqlOption.java index 058435e..288735a 100644 --- a/src/main/java/io/trygvis/esper/testing/sql/SqlOption.java +++ b/src/main/java/io/trygvis/esper/testing/sql/SqlOption.java @@ -43,6 +43,16 @@ public abstract class SqlOption<A> { return !isSome(); } + public abstract A getOrElse(A a); + + public static <A> SqlOption<A> fromNull(A a) { + if (a != null) { + return some(a); + } else { + return none(); + } + } + // ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- @@ -59,6 +69,14 @@ public abstract class SqlOption<A> { public boolean isSome() { return false; } + + public A getOrElse(A a) { + return a; + } + + public String toString() { + return "None"; + } } private static class Some<A> extends SqlOption<A> { @@ -79,5 +97,13 @@ public abstract class SqlOption<A> { public boolean isSome() { return true; } + + public A getOrElse(A a) { + return this.a; + } + + public String toString() { + return "Some(" + a + ")"; + } } } |