Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add int type

  • Loading branch information...
commit dec87dd596c38ac07ad5dbbcd009d30243327c98 1 parent a5faa28
@kazuho authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 net/examp1e/picoorm/types/IntegerType.java
View
37 net/examp1e/picoorm/types/IntegerType.java
@@ -0,0 +1,37 @@
+package net.examp1e.picoorm.types;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import net.examp1e.picoorm.*;
+
+public class IntegerType extends AbstractType<IntegerType, Integer> {
+
+ final static Binder<Integer> BINDER = new Binder<Integer>() {
+ @Override
+ public void bind(PreparedStatement ps, int parameterIndex, Integer value) throws SQLException {
+ if (value != null)
+ ps.setInt(parameterIndex, value);
+ else
+ ps.setNull(parameterIndex, Types.INTEGER);
+ }
+ };
+
+ @Override
+ protected Binder<Integer> getBinder() {
+ return BINDER;
+ }
+
+ public static class Predicate<Row extends AbstractRow> extends AbstractType.Predicate<Predicate<Row>, Row, Integer> {
+ @Override
+ protected Parameter<Integer> createParameter(Integer value) {
+ return new Parameter<Integer>(value) {
+ protected Binder<Integer> getBinder() {
+ return BINDER;
+ }
+ };
+ }
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.