Example #1
0
  public FieldSpec buildRowIdColumnFieldSpec() {
    String name = "_rowid_";
    TypeName columnDefType = ParameterizedTypeName.get(Types.ColumnDef, TypeName.LONG.box());

    CodeBlock initializer;
    initializer =
        CodeBlock.builder()
            .add(
                "new $T($S, $T.class, $L, $L, $L, $L, $L, $L)",
                columnDefType,
                name,
                TypeName.LONG,
                false /* nullable */,
                true /* primary key */,
                false /* autoincrement */,
                true /* autoId */,
                false,
                false)
            .build();

    return FieldSpec.builder(columnDefType, name)
        .addModifiers(publicStaticFinal)
        .initializer(initializer)
        .build();
  }
Example #2
0
  static {
    javaToSqlite.put(TypeName.INT, "INTEGER");
    javaToSqlite.put(TypeName.INT.box(), "INTEGER");
    javaToSqlite.put(TypeName.LONG, "INTEGER");
    javaToSqlite.put(TypeName.LONG.box(), "INTEGER");
    javaToSqlite.put(TypeName.SHORT, "INTEGER");
    javaToSqlite.put(TypeName.SHORT.box(), "INTEGER");
    javaToSqlite.put(TypeName.BYTE, "INTEGER");
    javaToSqlite.put(TypeName.BYTE.box(), "INTEGER");

    javaToSqlite.put(TypeName.FLOAT, "REAL");
    javaToSqlite.put(TypeName.FLOAT.box(), "REAL");
    javaToSqlite.put(TypeName.DOUBLE, "REAL");
    javaToSqlite.put(TypeName.DOUBLE.box(), "REAL");

    javaToSqlite.put(ClassName.get(String.class), "TEXT");
    javaToSqlite.put(TypeName.CHAR, "TEXT");
    javaToSqlite.put(TypeName.CHAR.box(), "TEXT");
    javaToSqlite.put(ArrayTypeName.of(TypeName.BYTE), "BLOB");

    javaToSqlite.put(TypeName.BOOLEAN, "BOOLEAN");
    javaToSqlite.put(TypeName.BOOLEAN.box(), "BOOLEAN");

    javaToSqlite.put(Types.SingleRelation, "INTEGER"); // foreign key

    // TODO: date and time types?
  }
Example #3
0
 {
   put(ArrayTypeName.of(TypeName.BYTE), "getBlb");
   put(ArrayTypeName.of(TypeName.BYTE.box()), "getBlob");
   put(TypeName.BYTE, "getByt");
   put(TypeName.BYTE.box(), "getByte");
   put(TypeName.DOUBLE, "getDble");
   put(TypeName.DOUBLE.box(), "getDouble");
   put(TypeName.FLOAT, "getFlt");
   put(TypeName.FLOAT.box(), "getFloat");
   put(TypeName.INT, "getInt");
   put(TypeName.INT.box(), "getInteger");
   put(TypeName.LONG, "getLng");
   put(TypeName.LONG.box(), "getLong");
   put(TypeName.SHORT, "getShrt");
   put(TypeName.SHORT.box(), "getShort");
   put(TypeName.BOOLEAN.box(), "getBoolean");
   put(TypeName.BOOLEAN, "getBool");
   put(ClassName.get(String.class), "getString");
   put(ClassName.get(Blob.class), "getBlb");
 }
Example #4
0
 {
   put(ArrayTypeName.of(TypeName.BYTE), "getBlob");
   put(ArrayTypeName.of(TypeName.BYTE.box()), "getBlob");
   put(TypeName.BOOLEAN, "getInt");
   put(TypeName.BYTE, "getInt");
   put(TypeName.BYTE.box(), "getInt");
   put(TypeName.CHAR, "getString");
   put(TypeName.CHAR.box(), "getString");
   put(TypeName.DOUBLE, "getDouble");
   put(TypeName.DOUBLE.box(), "getDouble");
   put(TypeName.FLOAT, "getFloat");
   put(TypeName.FLOAT.box(), "getFloat");
   put(TypeName.INT, "getInt");
   put(TypeName.INT.box(), "getInt");
   put(TypeName.LONG, "getLong");
   put(TypeName.LONG.box(), "getLong");
   put(TypeName.SHORT, "getShort");
   put(TypeName.SHORT.box(), "getShort");
   put(ClassName.get(String.class), "getString");
   put(ClassName.get(Blob.class), "getBlob");
 }
Example #5
0
 {
   put(TypeName.BYTE, SQLiteHelper.INTEGER);
   put(TypeName.SHORT, SQLiteHelper.INTEGER);
   put(TypeName.INT, SQLiteHelper.INTEGER);
   put(TypeName.LONG, SQLiteHelper.INTEGER);
   put(TypeName.FLOAT, SQLiteHelper.REAL);
   put(TypeName.DOUBLE, SQLiteHelper.REAL);
   put(TypeName.BOOLEAN, SQLiteHelper.INTEGER);
   put(TypeName.CHAR, SQLiteHelper.TEXT);
   put(ArrayTypeName.of(TypeName.BYTE), SQLiteHelper.BLOB);
   put(TypeName.BYTE.box(), SQLiteHelper.INTEGER);
   put(TypeName.SHORT.box(), SQLiteHelper.INTEGER);
   put(TypeName.INT.box(), SQLiteHelper.INTEGER);
   put(TypeName.LONG.box(), SQLiteHelper.INTEGER);
   put(TypeName.FLOAT.box(), SQLiteHelper.REAL);
   put(TypeName.DOUBLE.box(), SQLiteHelper.REAL);
   put(TypeName.BOOLEAN.box(), SQLiteHelper.INTEGER);
   put(TypeName.CHAR.box(), SQLiteHelper.TEXT);
   put(ClassName.get(String.class), SQLiteHelper.TEXT);
   put(ArrayTypeName.of(TypeName.BYTE.box()), SQLiteHelper.BLOB);
   put(ArrayTypeName.of(TypeName.BYTE), SQLiteHelper.BLOB);
   put(ClassName.get(Blob.class), SQLiteHelper.BLOB);
 }