@Test public void testCreateTableDefinition() { String expectedSql = "CREATE TABLE IF NOT EXISTS `FullTestModel` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, " + "`booleanField` INTEGER, `dateField` INTEGER, `doubleField` REAL, `intField` INTEGER, `stringField` " + "TEXT COLLATE BINARY UNIQUE ON CONFLICT IGNORE, UNIQUE (`dateField`, `doubleField`) ON CONFLICT FAIL, " + "UNIQUE (`booleanField`, `intField`) ON CONFLICT ROLLBACK);"; TableInfo testModelTableInfo = ReActiveAndroid.getTableInfo(FullTestModel.class); assertEquals(expectedSql, SQLiteUtils.createTableDefinition(testModelTableInfo)); }
@NonNull public static String createTableDefinition(TableInfo tableInfo) { ArrayList<String> definitions = new ArrayList<>(); for (Field field : tableInfo.getColumnFields()) { String definition = createColumnDefinition(tableInfo, field); if (!TextUtils.isEmpty(definition)) { definitions.add(definition); } } definitions.addAll(createUniqueDefinition(tableInfo)); return String.format("CREATE TABLE IF NOT EXISTS `%s` (%s);", tableInfo.getTableName(), TextUtils.join(", ", definitions)); }
SQLiteUtils { @NonNull public static String createTableDefinition(TableInfo tableInfo) { ArrayList<String> definitions = new ArrayList<>(); for (Field field : tableInfo.getColumnFields()) { String definition = createColumnDefinition(tableInfo, field); if (!TextUtils.isEmpty(definition)) { definitions.add(definition); } } definitions.addAll(createUniqueDefinition(tableInfo)); return String.format("CREATE TABLE IF NOT EXISTS `%s` (%s);", tableInfo.getTableName(), TextUtils.join(", ", definitions)); } }
SQLiteUtils { @NonNull public static String createTableDefinition(TableInfo tableInfo) { ArrayList<String> definitions = new ArrayList<>(); for (Field field : tableInfo.getColumnFields()) { String definition = createColumnDefinition(tableInfo, field); if (!TextUtils.isEmpty(definition)) { definitions.add(definition); } } definitions.addAll(createUniqueDefinition(tableInfo)); return String.format("CREATE TABLE IF NOT EXISTS `%s` (%s);", tableInfo.getTableName(), TextUtils.join(", ", definitions)); }  }
SQLiteUtils { @NonNull public static String createTableDefinition(TableInfo tableInfo) { ArrayList<String> definitions = new ArrayList<>(); for (Field field : tableInfo.getColumnFields()) { String definition = createColumnDefinition(tableInfo, field); if (!TextUtils.isEmpty(definition)) { definitions.add(definition); } } definitions.addAll(createUniqueDefinition(tableInfo)); return String.format("CREATE TABLE IF NOT EXISTS `%s` (%s);", tableInfo.getTableName(), TextUtils.join(", ", definitions)); }  @NonNull static String getIdentityHash(Collection<TableInfo> tableInfos); @NonNull static ArrayList<String> getAllTableNames(SQLiteDatabase database); @NonNull static String createTableDefinition(TableInfo tableInfo); @NonNull static List<String> createIndexDefinition(TableInfo tableInfo); static SQLiteType getFieldSQLiteType(Field field, Map<Class<?>, TypeSerializer> typeSerializers); static Object getColumnFieldValue(Class<?> modelClass,
                                             Class<?> fieldType,
                                             Cursor cursor,
                                             int columnIndex); static void fillContentValuesForUpdate(Object model,
                                                  ModelAdapter modelAdapter,
                                                  ContentValues contentValues); static void fillContentValuesForInsert(Object model,
                                                  ModelAdapter modelAdapter,
                                                  ContentValues contentValues); }
SQLiteUtils { @NonNull public static String createTableDefinition(TableInfo tableInfo) { ArrayList<String> definitions = new ArrayList<>(); for (Field field : tableInfo.getColumnFields()) { String definition = createColumnDefinition(tableInfo, field); if (!TextUtils.isEmpty(definition)) { definitions.add(definition); } } definitions.addAll(createUniqueDefinition(tableInfo)); return String.format("CREATE TABLE IF NOT EXISTS `%s` (%s);", tableInfo.getTableName(), TextUtils.join(", ", definitions)); }  @NonNull static String getIdentityHash(Collection<TableInfo> tableInfos); @NonNull static ArrayList<String> getAllTableNames(SQLiteDatabase database); @NonNull static String createTableDefinition(TableInfo tableInfo); @NonNull static List<String> createIndexDefinition(TableInfo tableInfo); static SQLiteType getFieldSQLiteType(Field field, Map<Class<?>, TypeSerializer> typeSerializers); static Object getColumnFieldValue(Class<?> modelClass,
                                             Class<?> fieldType,
                                             Cursor cursor,
                                             int columnIndex); static void fillContentValuesForUpdate(Object model,
                                                  ModelAdapter modelAdapter,
                                                  ContentValues contentValues); static void fillContentValuesForInsert(Object model,
                                                  ModelAdapter modelAdapter,
                                                  ContentValues contentValues);  }