diff --git a/build.gradle b/build.gradle index 9a2c9431..6252d52b 100644 --- a/build.gradle +++ b/build.gradle @@ -15,8 +15,8 @@ final ANDROID_SDK_PATH = { }() ext { - MIN_SDK_VERSION = 16 - SDK_VERSION = 28 + MIN_SDK_VERSION = 21 + SDK_VERSION = 31 BUILD_TOOLS_VERSION = '28.0.3' ANDROIDX_CORE_VERSION = '1.0.0' ANDROIDX_ANNOTATION_VERSION = '1.0.0' @@ -26,21 +26,51 @@ ext { } buildscript { + ext { + agp_version = '7.3.1' + } repositories { google() - jcenter() + mavenCentral() + maven { + url "https://plugins.gradle.org/m2/" + } + maven { url 'https://repo.grails.org/grails/core/' } + maven { + url 'https://oss.sonatype.org/content/repositories/snapshots/' + } + maven { + url 'https://dl.bintray.com/realm/maven/' + } + maven { + url 'https://maven.aliyun.com/repository/public/' + } } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath "com.android.tools.build:gradle:$agp_version" classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath "gradle.plugin.org.ec4j.gradle:editorconfig-gradle-plugin:0.0.3" + //classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' } } allprojects { repositories { google() - jcenter() + mavenCentral() + maven { + url "https://plugins.gradle.org/m2/" + } + maven { url 'https://repo.grails.org/grails/core/' } + maven { + url 'https://oss.sonatype.org/content/repositories/snapshots/' + } + maven { + url 'https://dl.bintray.com/realm/maven/' + } + maven { + url 'https://maven.aliyun.com/repository/public/' + } } gradle.projectsEvaluated { @@ -118,7 +148,6 @@ class TimingsListener implements TaskExecutionListener, BuildListener { } } - @Override void buildStarted(Gradle gradle) {} @Override diff --git a/core/build.gradle b/core/build.gradle index 3573def6..53eaa6c0 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -15,7 +15,7 @@ */ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.github.dcendents.android-maven' android { compileSdkVersion SDK_VERSION diff --git a/encryption/build.gradle b/encryption/build.gradle index 7576b836..689c5655 100644 --- a/encryption/build.gradle +++ b/encryption/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.github.dcendents.android-maven' android { compileSdkVersion SDK_VERSION @@ -43,7 +43,9 @@ dependencies { api "androidx.annotation:annotation:${ANDROIDX_ANNOTATION_VERSION}" // https://github.com/sqlcipher/android-database-sqlcipher - implementation 'net.zetetic:android-database-sqlcipher:4.3.0' + implementation 'androidx.sqlite:sqlite:2.2.0' + // implementation 'net.zetetic:android-database-sqlcipher:4.5.4' + implementation 'net.zetetic:sqlcipher-android:4.7.2@aar' } archivesBaseName = 'orma-encryption' diff --git a/encryption/src/main/java/com/github/gfx/android/orma/encryption/EncryptedDatabase.java b/encryption/src/main/java/com/github/gfx/android/orma/encryption/EncryptedDatabase.java index 90839e10..0d4bc67a 100644 --- a/encryption/src/main/java/com/github/gfx/android/orma/encryption/EncryptedDatabase.java +++ b/encryption/src/main/java/com/github/gfx/android/orma/encryption/EncryptedDatabase.java @@ -20,8 +20,9 @@ import com.github.gfx.android.orma.core.DatabaseProvider; import com.github.gfx.android.orma.core.DatabaseStatement; -import net.sqlcipher.DatabaseUtils; -import net.sqlcipher.database.SQLiteDatabase; + +import net.zetetic.database.DatabaseUtils; +import net.zetetic.database.sqlcipher.SQLiteDatabase; import android.content.ContentValues; import android.content.Context; @@ -165,16 +166,16 @@ public Provider(@NonNull String password) { @NonNull @Override public Database provideOnDiskDatabase(@NonNull Context context, @NonNull String name, int mode) { - SQLiteDatabase.loadLibs(context); + System.loadLibrary("sqlcipher"); File path = context.getDatabasePath(name); - return new EncryptedDatabase(SQLiteDatabase.openOrCreateDatabase(path, password, null)); + return new EncryptedDatabase(SQLiteDatabase.openOrCreateDatabase(path, password, null,null)); } @NonNull @Override public Database provideOnMemoryDatabase(@NonNull Context context) { - SQLiteDatabase.loadLibs(context); - return new EncryptedDatabase(SQLiteDatabase.create(null, password)); + System.loadLibrary("sqlcipher"); + return new EncryptedDatabase(SQLiteDatabase.create(null)); } } } diff --git a/encryption/src/main/java/com/github/gfx/android/orma/encryption/EncryptedDatabaseStatement.java b/encryption/src/main/java/com/github/gfx/android/orma/encryption/EncryptedDatabaseStatement.java index 6370deaa..db8e205f 100644 --- a/encryption/src/main/java/com/github/gfx/android/orma/encryption/EncryptedDatabaseStatement.java +++ b/encryption/src/main/java/com/github/gfx/android/orma/encryption/EncryptedDatabaseStatement.java @@ -18,7 +18,8 @@ import com.github.gfx.android.orma.core.DatabaseStatement; -import net.sqlcipher.database.SQLiteStatement; +import net.zetetic.database.sqlcipher.SQLiteStatement; + class EncryptedDatabaseStatement implements DatabaseStatement { diff --git a/example/build.gradle b/example/build.gradle index efdbff96..9a9f766b 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -1,7 +1,13 @@ buildscript { repositories { google() - jcenter() + mavenCentral() + maven { + url 'https://dl.bintray.com/realm/maven/' + } + maven { + url 'https://maven.aliyun.com/repository/public/' + } } dependencies { classpath 'io.realm:realm-gradle-plugin:3.7.2' @@ -36,14 +42,14 @@ android { buildTypes { release { minifyEnabled true - useProguard true + //useProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.debug resValue "string", "app_name", "Orma ${rootProject.ext.versionName} (release)" } debug { minifyEnabled true - useProguard false + //useProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.debug resValue "string", "app_name", "Orma ${rootProject.ext.versionName} (release)" diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_AssociationCondition.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_AssociationCondition.java deleted file mode 100644 index 299658fc..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_AssociationCondition.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.AssociationCondition; -import com.github.gfx.android.orma.OrmaConnection; -import java.util.Arrays; -import java.util.Collection; - -public class Category_AssociationCondition extends AssociationCondition { - final Category_Schema schema; - - public Category_AssociationCondition(OrmaConnection conn, Category_Schema schema) { - super(conn); - this.schema = schema; - } - - public Category_AssociationCondition(Category_AssociationCondition that) { - super(that); - this.schema = that.getSchema(); - } - - public Category_AssociationCondition(Category_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Category_AssociationCondition clone() { - return new Category_AssociationCondition(this); - } - - @NonNull - @Override - public Category_Schema getSchema() { - return schema; - } - - public Category_AssociationCondition idEq(long id) { - return where(schema.id, "=", id); - } - - public Category_AssociationCondition idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Category_AssociationCondition idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Category_AssociationCondition idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Category_AssociationCondition idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Category_AssociationCondition idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Category_AssociationCondition idLt(long id) { - return where(schema.id, "<", id); - } - - public Category_AssociationCondition idLe(long id) { - return where(schema.id, "<=", id); - } - - public Category_AssociationCondition idGt(long id) { - return where(schema.id, ">", id); - } - - public Category_AssociationCondition idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Category_AssociationCondition idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Deleter.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Deleter.java deleted file mode 100644 index 6896c433..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Deleter.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.rx.RxDeleter; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import java.util.Arrays; -import java.util.Collection; - -public class Category_Deleter extends RxDeleter { - final Category_Schema schema; - - public Category_Deleter(RxOrmaConnection conn, Category_Schema schema) { - super(conn); - this.schema = schema; - } - - public Category_Deleter(Category_Deleter that) { - super(that); - this.schema = that.getSchema(); - } - - public Category_Deleter(Category_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Category_Deleter clone() { - return new Category_Deleter(this); - } - - @NonNull - @Override - public Category_Schema getSchema() { - return schema; - } - - public Category_Deleter idEq(long id) { - return where(schema.id, "=", id); - } - - public Category_Deleter idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Category_Deleter idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Category_Deleter idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Category_Deleter idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Category_Deleter idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Category_Deleter idLt(long id) { - return where(schema.id, "<", id); - } - - public Category_Deleter idLe(long id) { - return where(schema.id, "<=", id); - } - - public Category_Deleter idGt(long id) { - return where(schema.id, ">", id); - } - - public Category_Deleter idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Category_Deleter idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Relation.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Relation.java deleted file mode 100644 index c27e2aae..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Relation.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxRelation; -import java.util.Arrays; -import java.util.Collection; - -public class Category_Relation extends RxRelation { - final Category_Schema schema; - - public Category_Relation(RxOrmaConnection conn, Category_Schema schema) { - super(conn); - this.schema = schema; - } - - public Category_Relation(Category_Relation that) { - super(that); - this.schema = that.getSchema(); - } - - @Override - public Category_Relation clone() { - return new Category_Relation(this); - } - - @NonNull - @Override - public Category_Schema getSchema() { - return schema; - } - - @NonNull - @CheckResult - public Category reload(@NonNull Category model) { - return selector().idEq(model.id).value(); - } - - @NonNull - @Override - public Category upsertWithoutTransaction(@NonNull Category model) { - ContentValues contentValues = new ContentValues(); - contentValues.put("`name`", model.name); - if (model.id != 0) { - int updatedRows = updater().idEq(model.id).putAll(contentValues).execute(); - if (updatedRows != 0) { - return selector().idEq(model.id).value(); - } - } - long rowId = conn.insert(schema, contentValues, OnConflict.NONE); - return conn.findByRowId(schema, rowId); - } - - @NonNull - @Override - public Category_Selector selector() { - return new Category_Selector(this); - } - - @NonNull - @Override - public Category_Updater updater() { - return new Category_Updater(this); - } - - @NonNull - @Override - public Category_Deleter deleter() { - return new Category_Deleter(this); - } - - public Category_Relation idEq(long id) { - return where(schema.id, "=", id); - } - - public Category_Relation idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Category_Relation idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Category_Relation idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Category_Relation idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Category_Relation idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Category_Relation idLt(long id) { - return where(schema.id, "<", id); - } - - public Category_Relation idLe(long id) { - return where(schema.id, "<=", id); - } - - public Category_Relation idGt(long id) { - return where(schema.id, ">", id); - } - - public Category_Relation idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Category_Relation idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Schema.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Schema.java deleted file mode 100644 index 420c84f0..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Schema.java +++ /dev/null @@ -1,230 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import android.database.Cursor; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.github.gfx.android.orma.ColumnDef; -import com.github.gfx.android.orma.OrmaConnection; -import com.github.gfx.android.orma.Schema; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.core.DatabaseStatement; -import com.github.gfx.android.orma.internal.Aliases; -import com.github.gfx.android.orma.internal.Schemas; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class Category_Schema implements Schema { - public static final Category_Schema INSTANCE = Schemas.register(new Category_Schema()); - - @Nullable - private final String $alias; - - public final ColumnDef name; - - public final ColumnDef id; - - private final String[] $defaultResultColumns; - - public Category_Schema() { - this(null); - } - - public Category_Schema(@Nullable Aliases.ColumnPath current) { - $alias = current != null ? current.getAlias() : null; - this.id = new ColumnDef(this, "id", long.class, "INTEGER", ColumnDef.PRIMARY_KEY | ColumnDef.AUTO_VALUE) { - @Override - @NonNull - public Long get(@NonNull Category model) { - return model.id; - } - - @NonNull - @Override - public Long getSerialized(@NonNull Category model) { - return model.id; - } - - @NonNull - @Override - public Long getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.getLong(index); - } - }; - this.name = new ColumnDef(this, "name", String.class, "TEXT", ColumnDef.UNIQUE) { - @Override - @NonNull - public String get(@NonNull Category model) { - return model.name; - } - - @NonNull - @Override - public String getSerialized(@NonNull Category model) { - return model.name; - } - - @NonNull - @Override - public String getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.getString(index); - } - }; - $defaultResultColumns = new String[]{ - name.getQualifiedName(), - id.getQualifiedName() - }; - } - - @NonNull - @Override - public Class getModelClass() { - return Category.class; - } - - @NonNull - @Override - public String getTableName() { - return "Category"; - } - - @NonNull - @Override - public String getEscapedTableName() { - return "`Category`"; - } - - @Nullable - @Override - public String getTableAlias() { - return $alias; - } - - @Nullable - @Override - public String getEscapedTableAlias() { - return $alias != null ? '`' + $alias + '`' : null; - } - - @NonNull - @Override - public String getSelectFromTableClause() { - return "`Category`"+ ($alias != null ? " AS " + '`' + $alias + '`' : ""); - } - - @NonNull - @Override - public ColumnDef getPrimaryKey() { - return id; - } - - @NonNull - @Override - public List> getColumns() { - return Arrays.>asList( - name, - id - ); - } - - @NonNull - @Override - public String[] getDefaultResultColumns() { - return $defaultResultColumns; - } - - @NonNull - @Override - public String getCreateTableStatement() { - return "CREATE TABLE `Category` (`name` TEXT UNIQUE ON CONFLICT IGNORE NOT NULL, `id` INTEGER PRIMARY KEY)"; - } - - @NonNull - @Override - public List getCreateIndexStatements() { - return Collections.emptyList(); - } - - @NonNull - @Override - public String getDropTableStatement() { - return "DROP TABLE IF EXISTS `Category`"; - } - - @NonNull - @Override - public String getInsertStatement(@OnConflict int onConflictAlgorithm, boolean withoutAutoId) { - StringBuilder s = new StringBuilder(); - s.append("INSERT"); - switch (onConflictAlgorithm) { - case OnConflict.NONE: /* nop */ break; - case OnConflict.ABORT: s.append(" OR ABORT"); break; - case OnConflict.FAIL: s.append(" OR FAIL"); break; - case OnConflict.IGNORE: s.append(" OR IGNORE"); break; - case OnConflict.REPLACE: s.append(" OR REPLACE"); break; - case OnConflict.ROLLBACK: s.append(" OR ROLLBACK"); break; - default: throw new IllegalArgumentException("Invalid OnConflict algorithm: " + onConflictAlgorithm); - } - if (withoutAutoId) { - s.append(" INTO `Category` (`name`) VALUES (?)"); - } - else { - s.append(" INTO `Category` (`name`,`id`) VALUES (?,?)"); - } - return s.toString(); - } - - /** - * Convert a model to {@code ContentValues). You can use the content values for UPDATE and/or INSERT. - */ - @NonNull - @Override - public ContentValues convertToContentValues(@NonNull OrmaConnection conn, @NonNull Category model, - boolean withoutAutoId) { - ContentValues contentValues = new ContentValues(); - contentValues.put("name", model.name); - if (!withoutAutoId) { - contentValues.put("id", model.id); - } - return contentValues; - } - - /** - * Convert a model to {@code Object[]}. Provided for debugging. - */ - @NonNull - @Override - public Object[] convertToArgs(@NonNull OrmaConnection conn, @NonNull Category model, - boolean withoutAutoId) { - Object[] args = new Object[withoutAutoId ? 1 : 2]; - if (model.name != null) { - args[0] = model.name; - } - else { - throw new IllegalArgumentException("Category.name" + " must not be null, or use @Nullable to declare it as NULL"); - } - if (!withoutAutoId) { - args[1] = model.id; - } - return args; - } - - @Override - public void bindArgs(@NonNull OrmaConnection conn, @NonNull DatabaseStatement statement, - @NonNull Category model, boolean withoutAutoId) { - statement.bindString(1, model.name); - if (!withoutAutoId) { - statement.bindLong(2, model.id); - } - } - - @NonNull - @Override - public Category newModelFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, - int offset) { - String name = cursor.getString(offset + 0); - long id = cursor.getLong(offset + 1); - return new Category(id, name); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Selector.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Selector.java deleted file mode 100644 index 812b1f8f..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Selector.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxSelector; -import java.util.Arrays; -import java.util.Collection; - -public class Category_Selector extends RxSelector { - final Category_Schema schema; - - public Category_Selector(RxOrmaConnection conn, Category_Schema schema) { - super(conn); - this.schema = schema; - } - - public Category_Selector(Category_Selector that) { - super(that); - this.schema = that.getSchema(); - } - - public Category_Selector(Category_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Category_Selector clone() { - return new Category_Selector(this); - } - - @NonNull - @Override - public Category_Schema getSchema() { - return schema; - } - - public Category_Selector idEq(long id) { - return where(schema.id, "=", id); - } - - public Category_Selector idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Category_Selector idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Category_Selector idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Category_Selector idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Category_Selector idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Category_Selector idLt(long id) { - return where(schema.id, "<", id); - } - - public Category_Selector idLe(long id) { - return where(schema.id, "<=", id); - } - - public Category_Selector idGt(long id) { - return where(schema.id, ">", id); - } - - public Category_Selector idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Category_Selector idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Updater.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Updater.java deleted file mode 100644 index bd1f71c5..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Category_Updater.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxUpdater; -import java.util.Arrays; -import java.util.Collection; - -public class Category_Updater extends RxUpdater { - final Category_Schema schema; - - public Category_Updater(RxOrmaConnection conn, Category_Schema schema) { - super(conn); - this.schema = schema; - } - - public Category_Updater(Category_Updater that) { - super(that); - this.schema = that.getSchema(); - } - - public Category_Updater(Category_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Category_Updater clone() { - return new Category_Updater(this); - } - - @NonNull - @Override - public Category_Schema getSchema() { - return schema; - } - - public Category_Updater name(@NonNull String name) { - contents.put("`name`", name); - return this; - } - - public Category_Updater idEq(long id) { - return where(schema.id, "=", id); - } - - public Category_Updater idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Category_Updater idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Category_Updater idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Category_Updater idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Category_Updater idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Category_Updater idLt(long id) { - return where(schema.id, "<", id); - } - - public Category_Updater idLe(long id) { - return where(schema.id, "<=", id); - } - - public Category_Updater idGt(long id) { - return where(schema.id, ">", id); - } - - public Category_Updater idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Category_Updater idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_AssociationCondition.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_AssociationCondition.java deleted file mode 100644 index d1aeac61..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_AssociationCondition.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.AssociationCondition; -import com.github.gfx.android.orma.OrmaConnection; -import java.util.Arrays; -import java.util.Collection; - -public class Entry_AssociationCondition extends AssociationCondition { - final Entry_Schema schema; - - public Entry_AssociationCondition(OrmaConnection conn, Entry_Schema schema) { - super(conn); - this.schema = schema; - } - - public Entry_AssociationCondition(Entry_AssociationCondition that) { - super(that); - this.schema = that.getSchema(); - } - - public Entry_AssociationCondition(Entry_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Entry_AssociationCondition clone() { - return new Entry_AssociationCondition(this); - } - - @NonNull - @Override - public Entry_Schema getSchema() { - return schema; - } - - public Entry_AssociationCondition idEq(long id) { - return where(schema.id, "=", id); - } - - public Entry_AssociationCondition idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Entry_AssociationCondition idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Entry_AssociationCondition idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Entry_AssociationCondition idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Entry_AssociationCondition idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Entry_AssociationCondition idLt(long id) { - return where(schema.id, "<", id); - } - - public Entry_AssociationCondition idLe(long id) { - return where(schema.id, "<=", id); - } - - public Entry_AssociationCondition idGt(long id) { - return where(schema.id, ">", id); - } - - public Entry_AssociationCondition idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Entry_AssociationCondition idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } - - public Entry_AssociationCondition resourceTypeAndResourceIdEq(@NonNull String resourceType, - long resourceId) { - return where(schema.resourceType, "=", resourceType).where(schema.resourceId, "=", resourceId); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Deleter.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Deleter.java deleted file mode 100644 index 1c30daea..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Deleter.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.rx.RxDeleter; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import java.util.Arrays; -import java.util.Collection; - -public class Entry_Deleter extends RxDeleter { - final Entry_Schema schema; - - public Entry_Deleter(RxOrmaConnection conn, Entry_Schema schema) { - super(conn); - this.schema = schema; - } - - public Entry_Deleter(Entry_Deleter that) { - super(that); - this.schema = that.getSchema(); - } - - public Entry_Deleter(Entry_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Entry_Deleter clone() { - return new Entry_Deleter(this); - } - - @NonNull - @Override - public Entry_Schema getSchema() { - return schema; - } - - public Entry_Deleter idEq(long id) { - return where(schema.id, "=", id); - } - - public Entry_Deleter idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Entry_Deleter idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Entry_Deleter idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Entry_Deleter idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Entry_Deleter idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Entry_Deleter idLt(long id) { - return where(schema.id, "<", id); - } - - public Entry_Deleter idLe(long id) { - return where(schema.id, "<=", id); - } - - public Entry_Deleter idGt(long id) { - return where(schema.id, ">", id); - } - - public Entry_Deleter idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Entry_Deleter idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } - - public Entry_Deleter resourceTypeAndResourceIdEq(@NonNull String resourceType, long resourceId) { - return where(schema.resourceType, "=", resourceType).where(schema.resourceId, "=", resourceId); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Relation.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Relation.java deleted file mode 100644 index b7fba718..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Relation.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxRelation; -import java.util.Arrays; -import java.util.Collection; - -public class Entry_Relation extends RxRelation { - final Entry_Schema schema; - - public Entry_Relation(RxOrmaConnection conn, Entry_Schema schema) { - super(conn); - this.schema = schema; - } - - public Entry_Relation(Entry_Relation that) { - super(that); - this.schema = that.getSchema(); - } - - @Override - public Entry_Relation clone() { - return new Entry_Relation(this); - } - - @NonNull - @Override - public Entry_Schema getSchema() { - return schema; - } - - @NonNull - @CheckResult - public Entry reload(@NonNull Entry model) { - return selector().idEq(model.id).value(); - } - - @NonNull - @Override - public Entry upsertWithoutTransaction(@NonNull Entry model) { - ContentValues contentValues = new ContentValues(); - contentValues.put("`resourceType`", model.resourceType); - contentValues.put("`resourceId`", model.resourceId); - if (model.id != 0) { - int updatedRows = updater().idEq(model.id).putAll(contentValues).execute(); - if (updatedRows != 0) { - return selector().idEq(model.id).value(); - } - } - long rowId = conn.insert(schema, contentValues, OnConflict.NONE); - return conn.findByRowId(schema, rowId); - } - - @NonNull - @Override - public Entry_Selector selector() { - return new Entry_Selector(this); - } - - @NonNull - @Override - public Entry_Updater updater() { - return new Entry_Updater(this); - } - - @NonNull - @Override - public Entry_Deleter deleter() { - return new Entry_Deleter(this); - } - - public Entry_Relation idEq(long id) { - return where(schema.id, "=", id); - } - - public Entry_Relation idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Entry_Relation idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Entry_Relation idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Entry_Relation idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Entry_Relation idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Entry_Relation idLt(long id) { - return where(schema.id, "<", id); - } - - public Entry_Relation idLe(long id) { - return where(schema.id, "<=", id); - } - - public Entry_Relation idGt(long id) { - return where(schema.id, ">", id); - } - - public Entry_Relation idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Entry_Relation idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } - - public Entry_Relation resourceTypeAndResourceIdEq(@NonNull String resourceType, long resourceId) { - return where(schema.resourceType, "=", resourceType).where(schema.resourceId, "=", resourceId); - } - - public Entry_Relation orderByresourceTypeAndResourceIdAsc() { - return orderBy(schema.resourceType.orderInAscending()).orderBy(schema.resourceId.orderInAscending()); - } - - public Entry_Relation orderByresourceTypeAndResourceIdDesc() { - return orderBy(schema.resourceType.orderInDescending()).orderBy(schema.resourceId.orderInDescending()); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Schema.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Schema.java deleted file mode 100644 index 86fafc1c..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Schema.java +++ /dev/null @@ -1,259 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import android.database.Cursor; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.github.gfx.android.orma.ColumnDef; -import com.github.gfx.android.orma.OrmaConnection; -import com.github.gfx.android.orma.Schema; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.core.DatabaseStatement; -import com.github.gfx.android.orma.internal.Aliases; -import com.github.gfx.android.orma.internal.Schemas; -import java.util.Arrays; -import java.util.List; - -public class Entry_Schema implements Schema { - public static final Entry_Schema INSTANCE = Schemas.register(new Entry_Schema()); - - @Nullable - private final String $alias; - - public final ColumnDef resourceType; - - public final ColumnDef resourceId; - - public final ColumnDef id; - - private final String[] $defaultResultColumns; - - public Entry_Schema() { - this(null); - } - - public Entry_Schema(@Nullable Aliases.ColumnPath current) { - $alias = current != null ? current.getAlias() : null; - this.id = new ColumnDef(this, "id", long.class, "INTEGER", ColumnDef.PRIMARY_KEY | ColumnDef.AUTO_VALUE) { - @Override - @NonNull - public Long get(@NonNull Entry model) { - return model.id; - } - - @NonNull - @Override - public Long getSerialized(@NonNull Entry model) { - return model.id; - } - - @NonNull - @Override - public Long getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.getLong(index); - } - }; - this.resourceType = new ColumnDef(this, "resourceType", String.class, "TEXT", 0) { - @Override - @NonNull - public String get(@NonNull Entry model) { - return model.resourceType; - } - - @NonNull - @Override - public String getSerialized(@NonNull Entry model) { - return model.resourceType; - } - - @NonNull - @Override - public String getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.getString(index); - } - }; - this.resourceId = new ColumnDef(this, "resourceId", long.class, "INTEGER", 0) { - @Override - @NonNull - public Long get(@NonNull Entry model) { - return model.resourceId; - } - - @NonNull - @Override - public Long getSerialized(@NonNull Entry model) { - return model.resourceId; - } - - @NonNull - @Override - public Long getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.getLong(index); - } - }; - $defaultResultColumns = new String[]{ - resourceType.getQualifiedName(), - resourceId.getQualifiedName(), - id.getQualifiedName() - }; - } - - @NonNull - @Override - public Class getModelClass() { - return Entry.class; - } - - @NonNull - @Override - public String getTableName() { - return "Entry"; - } - - @NonNull - @Override - public String getEscapedTableName() { - return "`Entry`"; - } - - @Nullable - @Override - public String getTableAlias() { - return $alias; - } - - @Nullable - @Override - public String getEscapedTableAlias() { - return $alias != null ? '`' + $alias + '`' : null; - } - - @NonNull - @Override - public String getSelectFromTableClause() { - return "`Entry`"+ ($alias != null ? " AS " + '`' + $alias + '`' : ""); - } - - @NonNull - @Override - public ColumnDef getPrimaryKey() { - return id; - } - - @NonNull - @Override - public List> getColumns() { - return Arrays.>asList( - resourceType, - resourceId, - id - ); - } - - @NonNull - @Override - public String[] getDefaultResultColumns() { - return $defaultResultColumns; - } - - @NonNull - @Override - public String getCreateTableStatement() { - return "CREATE TABLE `Entry` (`resourceType` TEXT NOT NULL, `resourceId` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY)"; - } - - @NonNull - @Override - public List getCreateIndexStatements() { - return Arrays.asList( - "CREATE UNIQUE INDEX `index_resourceType_resourceId_on_Entry` ON `Entry` (`resourceType`, `resourceId`)" - ); - } - - @NonNull - @Override - public String getDropTableStatement() { - return "DROP TABLE IF EXISTS `Entry`"; - } - - @NonNull - @Override - public String getInsertStatement(@OnConflict int onConflictAlgorithm, boolean withoutAutoId) { - StringBuilder s = new StringBuilder(); - s.append("INSERT"); - switch (onConflictAlgorithm) { - case OnConflict.NONE: /* nop */ break; - case OnConflict.ABORT: s.append(" OR ABORT"); break; - case OnConflict.FAIL: s.append(" OR FAIL"); break; - case OnConflict.IGNORE: s.append(" OR IGNORE"); break; - case OnConflict.REPLACE: s.append(" OR REPLACE"); break; - case OnConflict.ROLLBACK: s.append(" OR ROLLBACK"); break; - default: throw new IllegalArgumentException("Invalid OnConflict algorithm: " + onConflictAlgorithm); - } - if (withoutAutoId) { - s.append(" INTO `Entry` (`resourceType`,`resourceId`) VALUES (?,?)"); - } - else { - s.append(" INTO `Entry` (`resourceType`,`resourceId`,`id`) VALUES (?,?,?)"); - } - return s.toString(); - } - - /** - * Convert a model to {@code ContentValues). You can use the content values for UPDATE and/or INSERT. - */ - @NonNull - @Override - public ContentValues convertToContentValues(@NonNull OrmaConnection conn, @NonNull Entry model, - boolean withoutAutoId) { - ContentValues contentValues = new ContentValues(); - contentValues.put("resourceType", model.resourceType); - contentValues.put("resourceId", model.resourceId); - if (!withoutAutoId) { - contentValues.put("id", model.id); - } - return contentValues; - } - - /** - * Convert a model to {@code Object[]}. Provided for debugging. - */ - @NonNull - @Override - public Object[] convertToArgs(@NonNull OrmaConnection conn, @NonNull Entry model, - boolean withoutAutoId) { - Object[] args = new Object[withoutAutoId ? 2 : 3]; - if (model.resourceType != null) { - args[0] = model.resourceType; - } - else { - throw new IllegalArgumentException("Entry.resourceType" + " must not be null, or use @Nullable to declare it as NULL"); - } - args[1] = model.resourceId; - if (!withoutAutoId) { - args[2] = model.id; - } - return args; - } - - @Override - public void bindArgs(@NonNull OrmaConnection conn, @NonNull DatabaseStatement statement, - @NonNull Entry model, boolean withoutAutoId) { - statement.bindString(1, model.resourceType); - statement.bindLong(2, model.resourceId); - if (!withoutAutoId) { - statement.bindLong(3, model.id); - } - } - - @NonNull - @Override - public Entry newModelFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, - int offset) { - Entry model = new Entry(); - model.resourceType = cursor.getString(offset + 0); - model.resourceId = cursor.getLong(offset + 1); - model.id = cursor.getLong(offset + 2); - return model; - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Selector.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Selector.java deleted file mode 100644 index 4cda8686..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Selector.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.database.Cursor; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxSelector; -import java.util.Arrays; -import java.util.Collection; - -public class Entry_Selector extends RxSelector { - final Entry_Schema schema; - - public Entry_Selector(RxOrmaConnection conn, Entry_Schema schema) { - super(conn); - this.schema = schema; - } - - public Entry_Selector(Entry_Selector that) { - super(that); - this.schema = that.getSchema(); - } - - public Entry_Selector(Entry_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Entry_Selector clone() { - return new Entry_Selector(this); - } - - @NonNull - @Override - public Entry_Schema getSchema() { - return schema; - } - - public Entry_Selector idEq(long id) { - return where(schema.id, "=", id); - } - - public Entry_Selector idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Entry_Selector idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Entry_Selector idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Entry_Selector idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Entry_Selector idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Entry_Selector idLt(long id) { - return where(schema.id, "<", id); - } - - public Entry_Selector idLe(long id) { - return where(schema.id, "<=", id); - } - - public Entry_Selector idGt(long id) { - return where(schema.id, ">", id); - } - - public Entry_Selector idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Entry_Selector idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } - - public Entry_Selector resourceTypeAndResourceIdEq(@NonNull String resourceType, long resourceId) { - return where(schema.resourceType, "=", resourceType).where(schema.resourceId, "=", resourceId); - } - - public Entry_Selector orderByresourceTypeAndResourceIdAsc() { - return orderBy(schema.resourceType.orderInAscending()).orderBy(schema.resourceId.orderInAscending()); - } - - public Entry_Selector orderByresourceTypeAndResourceIdDesc() { - return orderBy(schema.resourceType.orderInDescending()).orderBy(schema.resourceId.orderInDescending()); - } - - @Nullable - public Long minByResourceId() { - Cursor cursor = executeWithColumns(schema.resourceId.buildCallExpr("MIN")); - try { - cursor.moveToFirst(); - return cursor.isNull(0) ? null : schema.resourceId.getFromCursor(conn, cursor, 0); - } - finally { - cursor.close(); - } - } - - @Nullable - public Long maxByResourceId() { - Cursor cursor = executeWithColumns(schema.resourceId.buildCallExpr("MAX")); - try { - cursor.moveToFirst(); - return cursor.isNull(0) ? null : schema.resourceId.getFromCursor(conn, cursor, 0); - } - finally { - cursor.close(); - } - } - - @Nullable - public Long sumByResourceId() { - Cursor cursor = executeWithColumns(schema.resourceId.buildCallExpr("SUM")); - try { - cursor.moveToFirst(); - return cursor.isNull(0) ? null : cursor.getLong(0); - } - finally { - cursor.close(); - } - } - - @Nullable - public Double avgByResourceId() { - Cursor cursor = executeWithColumns(schema.resourceId.buildCallExpr("AVG")); - try { - cursor.moveToFirst(); - return cursor.isNull(0) ? null : cursor.getDouble(0); - } - finally { - cursor.close(); - } - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Updater.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Updater.java deleted file mode 100644 index 89b53f79..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Entry_Updater.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxUpdater; -import java.util.Arrays; -import java.util.Collection; - -public class Entry_Updater extends RxUpdater { - final Entry_Schema schema; - - public Entry_Updater(RxOrmaConnection conn, Entry_Schema schema) { - super(conn); - this.schema = schema; - } - - public Entry_Updater(Entry_Updater that) { - super(that); - this.schema = that.getSchema(); - } - - public Entry_Updater(Entry_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Entry_Updater clone() { - return new Entry_Updater(this); - } - - @NonNull - @Override - public Entry_Schema getSchema() { - return schema; - } - - public Entry_Updater resourceType(@NonNull String resourceType) { - contents.put("`resourceType`", resourceType); - return this; - } - - public Entry_Updater resourceId(long resourceId) { - contents.put("`resourceId`", resourceId); - return this; - } - - public Entry_Updater idEq(long id) { - return where(schema.id, "=", id); - } - - public Entry_Updater idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Entry_Updater idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Entry_Updater idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Entry_Updater idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Entry_Updater idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Entry_Updater idLt(long id) { - return where(schema.id, "<", id); - } - - public Entry_Updater idLe(long id) { - return where(schema.id, "<=", id); - } - - public Entry_Updater idGt(long id) { - return where(schema.id, ">", id); - } - - public Entry_Updater idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Entry_Updater idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } - - public Entry_Updater resourceTypeAndResourceIdEq(@NonNull String resourceType, long resourceId) { - return where(schema.resourceType, "=", resourceType).where(schema.resourceId, "=", resourceId); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_AssociationCondition.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_AssociationCondition.java deleted file mode 100644 index 2e97e240..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_AssociationCondition.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.AssociationCondition; -import com.github.gfx.android.orma.OrmaConnection; -import com.github.gfx.android.orma.function.Function1; -import java.util.Arrays; -import java.util.Collection; - -public class Item2_AssociationCondition extends AssociationCondition { - final Item2_Schema schema; - - public Item2_AssociationCondition(OrmaConnection conn, Item2_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item2_AssociationCondition(Item2_AssociationCondition that) { - super(that); - this.schema = that.getSchema(); - } - - public Item2_AssociationCondition(Item2_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Item2_AssociationCondition clone() { - return new Item2_AssociationCondition(this); - } - - @NonNull - @Override - public Item2_Schema getSchema() { - return schema; - } - - public Item2_AssociationCondition category1Eq(@NonNull Category category1) { - return where(schema.category1, "=", category1.id); - } - - public Item2_AssociationCondition category1Eq(long category1Id) { - return where(schema.category1, "=", category1Id); - } - - public Item2_AssociationCondition category1( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category1.associationSchema)).appendTo(this); - } - - public Item2_AssociationCondition category2IsNull() { - return where(schema.category2, " IS NULL"); - } - - public Item2_AssociationCondition category2IsNotNull() { - return where(schema.category2, " IS NOT NULL"); - } - - public Item2_AssociationCondition category2Eq(@NonNull Category category2) { - return where(schema.category2, "=", category2.id); - } - - public Item2_AssociationCondition category2Eq(long category2Id) { - return where(schema.category2, "=", category2Id); - } - - public Item2_AssociationCondition category2( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category2.associationSchema)).appendTo(this); - } - - public Item2_AssociationCondition nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item2_AssociationCondition nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item2_AssociationCondition nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item2_AssociationCondition nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item2_AssociationCondition nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item2_AssociationCondition nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item2_AssociationCondition nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item2_AssociationCondition nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item2_AssociationCondition nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item2_AssociationCondition nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Deleter.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Deleter.java deleted file mode 100644 index cb7e5fc9..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Deleter.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.function.Function1; -import com.github.gfx.android.orma.rx.RxDeleter; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import java.util.Arrays; -import java.util.Collection; - -public class Item2_Deleter extends RxDeleter { - final Item2_Schema schema; - - public Item2_Deleter(RxOrmaConnection conn, Item2_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item2_Deleter(Item2_Deleter that) { - super(that); - this.schema = that.getSchema(); - } - - public Item2_Deleter(Item2_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Item2_Deleter clone() { - return new Item2_Deleter(this); - } - - @NonNull - @Override - public Item2_Schema getSchema() { - return schema; - } - - public Item2_Deleter category1Eq(@NonNull Category category1) { - return where(schema.category1, "=", category1.id); - } - - public Item2_Deleter category1Eq(long category1Id) { - return where(schema.category1, "=", category1Id); - } - - public Item2_Deleter category1( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category1.associationSchema)).appendTo(this); - } - - public Item2_Deleter category2IsNull() { - return where(schema.category2, " IS NULL"); - } - - public Item2_Deleter category2IsNotNull() { - return where(schema.category2, " IS NOT NULL"); - } - - public Item2_Deleter category2Eq(@NonNull Category category2) { - return where(schema.category2, "=", category2.id); - } - - public Item2_Deleter category2Eq(long category2Id) { - return where(schema.category2, "=", category2Id); - } - - public Item2_Deleter category2( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category2.associationSchema)).appendTo(this); - } - - public Item2_Deleter nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item2_Deleter nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item2_Deleter nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item2_Deleter nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item2_Deleter nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item2_Deleter nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item2_Deleter nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item2_Deleter nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item2_Deleter nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item2_Deleter nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Relation.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Relation.java deleted file mode 100644 index d026ff60..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Relation.java +++ /dev/null @@ -1,176 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.example.tool.TypeAdapters; -import com.github.gfx.android.orma.function.Function1; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxRelation; -import java.util.Arrays; -import java.util.Collection; - -public class Item2_Relation extends RxRelation { - final Item2_Schema schema; - - public Item2_Relation(RxOrmaConnection conn, Item2_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item2_Relation(Item2_Relation that) { - super(that); - this.schema = that.getSchema(); - } - - @Override - public Item2_Relation clone() { - return new Item2_Relation(this); - } - - @NonNull - @Override - public Item2_Schema getSchema() { - return schema; - } - - @NonNull - @CheckResult - public Item2 reload(@NonNull Item2 model) { - return selector().nameEq(model.name).value(); - } - - @NonNull - @Override - public Item2 upsertWithoutTransaction(@NonNull Item2 model) { - ContentValues contentValues = new ContentValues(); - contentValues.put("`category1`", new Category_Relation(conn, Category_Schema.INSTANCE).upsertWithoutTransaction(model.category1).id); - contentValues.put("`category2`", model.category2 != null ? new Category_Relation(conn, Category_Schema.INSTANCE).upsertWithoutTransaction(model.category2).id : null); - contentValues.put("`zonedTimestamp`", TypeAdapters.serializeZonedDateTime(model.zonedTimestamp)); - contentValues.put("`localDateTime`", TypeAdapters.serializeLocalDateTime(model.localDateTime)); - contentValues.put("`name`", model.name); - int updatedRows = updater().nameEq(model.name).putAll(contentValues).execute(); - if (updatedRows != 0) { - return selector().nameEq(model.name).value(); - } - long rowId = conn.insert(schema, contentValues, OnConflict.NONE); - return conn.findByRowId(schema, rowId); - } - - @NonNull - @Override - public Item2_Selector selector() { - return new Item2_Selector(this); - } - - @NonNull - @Override - public Item2_Updater updater() { - return new Item2_Updater(this); - } - - @NonNull - @Override - public Item2_Deleter deleter() { - return new Item2_Deleter(this); - } - - public Item2_Relation category1Eq(@NonNull Category category1) { - return where(schema.category1, "=", category1.id); - } - - public Item2_Relation category1Eq(long category1Id) { - return where(schema.category1, "=", category1Id); - } - - public Item2_Relation category1( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category1.associationSchema)).appendTo(this); - } - - public Item2_Relation category2IsNull() { - return where(schema.category2, " IS NULL"); - } - - public Item2_Relation category2IsNotNull() { - return where(schema.category2, " IS NOT NULL"); - } - - public Item2_Relation category2Eq(@NonNull Category category2) { - return where(schema.category2, "=", category2.id); - } - - public Item2_Relation category2Eq(long category2Id) { - return where(schema.category2, "=", category2Id); - } - - public Item2_Relation category2( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category2.associationSchema)).appendTo(this); - } - - public Item2_Relation nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item2_Relation nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item2_Relation nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item2_Relation nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item2_Relation nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item2_Relation nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item2_Relation nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item2_Relation nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item2_Relation nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item2_Relation nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } - - public Item2_Relation orderByCategory1Asc() { - return orderBy(schema.category1.orderInAscending()); - } - - public Item2_Relation orderByCategory1Desc() { - return orderBy(schema.category1.orderInDescending()); - } - - public Item2_Relation orderByCategory2Asc() { - return orderBy(schema.category2.orderInAscending()); - } - - public Item2_Relation orderByCategory2Desc() { - return orderBy(schema.category2.orderInDescending()); - } - - public Item2_Relation orderByNameAsc() { - return orderBy(schema.name.orderInAscending()); - } - - public Item2_Relation orderByNameDesc() { - return orderBy(schema.name.orderInDescending()); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Schema.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Schema.java deleted file mode 100644 index 5cfbd4a5..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Schema.java +++ /dev/null @@ -1,349 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import android.database.Cursor; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.github.gfx.android.orma.AssociationDef; -import com.github.gfx.android.orma.ColumnDef; -import com.github.gfx.android.orma.OrmaConnection; -import com.github.gfx.android.orma.Schema; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.core.DatabaseStatement; -import com.github.gfx.android.orma.example.tool.TypeAdapters; -import com.github.gfx.android.orma.internal.Aliases; -import com.github.gfx.android.orma.internal.Schemas; -import java.util.Arrays; -import java.util.List; -import org.threeten.bp.LocalDateTime; -import org.threeten.bp.ZonedDateTime; - -public class Item2_Schema implements Schema { - public static final Item2_Schema INSTANCE = Schemas.register(new Item2_Schema()); - - @Nullable - private final String $alias; - - public final AssociationDef category1; - - public final AssociationDef category2; - - public final ColumnDef zonedTimestamp; - - public final ColumnDef localDateTime; - - public final ColumnDef name; - - private final String[] $defaultResultColumns; - - public Item2_Schema() { - this(new Aliases().createPath("Item2")); - } - - public Item2_Schema(@Nullable Aliases.ColumnPath current) { - $alias = current != null ? current.getAlias() : null; - this.name = new ColumnDef(this, "name", String.class, "TEXT", ColumnDef.PRIMARY_KEY) { - @Override - @NonNull - public String get(@NonNull Item2 model) { - return model.name; - } - - @NonNull - @Override - public String getSerialized(@NonNull Item2 model) { - return model.name; - } - - @NonNull - @Override - public String getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.getString(index); - } - }; - this.category1 = new AssociationDef(this, "category1", Category.class, "INTEGER", ColumnDef.INDEXED, new Category_Schema(current != null ? current.add("category1", "Category") : null)) { - @Override - @NonNull - public Category get(@NonNull Item2 model) { - return model.category1; - } - - @NonNull - @Override - public Long getSerialized(@NonNull Item2 model) { - return model.category1.id; - } - - @NonNull - @Override - public Category getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, - int index) { - return Category_Schema.INSTANCE.newModelFromCursor(conn, cursor, index + 1) /* consumes items: 2 */; - } - }; - this.category2 = new AssociationDef(this, "category2", Category.class, "INTEGER", ColumnDef.NULLABLE | ColumnDef.INDEXED, new Category_Schema(current != null ? current.add("category2", "Category") : null)) { - @Override - @Nullable - public Category get(@NonNull Item2 model) { - return model.category2; - } - - @Nullable - @Override - public Long getSerialized(@NonNull Item2 model) { - return model.category2.id; - } - - @Nullable - @Override - public Category getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, - int index) { - return cursor.isNull(index + 2) ? null : Category_Schema.INSTANCE.newModelFromCursor(conn, cursor, index + 1) /* consumes items: 2 */; - } - }; - this.zonedTimestamp = new ColumnDef(this, "zonedTimestamp", ZonedDateTime.class, "TEXT", 0) { - @Override - @NonNull - public ZonedDateTime get(@NonNull Item2 model) { - return model.zonedTimestamp; - } - - @NonNull - @Override - public String getSerialized(@NonNull Item2 model) { - return TypeAdapters.serializeZonedDateTime(model.zonedTimestamp); - } - - @NonNull - @Override - public ZonedDateTime getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, - int index) { - return TypeAdapters.deserializeZonedDateTime(cursor.getString(index)); - } - }; - this.localDateTime = new ColumnDef(this, "localDateTime", LocalDateTime.class, "TEXT", 0) { - @Override - @NonNull - public LocalDateTime get(@NonNull Item2 model) { - return model.localDateTime; - } - - @NonNull - @Override - public String getSerialized(@NonNull Item2 model) { - return TypeAdapters.serializeLocalDateTime(model.localDateTime); - } - - @NonNull - @Override - public LocalDateTime getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, - int index) { - return TypeAdapters.deserializeLocalDateTime(cursor.getString(index)); - } - }; - $defaultResultColumns = new String[]{ - category1.getQualifiedName(), - category1.associationSchema.name.getQualifiedName(), - category1.associationSchema.id.getQualifiedName() - , - category2.getQualifiedName(), - category2.associationSchema.name.getQualifiedName(), - category2.associationSchema.id.getQualifiedName() - , - zonedTimestamp.getQualifiedName(), - localDateTime.getQualifiedName(), - name.getQualifiedName() - }; - } - - @NonNull - @Override - public Class getModelClass() { - return Item2.class; - } - - @NonNull - @Override - public String getTableName() { - return "Item2"; - } - - @NonNull - @Override - public String getEscapedTableName() { - return "`Item2`"; - } - - @Nullable - @Override - public String getTableAlias() { - return $alias; - } - - @Nullable - @Override - public String getEscapedTableAlias() { - return $alias != null ? '`' + $alias + '`' : null; - } - - @NonNull - @Override - public String getSelectFromTableClause() { - return "`Item2`"+ " AS " + getEscapedTableAlias() - + " LEFT OUTER JOIN `Category` AS " + category1.associationSchema.getEscapedTableAlias() + " ON " + category1.getQualifiedName() + " = " + category1.associationSchema.id.getQualifiedName() - - + " LEFT OUTER JOIN `Category` AS " + category2.associationSchema.getEscapedTableAlias() + " ON " + category2.getQualifiedName() + " = " + category2.associationSchema.id.getQualifiedName() - - ; - } - - @NonNull - @Override - public ColumnDef getPrimaryKey() { - return name; - } - - @NonNull - @Override - public List> getColumns() { - return Arrays.>asList( - category1, - category2, - zonedTimestamp, - localDateTime, - name - ); - } - - @NonNull - @Override - public String[] getDefaultResultColumns() { - return $defaultResultColumns; - } - - @NonNull - @Override - public String getCreateTableStatement() { - return "CREATE TABLE `Item2` (`category1` INTEGER NOT NULL REFERENCES `Category`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, `category2` INTEGER REFERENCES `Category`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, `zonedTimestamp` TEXT NOT NULL, `localDateTime` TEXT NOT NULL, `name` TEXT PRIMARY KEY)"; - } - - @NonNull - @Override - public List getCreateIndexStatements() { - return Arrays.asList( - "CREATE INDEX `index_category1_on_Item2` ON `Item2` (`category1`)", - "CREATE INDEX `index_category2_on_Item2` ON `Item2` (`category2`)" - ); - } - - @NonNull - @Override - public String getDropTableStatement() { - return "DROP TABLE IF EXISTS `Item2`"; - } - - @NonNull - @Override - public String getInsertStatement(@OnConflict int onConflictAlgorithm, boolean withoutAutoId) { - StringBuilder s = new StringBuilder(); - s.append("INSERT"); - switch (onConflictAlgorithm) { - case OnConflict.NONE: /* nop */ break; - case OnConflict.ABORT: s.append(" OR ABORT"); break; - case OnConflict.FAIL: s.append(" OR FAIL"); break; - case OnConflict.IGNORE: s.append(" OR IGNORE"); break; - case OnConflict.REPLACE: s.append(" OR REPLACE"); break; - case OnConflict.ROLLBACK: s.append(" OR ROLLBACK"); break; - default: throw new IllegalArgumentException("Invalid OnConflict algorithm: " + onConflictAlgorithm); - } - s.append(" INTO `Item2` (`category1`,`category2`,`zonedTimestamp`,`localDateTime`,`name`) VALUES (?,?,?,?,?)"); - return s.toString(); - } - - /** - * Convert a model to {@code ContentValues). You can use the content values for UPDATE and/or INSERT. - */ - @NonNull - @Override - public ContentValues convertToContentValues(@NonNull OrmaConnection conn, @NonNull Item2 model, - boolean withoutAutoId) { - ContentValues contentValues = new ContentValues(); - contentValues.put("category1", model.category1.id); - if (model.category2 != null) { - contentValues.put("category2", model.category2.id); - } - else { - contentValues.putNull("category2"); - } - contentValues.put("zonedTimestamp", TypeAdapters.serializeZonedDateTime(model.zonedTimestamp)); - contentValues.put("localDateTime", TypeAdapters.serializeLocalDateTime(model.localDateTime)); - contentValues.put("name", model.name); - return contentValues; - } - - /** - * Convert a model to {@code Object[]}. Provided for debugging. - */ - @NonNull - @Override - public Object[] convertToArgs(@NonNull OrmaConnection conn, @NonNull Item2 model, - boolean withoutAutoId) { - Object[] args = new Object[5]; - if (model.category1 != null) { - args[0] = model.category1.id; - } - else { - throw new IllegalArgumentException("Item2.category1" + " must not be null, or use @Nullable to declare it as NULL"); - } - if (model.category2 != null) { - args[1] = model.category2.id; - } - if (model.zonedTimestamp != null) { - args[2] = TypeAdapters.serializeZonedDateTime(model.zonedTimestamp); - } - else { - throw new IllegalArgumentException("Item2.zonedTimestamp" + " must not be null, or use @Nullable to declare it as NULL"); - } - if (model.localDateTime != null) { - args[3] = TypeAdapters.serializeLocalDateTime(model.localDateTime); - } - else { - throw new IllegalArgumentException("Item2.localDateTime" + " must not be null, or use @Nullable to declare it as NULL"); - } - if (model.name != null) { - args[4] = model.name; - } - else { - throw new IllegalArgumentException("Item2.name" + " must not be null, or use @Nullable to declare it as NULL"); - } - return args; - } - - @Override - public void bindArgs(@NonNull OrmaConnection conn, @NonNull DatabaseStatement statement, - @NonNull Item2 model, boolean withoutAutoId) { - statement.bindLong(1, model.category1.id); - if (model.category2 != null) { - statement.bindLong(2, model.category2.id); - } - else { - statement.bindNull(2); - } - statement.bindString(3, TypeAdapters.serializeZonedDateTime(model.zonedTimestamp)); - statement.bindString(4, TypeAdapters.serializeLocalDateTime(model.localDateTime)); - statement.bindString(5, model.name); - } - - @NonNull - @Override - public Item2 newModelFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, - int offset) { - Item2 model = new Item2(); - model.category1 = Category_Schema.INSTANCE.newModelFromCursor(conn, cursor, offset + 0 + 1) /* consumes items: 2 */; - model.category2 = cursor.isNull(offset + 3 + 2) ? null : Category_Schema.INSTANCE.newModelFromCursor(conn, cursor, offset + 3 + 1) /* consumes items: 2 */; - model.zonedTimestamp = TypeAdapters.deserializeZonedDateTime(cursor.getString(offset + 6)); - model.localDateTime = TypeAdapters.deserializeLocalDateTime(cursor.getString(offset + 7)); - model.name = cursor.getString(offset + 8); - return model; - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Selector.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Selector.java deleted file mode 100644 index 3f5d331e..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Selector.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.function.Function1; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxSelector; -import java.util.Arrays; -import java.util.Collection; - -public class Item2_Selector extends RxSelector { - final Item2_Schema schema; - - public Item2_Selector(RxOrmaConnection conn, Item2_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item2_Selector(Item2_Selector that) { - super(that); - this.schema = that.getSchema(); - } - - public Item2_Selector(Item2_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Item2_Selector clone() { - return new Item2_Selector(this); - } - - @NonNull - @Override - public Item2_Schema getSchema() { - return schema; - } - - public Item2_Selector category1Eq(@NonNull Category category1) { - return where(schema.category1, "=", category1.id); - } - - public Item2_Selector category1Eq(long category1Id) { - return where(schema.category1, "=", category1Id); - } - - public Item2_Selector category1( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category1.associationSchema)).appendTo(this); - } - - public Item2_Selector category2IsNull() { - return where(schema.category2, " IS NULL"); - } - - public Item2_Selector category2IsNotNull() { - return where(schema.category2, " IS NOT NULL"); - } - - public Item2_Selector category2Eq(@NonNull Category category2) { - return where(schema.category2, "=", category2.id); - } - - public Item2_Selector category2Eq(long category2Id) { - return where(schema.category2, "=", category2Id); - } - - public Item2_Selector category2( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category2.associationSchema)).appendTo(this); - } - - public Item2_Selector nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item2_Selector nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item2_Selector nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item2_Selector nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item2_Selector nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item2_Selector nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item2_Selector nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item2_Selector nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item2_Selector nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item2_Selector nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } - - public Item2_Selector orderByCategory1Asc() { - return orderBy(schema.category1.orderInAscending()); - } - - public Item2_Selector orderByCategory1Desc() { - return orderBy(schema.category1.orderInDescending()); - } - - public Item2_Selector orderByCategory2Asc() { - return orderBy(schema.category2.orderInAscending()); - } - - public Item2_Selector orderByCategory2Desc() { - return orderBy(schema.category2.orderInDescending()); - } - - public Item2_Selector orderByNameAsc() { - return orderBy(schema.name.orderInAscending()); - } - - public Item2_Selector orderByNameDesc() { - return orderBy(schema.name.orderInDescending()); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Updater.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Updater.java deleted file mode 100644 index 4d88e92e..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item2_Updater.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.github.gfx.android.orma.example.tool.TypeAdapters; -import com.github.gfx.android.orma.function.Function1; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxUpdater; -import java.util.Arrays; -import java.util.Collection; -import org.threeten.bp.LocalDateTime; -import org.threeten.bp.ZonedDateTime; - -public class Item2_Updater extends RxUpdater { - final Item2_Schema schema; - - public Item2_Updater(RxOrmaConnection conn, Item2_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item2_Updater(Item2_Updater that) { - super(that); - this.schema = that.getSchema(); - } - - public Item2_Updater(Item2_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Item2_Updater clone() { - return new Item2_Updater(this); - } - - @NonNull - @Override - public Item2_Schema getSchema() { - return schema; - } - - public Item2_Updater category1(@NonNull Category category1) { - contents.put("`category1`", category1.id); - return this; - } - - public Item2_Updater category2(@Nullable Category category2) { - contents.put("`category2`", category2.id); - return this; - } - - public Item2_Updater zonedTimestamp(@NonNull ZonedDateTime zonedTimestamp) { - contents.put("`zonedTimestamp`", TypeAdapters.serializeZonedDateTime(zonedTimestamp)); - return this; - } - - public Item2_Updater localDateTime(@NonNull LocalDateTime localDateTime) { - contents.put("`localDateTime`", TypeAdapters.serializeLocalDateTime(localDateTime)); - return this; - } - - public Item2_Updater name(@NonNull String name) { - contents.put("`name`", name); - return this; - } - - public Item2_Updater category1Eq(@NonNull Category category1) { - return where(schema.category1, "=", category1.id); - } - - public Item2_Updater category1Eq(long category1Id) { - return where(schema.category1, "=", category1Id); - } - - public Item2_Updater category1( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category1.associationSchema)).appendTo(this); - } - - public Item2_Updater category2IsNull() { - return where(schema.category2, " IS NULL"); - } - - public Item2_Updater category2IsNotNull() { - return where(schema.category2, " IS NOT NULL"); - } - - public Item2_Updater category2Eq(@NonNull Category category2) { - return where(schema.category2, "=", category2.id); - } - - public Item2_Updater category2Eq(long category2Id) { - return where(schema.category2, "=", category2Id); - } - - public Item2_Updater category2( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category2.associationSchema)).appendTo(this); - } - - public Item2_Updater nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item2_Updater nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item2_Updater nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item2_Updater nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item2_Updater nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item2_Updater nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item2_Updater nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item2_Updater nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item2_Updater nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item2_Updater nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_AssociationCondition.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_AssociationCondition.java deleted file mode 100644 index 963cf720..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_AssociationCondition.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.AssociationCondition; -import com.github.gfx.android.orma.OrmaConnection; -import com.github.gfx.android.orma.function.Function1; -import java.util.Arrays; -import java.util.Collection; - -public class Item_AssociationCondition extends AssociationCondition { - final Item_Schema schema; - - public Item_AssociationCondition(OrmaConnection conn, Item_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item_AssociationCondition(Item_AssociationCondition that) { - super(that); - this.schema = that.getSchema(); - } - - public Item_AssociationCondition(Item_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Item_AssociationCondition clone() { - return new Item_AssociationCondition(this); - } - - @NonNull - @Override - public Item_Schema getSchema() { - return schema; - } - - public Item_AssociationCondition categoryEq(@NonNull Category category) { - return where(schema.category, "=", category.id); - } - - public Item_AssociationCondition categoryEq(long categoryId) { - return where(schema.category, "=", categoryId); - } - - public Item_AssociationCondition category( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category.associationSchema)).appendTo(this); - } - - public Item_AssociationCondition nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item_AssociationCondition nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item_AssociationCondition nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item_AssociationCondition nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item_AssociationCondition nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item_AssociationCondition nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item_AssociationCondition nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item_AssociationCondition nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item_AssociationCondition nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item_AssociationCondition nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Deleter.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Deleter.java deleted file mode 100644 index 3b1bebc1..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Deleter.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.function.Function1; -import com.github.gfx.android.orma.rx.RxDeleter; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import java.util.Arrays; -import java.util.Collection; - -public class Item_Deleter extends RxDeleter { - final Item_Schema schema; - - public Item_Deleter(RxOrmaConnection conn, Item_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item_Deleter(Item_Deleter that) { - super(that); - this.schema = that.getSchema(); - } - - public Item_Deleter(Item_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Item_Deleter clone() { - return new Item_Deleter(this); - } - - @NonNull - @Override - public Item_Schema getSchema() { - return schema; - } - - public Item_Deleter categoryEq(@NonNull Category category) { - return where(schema.category, "=", category.id); - } - - public Item_Deleter categoryEq(long categoryId) { - return where(schema.category, "=", categoryId); - } - - public Item_Deleter category( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category.associationSchema)).appendTo(this); - } - - public Item_Deleter nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item_Deleter nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item_Deleter nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item_Deleter nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item_Deleter nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item_Deleter nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item_Deleter nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item_Deleter nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item_Deleter nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item_Deleter nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Relation.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Relation.java deleted file mode 100644 index a9056612..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Relation.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.function.Function1; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxRelation; -import java.util.Arrays; -import java.util.Collection; - -public class Item_Relation extends RxRelation { - final Item_Schema schema; - - public Item_Relation(RxOrmaConnection conn, Item_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item_Relation(Item_Relation that) { - super(that); - this.schema = that.getSchema(); - } - - @Override - public Item_Relation clone() { - return new Item_Relation(this); - } - - @NonNull - @Override - public Item_Schema getSchema() { - return schema; - } - - @NonNull - @CheckResult - public Item reload(@NonNull Item model) { - return selector().nameEq(model.name).value(); - } - - @NonNull - @Override - public Item upsertWithoutTransaction(@NonNull Item model) { - ContentValues contentValues = new ContentValues(); - contentValues.put("`category`", new Category_Relation(conn, Category_Schema.INSTANCE).upsertWithoutTransaction(model.category).id); - contentValues.put("`name`", model.name); - int updatedRows = updater().nameEq(model.name).putAll(contentValues).execute(); - if (updatedRows != 0) { - return selector().nameEq(model.name).value(); - } - long rowId = conn.insert(schema, contentValues, OnConflict.NONE); - return conn.findByRowId(schema, rowId); - } - - @NonNull - @Override - public Item_Selector selector() { - return new Item_Selector(this); - } - - @NonNull - @Override - public Item_Updater updater() { - return new Item_Updater(this); - } - - @NonNull - @Override - public Item_Deleter deleter() { - return new Item_Deleter(this); - } - - public Item_Relation categoryEq(@NonNull Category category) { - return where(schema.category, "=", category.id); - } - - public Item_Relation categoryEq(long categoryId) { - return where(schema.category, "=", categoryId); - } - - public Item_Relation category( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category.associationSchema)).appendTo(this); - } - - public Item_Relation nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item_Relation nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item_Relation nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item_Relation nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item_Relation nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item_Relation nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item_Relation nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item_Relation nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item_Relation nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item_Relation nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } - - public Item_Relation orderByCategoryAsc() { - return orderBy(schema.category.orderInAscending()); - } - - public Item_Relation orderByCategoryDesc() { - return orderBy(schema.category.orderInDescending()); - } - - public Item_Relation orderByNameAsc() { - return orderBy(schema.name.orderInAscending()); - } - - public Item_Relation orderByNameDesc() { - return orderBy(schema.name.orderInDescending()); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Schema.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Schema.java deleted file mode 100644 index a60d414a..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Schema.java +++ /dev/null @@ -1,232 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import android.database.Cursor; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.github.gfx.android.orma.AssociationDef; -import com.github.gfx.android.orma.ColumnDef; -import com.github.gfx.android.orma.OrmaConnection; -import com.github.gfx.android.orma.Schema; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.core.DatabaseStatement; -import com.github.gfx.android.orma.internal.Aliases; -import com.github.gfx.android.orma.internal.Schemas; -import java.util.Arrays; -import java.util.List; - -public class Item_Schema implements Schema { - public static final Item_Schema INSTANCE = Schemas.register(new Item_Schema()); - - @Nullable - private final String $alias; - - public final AssociationDef category; - - public final ColumnDef name; - - private final String[] $defaultResultColumns; - - public Item_Schema() { - this(new Aliases().createPath("Item")); - } - - public Item_Schema(@Nullable Aliases.ColumnPath current) { - $alias = current != null ? current.getAlias() : null; - this.name = new ColumnDef(this, "name", String.class, "TEXT", ColumnDef.PRIMARY_KEY) { - @Override - @NonNull - public String get(@NonNull Item model) { - return model.name; - } - - @NonNull - @Override - public String getSerialized(@NonNull Item model) { - return model.name; - } - - @NonNull - @Override - public String getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.getString(index); - } - }; - this.category = new AssociationDef(this, "category", Category.class, "INTEGER", ColumnDef.INDEXED, new Category_Schema(current != null ? current.add("category", "Category") : null)) { - @Override - @NonNull - public Category get(@NonNull Item model) { - return model.category; - } - - @NonNull - @Override - public Long getSerialized(@NonNull Item model) { - return model.category.id; - } - - @NonNull - @Override - public Category getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, - int index) { - return Category_Schema.INSTANCE.newModelFromCursor(conn, cursor, index + 1) /* consumes items: 2 */; - } - }; - $defaultResultColumns = new String[]{ - category.getQualifiedName(), - category.associationSchema.name.getQualifiedName(), - category.associationSchema.id.getQualifiedName() - , - name.getQualifiedName() - }; - } - - @NonNull - @Override - public Class getModelClass() { - return Item.class; - } - - @NonNull - @Override - public String getTableName() { - return "Item"; - } - - @NonNull - @Override - public String getEscapedTableName() { - return "`Item`"; - } - - @Nullable - @Override - public String getTableAlias() { - return $alias; - } - - @Nullable - @Override - public String getEscapedTableAlias() { - return $alias != null ? '`' + $alias + '`' : null; - } - - @NonNull - @Override - public String getSelectFromTableClause() { - return "`Item`"+ " AS " + getEscapedTableAlias() - + " LEFT OUTER JOIN `Category` AS " + category.associationSchema.getEscapedTableAlias() + " ON " + category.getQualifiedName() + " = " + category.associationSchema.id.getQualifiedName() - - ; - } - - @NonNull - @Override - public ColumnDef getPrimaryKey() { - return name; - } - - @NonNull - @Override - public List> getColumns() { - return Arrays.>asList( - category, - name - ); - } - - @NonNull - @Override - public String[] getDefaultResultColumns() { - return $defaultResultColumns; - } - - @NonNull - @Override - public String getCreateTableStatement() { - return "CREATE TABLE `Item` (`category` INTEGER NOT NULL REFERENCES `Category`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, `name` TEXT PRIMARY KEY)"; - } - - @NonNull - @Override - public List getCreateIndexStatements() { - return Arrays.asList( - "CREATE INDEX `index_category_on_Item` ON `Item` (`category`)" - ); - } - - @NonNull - @Override - public String getDropTableStatement() { - return "DROP TABLE IF EXISTS `Item`"; - } - - @NonNull - @Override - public String getInsertStatement(@OnConflict int onConflictAlgorithm, boolean withoutAutoId) { - StringBuilder s = new StringBuilder(); - s.append("INSERT"); - switch (onConflictAlgorithm) { - case OnConflict.NONE: /* nop */ break; - case OnConflict.ABORT: s.append(" OR ABORT"); break; - case OnConflict.FAIL: s.append(" OR FAIL"); break; - case OnConflict.IGNORE: s.append(" OR IGNORE"); break; - case OnConflict.REPLACE: s.append(" OR REPLACE"); break; - case OnConflict.ROLLBACK: s.append(" OR ROLLBACK"); break; - default: throw new IllegalArgumentException("Invalid OnConflict algorithm: " + onConflictAlgorithm); - } - s.append(" INTO `Item` (`category`,`name`) VALUES (?,?)"); - return s.toString(); - } - - /** - * Convert a model to {@code ContentValues). You can use the content values for UPDATE and/or INSERT. - */ - @NonNull - @Override - public ContentValues convertToContentValues(@NonNull OrmaConnection conn, @NonNull Item model, - boolean withoutAutoId) { - ContentValues contentValues = new ContentValues(); - contentValues.put("category", model.category.id); - contentValues.put("name", model.name); - return contentValues; - } - - /** - * Convert a model to {@code Object[]}. Provided for debugging. - */ - @NonNull - @Override - public Object[] convertToArgs(@NonNull OrmaConnection conn, @NonNull Item model, - boolean withoutAutoId) { - Object[] args = new Object[2]; - if (model.category != null) { - args[0] = model.category.id; - } - else { - throw new IllegalArgumentException("Item.category" + " must not be null, or use @Nullable to declare it as NULL"); - } - if (model.name != null) { - args[1] = model.name; - } - else { - throw new IllegalArgumentException("Item.name" + " must not be null, or use @Nullable to declare it as NULL"); - } - return args; - } - - @Override - public void bindArgs(@NonNull OrmaConnection conn, @NonNull DatabaseStatement statement, - @NonNull Item model, boolean withoutAutoId) { - statement.bindLong(1, model.category.id); - statement.bindString(2, model.name); - } - - @NonNull - @Override - public Item newModelFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int offset) { - Category category = Category_Schema.INSTANCE.newModelFromCursor(conn, cursor, offset + 0 + 1) /* consumes items: 2 */; - String name = cursor.getString(offset + 3); - return new Item(name, category); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Selector.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Selector.java deleted file mode 100644 index 7e3cd8fb..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Selector.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.function.Function1; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxSelector; -import java.util.Arrays; -import java.util.Collection; - -public class Item_Selector extends RxSelector { - final Item_Schema schema; - - public Item_Selector(RxOrmaConnection conn, Item_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item_Selector(Item_Selector that) { - super(that); - this.schema = that.getSchema(); - } - - public Item_Selector(Item_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Item_Selector clone() { - return new Item_Selector(this); - } - - @NonNull - @Override - public Item_Schema getSchema() { - return schema; - } - - public Item_Selector categoryEq(@NonNull Category category) { - return where(schema.category, "=", category.id); - } - - public Item_Selector categoryEq(long categoryId) { - return where(schema.category, "=", categoryId); - } - - public Item_Selector category( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category.associationSchema)).appendTo(this); - } - - public Item_Selector nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item_Selector nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item_Selector nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item_Selector nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item_Selector nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item_Selector nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item_Selector nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item_Selector nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item_Selector nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item_Selector nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } - - public Item_Selector orderByCategoryAsc() { - return orderBy(schema.category.orderInAscending()); - } - - public Item_Selector orderByCategoryDesc() { - return orderBy(schema.category.orderInDescending()); - } - - public Item_Selector orderByNameAsc() { - return orderBy(schema.name.orderInAscending()); - } - - public Item_Selector orderByNameDesc() { - return orderBy(schema.name.orderInDescending()); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Updater.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Updater.java deleted file mode 100644 index 3073a808..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Item_Updater.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.function.Function1; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxUpdater; -import java.util.Arrays; -import java.util.Collection; - -public class Item_Updater extends RxUpdater { - final Item_Schema schema; - - public Item_Updater(RxOrmaConnection conn, Item_Schema schema) { - super(conn); - this.schema = schema; - } - - public Item_Updater(Item_Updater that) { - super(that); - this.schema = that.getSchema(); - } - - public Item_Updater(Item_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Item_Updater clone() { - return new Item_Updater(this); - } - - @NonNull - @Override - public Item_Schema getSchema() { - return schema; - } - - public Item_Updater category(@NonNull Category category) { - contents.put("`category`", category.id); - return this; - } - - public Item_Updater name(@NonNull String name) { - contents.put("`name`", name); - return this; - } - - public Item_Updater categoryEq(@NonNull Category category) { - return where(schema.category, "=", category.id); - } - - public Item_Updater categoryEq(long categoryId) { - return where(schema.category, "=", categoryId); - } - - public Item_Updater category( - @NonNull Function1 block) { - return block.apply(new Category_AssociationCondition(getConnection(), schema.category.associationSchema)).appendTo(this); - } - - public Item_Updater nameEq(@NonNull String name) { - return where(schema.name, "=", name); - } - - public Item_Updater nameNotEq(@NonNull String name) { - return where(schema.name, "<>", name); - } - - public Item_Updater nameIn(@NonNull Collection values) { - return in(false, schema.name, values); - } - - public Item_Updater nameNotIn(@NonNull Collection values) { - return in(true, schema.name, values); - } - - public final Item_Updater nameIn(@NonNull String... values) { - return nameIn(Arrays.asList(values)); - } - - public final Item_Updater nameNotIn(@NonNull String... values) { - return nameNotIn(Arrays.asList(values)); - } - - public Item_Updater nameLt(@NonNull String name) { - return where(schema.name, "<", name); - } - - public Item_Updater nameLe(@NonNull String name) { - return where(schema.name, "<=", name); - } - - public Item_Updater nameGt(@NonNull String name) { - return where(schema.name, ">", name); - } - - public Item_Updater nameGe(@NonNull String name) { - return where(schema.name, ">=", name); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/OrmaDatabase.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/OrmaDatabase.java deleted file mode 100644 index 32e00e3f..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/OrmaDatabase.java +++ /dev/null @@ -1,704 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteConstraintException; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; -import androidx.annotation.WorkerThread; -import com.github.gfx.android.orma.DatabaseHandle; -import com.github.gfx.android.orma.ModelFactory; -import com.github.gfx.android.orma.OrmaDatabaseBuilderBase; -import com.github.gfx.android.orma.Schema; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.rx.RxInserter; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import io.reactivex.Completable; -import io.reactivex.Single; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.Callable; - -/** - *

The Orma database handle class.

- *

To create instances: {@code OrmaDatabase.builder(context).build()}.

- *

To delete databases: {@code context.deleteDatabase(OrmaDatabase.Builder.getDefaultDatabaseName(context))}

- * - *

This is generated by {@code com.github.gfx.android.orma.processor.OrmaProcessor}.

- */ -public class OrmaDatabase implements DatabaseHandle { - /** - * The SHA-256 digest of all the {@code CREATE TABLE} and {@code CREATE INDEX} statements. - */ - public static String SCHEMA_HASH = "B180A070B8F2FE2CBEBE4B6F7B5E56FA8ED0C61FEB7AA492B2830EE71522E036"; - - public static final List> SCHEMAS = Arrays.>asList( - Item2_Schema.INSTANCE, - Category_Schema.INSTANCE, - Todo_Schema.INSTANCE, - Entry_Schema.INSTANCE, - Item_Schema.INSTANCE - ); - - private final RxOrmaConnection connection; - - public OrmaDatabase(@NonNull RxOrmaConnection connection) { - this.connection = connection; - } - - public static Builder builder(@NonNull Context context) { - return new Builder(context); - } - - @NonNull - @Override - public List> getSchemas() { - return SCHEMAS; - } - - /** - *

{@code migrate()} invokes database migration, which will takes several seconds.

- *

This is completely optional and migration is invoked on the first access of the database, anyway.

- * - * @throws SQLiteConstraintException migration information is not sufficient. - */ - public void migrate() throws SQLiteConstraintException { - connection.getWritableDatabase(); - } - - @NonNull - @Override - public RxOrmaConnection getConnection() { - return connection; - } - - @WorkerThread - public void transactionSync(@NonNull Runnable task) { - connection.transactionSync(task); - } - - public void transactionNonExclusiveSync(@NonNull Runnable task) { - connection.transactionNonExclusiveSync(task); - } - - /** - * RxJava 2.x {@code Completable} wrapper to {@link #transactionSync(Runnable)} - */ - @CheckResult - public Completable transactionAsCompletable(@NonNull final Runnable task) { - return Completable.fromRunnable(new Runnable() { - @Override - public void run() { - transactionSync(task); - } - }); - } - - /** - * RxJava 2.x {@code Completable} wrapper to {@link #transactionNonExclusiveSync(Runnable)} - */ - @CheckResult - public Completable transactionNonExclusiveAsCompletable(@NonNull final Runnable task) { - return Completable.fromRunnable(new Runnable() { - @Override - public void run() { - transactionNonExclusiveSync(task); - } - }); - } - - public void deleteAll() { - connection.deleteAll(); - } - - /** - * Retrieves a model from a cursor. */ - @NonNull - public Item2 newItem2FromCursor(@NonNull Cursor cursor) { - return Item2_Schema.INSTANCE.newModelFromCursor(connection, cursor, 0); - } - - /** - * Inserts a model created by {@code ModelFactory}, and retrieves it which is just inserted. - * The return value has the row ID. - */ - @NonNull - @WorkerThread - public Item2 createItem2(@NonNull ModelFactory factory) { - return connection.createModel(Item2_Schema.INSTANCE, factory); - } - - /** - * Creates a relation of {@code Item2}, which is an entry point of all the operations. - */ - @NonNull - public Item2_Relation relationOfItem2() { - return new Item2_Relation(connection, Item2_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code SELECT * FROM Item2 ...}. - */ - @NonNull - public Item2_Selector selectFromItem2() { - return new Item2_Selector(connection, Item2_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code UPDATE Item2 ...}. - */ - @WorkerThread - @NonNull - public Item2_Updater updateItem2() { - return new Item2_Updater(connection, Item2_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code DELETE FROM Item2 ...}. - */ - @WorkerThread - @NonNull - public Item2_Deleter deleteFromItem2() { - return new Item2_Deleter(connection, Item2_Schema.INSTANCE); - } - - /** - * Executes a query: {@code INSERT INTO Item2 ...}. - */ - @WorkerThread - public long insertIntoItem2(@NonNull Item2 model) { - return prepareInsertIntoItem2().executeAndClose(model); - } - - /** - * Create a prepared statement for {@code INSERT INTO Item2 ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoItem2() { - return prepareInsertIntoItem2(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Item2 ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoItem2(@OnConflict int onConflictAlgorithm) { - return prepareInsertIntoItem2(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Item2 ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoItem2(@OnConflict int onConflictAlgorithm, - boolean withoutAutoId) { - return new RxInserter(connection, Item2_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - - /** - * Create a prepared statement for {@code INSERT INTO Item2 ...}. - */ - @CheckResult - public Single> prepareInsertIntoItem2AsSingle() { - return prepareInsertIntoItem2AsSingle(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Item2 ...}. - */ - @CheckResult - public Single> prepareInsertIntoItem2AsSingle( - @OnConflict int onConflictAlgorithm) { - return prepareInsertIntoItem2AsSingle(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Item2 ...}. - */ - @CheckResult - public Single> prepareInsertIntoItem2AsSingle( - @OnConflict final int onConflictAlgorithm, final boolean withoutAutoId) { - return Single.fromCallable(new Callable>() { - @Override - public RxInserter call() throws Exception { - return new RxInserter(connection, Item2_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - }); - } - - /** - * Retrieves a model from a cursor. */ - @NonNull - public Category newCategoryFromCursor(@NonNull Cursor cursor) { - return Category_Schema.INSTANCE.newModelFromCursor(connection, cursor, 0); - } - - /** - * Inserts a model created by {@code ModelFactory}, and retrieves it which is just inserted. - * The return value has the row ID. - */ - @NonNull - @WorkerThread - public Category createCategory(@NonNull ModelFactory factory) { - return connection.createModel(Category_Schema.INSTANCE, factory); - } - - /** - * Creates a relation of {@code Category}, which is an entry point of all the operations. - */ - @NonNull - public Category_Relation relationOfCategory() { - return new Category_Relation(connection, Category_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code SELECT * FROM Category ...}. - */ - @NonNull - public Category_Selector selectFromCategory() { - return new Category_Selector(connection, Category_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code UPDATE Category ...}. - */ - @WorkerThread - @NonNull - public Category_Updater updateCategory() { - return new Category_Updater(connection, Category_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code DELETE FROM Category ...}. - */ - @WorkerThread - @NonNull - public Category_Deleter deleteFromCategory() { - return new Category_Deleter(connection, Category_Schema.INSTANCE); - } - - /** - * Executes a query: {@code INSERT INTO Category ...}. - */ - @WorkerThread - public long insertIntoCategory(@NonNull Category model) { - return prepareInsertIntoCategory().executeAndClose(model); - } - - /** - * Create a prepared statement for {@code INSERT INTO Category ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoCategory() { - return prepareInsertIntoCategory(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Category ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoCategory(@OnConflict int onConflictAlgorithm) { - return prepareInsertIntoCategory(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Category ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoCategory(@OnConflict int onConflictAlgorithm, - boolean withoutAutoId) { - return new RxInserter(connection, Category_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - - /** - * Create a prepared statement for {@code INSERT INTO Category ...}. - */ - @CheckResult - public Single> prepareInsertIntoCategoryAsSingle() { - return prepareInsertIntoCategoryAsSingle(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Category ...}. - */ - @CheckResult - public Single> prepareInsertIntoCategoryAsSingle( - @OnConflict int onConflictAlgorithm) { - return prepareInsertIntoCategoryAsSingle(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Category ...}. - */ - @CheckResult - public Single> prepareInsertIntoCategoryAsSingle( - @OnConflict final int onConflictAlgorithm, final boolean withoutAutoId) { - return Single.fromCallable(new Callable>() { - @Override - public RxInserter call() throws Exception { - return new RxInserter(connection, Category_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - }); - } - - /** - * Retrieves a model from a cursor. */ - @NonNull - public Todo newTodoFromCursor(@NonNull Cursor cursor) { - return Todo_Schema.INSTANCE.newModelFromCursor(connection, cursor, 0); - } - - /** - * Inserts a model created by {@code ModelFactory}, and retrieves it which is just inserted. - * The return value has the row ID. - */ - @NonNull - @WorkerThread - public Todo createTodo(@NonNull ModelFactory factory) { - return connection.createModel(Todo_Schema.INSTANCE, factory); - } - - /** - * Creates a relation of {@code Todo}, which is an entry point of all the operations. - */ - @NonNull - public Todo_Relation relationOfTodo() { - return new Todo_Relation(connection, Todo_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code SELECT * FROM Todo ...}. - */ - @NonNull - public Todo_Selector selectFromTodo() { - return new Todo_Selector(connection, Todo_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code UPDATE Todo ...}. - */ - @WorkerThread - @NonNull - public Todo_Updater updateTodo() { - return new Todo_Updater(connection, Todo_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code DELETE FROM Todo ...}. - */ - @WorkerThread - @NonNull - public Todo_Deleter deleteFromTodo() { - return new Todo_Deleter(connection, Todo_Schema.INSTANCE); - } - - /** - * Executes a query: {@code INSERT INTO Todo ...}. - */ - @WorkerThread - public long insertIntoTodo(@NonNull Todo model) { - return prepareInsertIntoTodo().executeAndClose(model); - } - - /** - * Create a prepared statement for {@code INSERT INTO Todo ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoTodo() { - return prepareInsertIntoTodo(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Todo ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoTodo(@OnConflict int onConflictAlgorithm) { - return prepareInsertIntoTodo(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Todo ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoTodo(@OnConflict int onConflictAlgorithm, - boolean withoutAutoId) { - return new RxInserter(connection, Todo_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - - /** - * Create a prepared statement for {@code INSERT INTO Todo ...}. - */ - @CheckResult - public Single> prepareInsertIntoTodoAsSingle() { - return prepareInsertIntoTodoAsSingle(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Todo ...}. - */ - @CheckResult - public Single> prepareInsertIntoTodoAsSingle( - @OnConflict int onConflictAlgorithm) { - return prepareInsertIntoTodoAsSingle(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Todo ...}. - */ - @CheckResult - public Single> prepareInsertIntoTodoAsSingle( - @OnConflict final int onConflictAlgorithm, final boolean withoutAutoId) { - return Single.fromCallable(new Callable>() { - @Override - public RxInserter call() throws Exception { - return new RxInserter(connection, Todo_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - }); - } - - /** - * Retrieves a model from a cursor. */ - @NonNull - public Entry newEntryFromCursor(@NonNull Cursor cursor) { - return Entry_Schema.INSTANCE.newModelFromCursor(connection, cursor, 0); - } - - /** - * Inserts a model created by {@code ModelFactory}, and retrieves it which is just inserted. - * The return value has the row ID. - */ - @NonNull - @WorkerThread - public Entry createEntry(@NonNull ModelFactory factory) { - return connection.createModel(Entry_Schema.INSTANCE, factory); - } - - /** - * Creates a relation of {@code Entry}, which is an entry point of all the operations. - */ - @NonNull - public Entry_Relation relationOfEntry() { - return new Entry_Relation(connection, Entry_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code SELECT * FROM Entry ...}. - */ - @NonNull - public Entry_Selector selectFromEntry() { - return new Entry_Selector(connection, Entry_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code UPDATE Entry ...}. - */ - @WorkerThread - @NonNull - public Entry_Updater updateEntry() { - return new Entry_Updater(connection, Entry_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code DELETE FROM Entry ...}. - */ - @WorkerThread - @NonNull - public Entry_Deleter deleteFromEntry() { - return new Entry_Deleter(connection, Entry_Schema.INSTANCE); - } - - /** - * Executes a query: {@code INSERT INTO Entry ...}. - */ - @WorkerThread - public long insertIntoEntry(@NonNull Entry model) { - return prepareInsertIntoEntry().executeAndClose(model); - } - - /** - * Create a prepared statement for {@code INSERT INTO Entry ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoEntry() { - return prepareInsertIntoEntry(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Entry ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoEntry(@OnConflict int onConflictAlgorithm) { - return prepareInsertIntoEntry(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Entry ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoEntry(@OnConflict int onConflictAlgorithm, - boolean withoutAutoId) { - return new RxInserter(connection, Entry_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - - /** - * Create a prepared statement for {@code INSERT INTO Entry ...}. - */ - @CheckResult - public Single> prepareInsertIntoEntryAsSingle() { - return prepareInsertIntoEntryAsSingle(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Entry ...}. - */ - @CheckResult - public Single> prepareInsertIntoEntryAsSingle( - @OnConflict int onConflictAlgorithm) { - return prepareInsertIntoEntryAsSingle(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Entry ...}. - */ - @CheckResult - public Single> prepareInsertIntoEntryAsSingle( - @OnConflict final int onConflictAlgorithm, final boolean withoutAutoId) { - return Single.fromCallable(new Callable>() { - @Override - public RxInserter call() throws Exception { - return new RxInserter(connection, Entry_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - }); - } - - /** - * Retrieves a model from a cursor. */ - @NonNull - public Item newItemFromCursor(@NonNull Cursor cursor) { - return Item_Schema.INSTANCE.newModelFromCursor(connection, cursor, 0); - } - - /** - * Inserts a model created by {@code ModelFactory}, and retrieves it which is just inserted. - * The return value has the row ID. - */ - @NonNull - @WorkerThread - public Item createItem(@NonNull ModelFactory factory) { - return connection.createModel(Item_Schema.INSTANCE, factory); - } - - /** - * Creates a relation of {@code Item}, which is an entry point of all the operations. - */ - @NonNull - public Item_Relation relationOfItem() { - return new Item_Relation(connection, Item_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code SELECT * FROM Item ...}. - */ - @NonNull - public Item_Selector selectFromItem() { - return new Item_Selector(connection, Item_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code UPDATE Item ...}. - */ - @WorkerThread - @NonNull - public Item_Updater updateItem() { - return new Item_Updater(connection, Item_Schema.INSTANCE); - } - - /** - * Starts building a query: {@code DELETE FROM Item ...}. - */ - @WorkerThread - @NonNull - public Item_Deleter deleteFromItem() { - return new Item_Deleter(connection, Item_Schema.INSTANCE); - } - - /** - * Executes a query: {@code INSERT INTO Item ...}. - */ - @WorkerThread - public long insertIntoItem(@NonNull Item model) { - return prepareInsertIntoItem().executeAndClose(model); - } - - /** - * Create a prepared statement for {@code INSERT INTO Item ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoItem() { - return prepareInsertIntoItem(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Item ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoItem(@OnConflict int onConflictAlgorithm) { - return prepareInsertIntoItem(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Item ...}. - */ - @WorkerThread - public RxInserter prepareInsertIntoItem(@OnConflict int onConflictAlgorithm, - boolean withoutAutoId) { - return new RxInserter(connection, Item_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - - /** - * Create a prepared statement for {@code INSERT INTO Item ...}. - */ - @CheckResult - public Single> prepareInsertIntoItemAsSingle() { - return prepareInsertIntoItemAsSingle(OnConflict.NONE, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Item ...}. - */ - @CheckResult - public Single> prepareInsertIntoItemAsSingle( - @OnConflict int onConflictAlgorithm) { - return prepareInsertIntoItemAsSingle(onConflictAlgorithm, true); - } - - /** - * Create a prepared statement for {@code INSERT OR ... INTO Item ...}. - */ - @CheckResult - public Single> prepareInsertIntoItemAsSingle( - @OnConflict final int onConflictAlgorithm, final boolean withoutAutoId) { - return Single.fromCallable(new Callable>() { - @Override - public RxInserter call() throws Exception { - return new RxInserter(connection, Item_Schema.INSTANCE, onConflictAlgorithm, withoutAutoId); - } - }); - } - - public static class Builder extends OrmaDatabaseBuilderBase { - public Builder(@NonNull Context context) { - super(context); - } - - @NonNull - @Override - protected String getSchemaHash() { - return SCHEMA_HASH; - } - - public OrmaDatabase build() { - return new OrmaDatabase(new RxOrmaConnection(fillDefaults(), SCHEMAS)); - } - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_AssociationCondition.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_AssociationCondition.java deleted file mode 100644 index e679fc74..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_AssociationCondition.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.AssociationCondition; -import com.github.gfx.android.orma.OrmaConnection; -import java.util.Arrays; -import java.util.Collection; - -public class Todo_AssociationCondition extends AssociationCondition { - final Todo_Schema schema; - - public Todo_AssociationCondition(OrmaConnection conn, Todo_Schema schema) { - super(conn); - this.schema = schema; - } - - public Todo_AssociationCondition(Todo_AssociationCondition that) { - super(that); - this.schema = that.getSchema(); - } - - public Todo_AssociationCondition(Todo_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Todo_AssociationCondition clone() { - return new Todo_AssociationCondition(this); - } - - @NonNull - @Override - public Todo_Schema getSchema() { - return schema; - } - - public Todo_AssociationCondition titleEq(@NonNull String title) { - return where(schema.title, "=", title); - } - - public Todo_AssociationCondition titleNotEq(@NonNull String title) { - return where(schema.title, "<>", title); - } - - public Todo_AssociationCondition titleIn(@NonNull Collection values) { - return in(false, schema.title, values); - } - - public Todo_AssociationCondition titleNotIn(@NonNull Collection values) { - return in(true, schema.title, values); - } - - public final Todo_AssociationCondition titleIn(@NonNull String... values) { - return titleIn(Arrays.asList(values)); - } - - public final Todo_AssociationCondition titleNotIn(@NonNull String... values) { - return titleNotIn(Arrays.asList(values)); - } - - public Todo_AssociationCondition titleGlob(@NonNull String pattern) { - return where(schema.title, "GLOB", pattern); - } - - public Todo_AssociationCondition titleNotGlob(@NonNull String pattern) { - return where(schema.title, "NOT GLOB", pattern); - } - - public Todo_AssociationCondition titleLike(@NonNull String pattern) { - return where(schema.title, "LIKE", pattern); - } - - public Todo_AssociationCondition titleNotLike(@NonNull String pattern) { - return where(schema.title, "NOT LIKE", pattern); - } - - public Todo_AssociationCondition titleLt(@NonNull String title) { - return where(schema.title, "<", title); - } - - public Todo_AssociationCondition titleLe(@NonNull String title) { - return where(schema.title, "<=", title); - } - - public Todo_AssociationCondition titleGt(@NonNull String title) { - return where(schema.title, ">", title); - } - - public Todo_AssociationCondition titleGe(@NonNull String title) { - return where(schema.title, ">=", title); - } - - public Todo_AssociationCondition doneEq(boolean done) { - return where(schema.done, "=", done); - } - - public Todo_AssociationCondition doneNotEq(boolean done) { - return where(schema.done, "<>", done); - } - - public Todo_AssociationCondition doneIn(@NonNull Collection values) { - return in(false, schema.done, values); - } - - public Todo_AssociationCondition doneNotIn(@NonNull Collection values) { - return in(true, schema.done, values); - } - - public final Todo_AssociationCondition doneIn(@NonNull Boolean... values) { - return doneIn(Arrays.asList(values)); - } - - public final Todo_AssociationCondition doneNotIn(@NonNull Boolean... values) { - return doneNotIn(Arrays.asList(values)); - } - - public Todo_AssociationCondition doneLt(boolean done) { - return where(schema.done, "<", done); - } - - public Todo_AssociationCondition doneLe(boolean done) { - return where(schema.done, "<=", done); - } - - public Todo_AssociationCondition doneGt(boolean done) { - return where(schema.done, ">", done); - } - - public Todo_AssociationCondition doneGe(boolean done) { - return where(schema.done, ">=", done); - } - - public Todo_AssociationCondition idEq(long id) { - return where(schema.id, "=", id); - } - - public Todo_AssociationCondition idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Todo_AssociationCondition idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Todo_AssociationCondition idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Todo_AssociationCondition idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Todo_AssociationCondition idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Todo_AssociationCondition idLt(long id) { - return where(schema.id, "<", id); - } - - public Todo_AssociationCondition idLe(long id) { - return where(schema.id, "<=", id); - } - - public Todo_AssociationCondition idGt(long id) { - return where(schema.id, ">", id); - } - - public Todo_AssociationCondition idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Todo_AssociationCondition idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Deleter.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Deleter.java deleted file mode 100644 index 8941e4b0..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Deleter.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.rx.RxDeleter; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import java.util.Arrays; -import java.util.Collection; - -public class Todo_Deleter extends RxDeleter { - final Todo_Schema schema; - - public Todo_Deleter(RxOrmaConnection conn, Todo_Schema schema) { - super(conn); - this.schema = schema; - } - - public Todo_Deleter(Todo_Deleter that) { - super(that); - this.schema = that.getSchema(); - } - - public Todo_Deleter(Todo_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Todo_Deleter clone() { - return new Todo_Deleter(this); - } - - @NonNull - @Override - public Todo_Schema getSchema() { - return schema; - } - - public Todo_Deleter titleEq(@NonNull String title) { - return where(schema.title, "=", title); - } - - public Todo_Deleter titleNotEq(@NonNull String title) { - return where(schema.title, "<>", title); - } - - public Todo_Deleter titleIn(@NonNull Collection values) { - return in(false, schema.title, values); - } - - public Todo_Deleter titleNotIn(@NonNull Collection values) { - return in(true, schema.title, values); - } - - public final Todo_Deleter titleIn(@NonNull String... values) { - return titleIn(Arrays.asList(values)); - } - - public final Todo_Deleter titleNotIn(@NonNull String... values) { - return titleNotIn(Arrays.asList(values)); - } - - public Todo_Deleter titleGlob(@NonNull String pattern) { - return where(schema.title, "GLOB", pattern); - } - - public Todo_Deleter titleNotGlob(@NonNull String pattern) { - return where(schema.title, "NOT GLOB", pattern); - } - - public Todo_Deleter titleLike(@NonNull String pattern) { - return where(schema.title, "LIKE", pattern); - } - - public Todo_Deleter titleNotLike(@NonNull String pattern) { - return where(schema.title, "NOT LIKE", pattern); - } - - public Todo_Deleter titleLt(@NonNull String title) { - return where(schema.title, "<", title); - } - - public Todo_Deleter titleLe(@NonNull String title) { - return where(schema.title, "<=", title); - } - - public Todo_Deleter titleGt(@NonNull String title) { - return where(schema.title, ">", title); - } - - public Todo_Deleter titleGe(@NonNull String title) { - return where(schema.title, ">=", title); - } - - public Todo_Deleter doneEq(boolean done) { - return where(schema.done, "=", done); - } - - public Todo_Deleter doneNotEq(boolean done) { - return where(schema.done, "<>", done); - } - - public Todo_Deleter doneIn(@NonNull Collection values) { - return in(false, schema.done, values); - } - - public Todo_Deleter doneNotIn(@NonNull Collection values) { - return in(true, schema.done, values); - } - - public final Todo_Deleter doneIn(@NonNull Boolean... values) { - return doneIn(Arrays.asList(values)); - } - - public final Todo_Deleter doneNotIn(@NonNull Boolean... values) { - return doneNotIn(Arrays.asList(values)); - } - - public Todo_Deleter doneLt(boolean done) { - return where(schema.done, "<", done); - } - - public Todo_Deleter doneLe(boolean done) { - return where(schema.done, "<=", done); - } - - public Todo_Deleter doneGt(boolean done) { - return where(schema.done, ">", done); - } - - public Todo_Deleter doneGe(boolean done) { - return where(schema.done, ">=", done); - } - - public Todo_Deleter idEq(long id) { - return where(schema.id, "=", id); - } - - public Todo_Deleter idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Todo_Deleter idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Todo_Deleter idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Todo_Deleter idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Todo_Deleter idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Todo_Deleter idLt(long id) { - return where(schema.id, "<", id); - } - - public Todo_Deleter idLe(long id) { - return where(schema.id, "<=", id); - } - - public Todo_Deleter idGt(long id) { - return where(schema.id, ">", id); - } - - public Todo_Deleter idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Todo_Deleter idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Relation.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Relation.java deleted file mode 100644 index 262cfc83..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Relation.java +++ /dev/null @@ -1,245 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.BuiltInSerializers; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxRelation; -import java.util.Arrays; -import java.util.Collection; - -public class Todo_Relation extends RxRelation { - final Todo_Schema schema; - - public Todo_Relation(RxOrmaConnection conn, Todo_Schema schema) { - super(conn); - this.schema = schema; - } - - public Todo_Relation(Todo_Relation that) { - super(that); - this.schema = that.getSchema(); - } - - @Override - public Todo_Relation clone() { - return new Todo_Relation(this); - } - - @NonNull - @Override - public Todo_Schema getSchema() { - return schema; - } - - @NonNull - @CheckResult - public Todo reload(@NonNull Todo model) { - return selector().idEq(model.id).value(); - } - - @NonNull - @Override - public Todo upsertWithoutTransaction(@NonNull Todo model) { - ContentValues contentValues = new ContentValues(); - contentValues.put("`title`", model.title); - contentValues.put("`content`", model.content != null ? model.content : null); - contentValues.put("`done`", model.done); - contentValues.put("`createdTime`", BuiltInSerializers.serializeDate(model.createdTime)); - if (model.id != 0) { - int updatedRows = updater().idEq(model.id).putAll(contentValues).execute(); - if (updatedRows != 0) { - return selector().idEq(model.id).value(); - } - } - long rowId = conn.insert(schema, contentValues, OnConflict.NONE); - return conn.findByRowId(schema, rowId); - } - - @NonNull - @Override - public Todo_Selector selector() { - return new Todo_Selector(this); - } - - @NonNull - @Override - public Todo_Updater updater() { - return new Todo_Updater(this); - } - - @NonNull - @Override - public Todo_Deleter deleter() { - return new Todo_Deleter(this); - } - - public Todo_Relation titleEq(@NonNull String title) { - return where(schema.title, "=", title); - } - - public Todo_Relation titleNotEq(@NonNull String title) { - return where(schema.title, "<>", title); - } - - public Todo_Relation titleIn(@NonNull Collection values) { - return in(false, schema.title, values); - } - - public Todo_Relation titleNotIn(@NonNull Collection values) { - return in(true, schema.title, values); - } - - public final Todo_Relation titleIn(@NonNull String... values) { - return titleIn(Arrays.asList(values)); - } - - public final Todo_Relation titleNotIn(@NonNull String... values) { - return titleNotIn(Arrays.asList(values)); - } - - public Todo_Relation titleGlob(@NonNull String pattern) { - return where(schema.title, "GLOB", pattern); - } - - public Todo_Relation titleNotGlob(@NonNull String pattern) { - return where(schema.title, "NOT GLOB", pattern); - } - - public Todo_Relation titleLike(@NonNull String pattern) { - return where(schema.title, "LIKE", pattern); - } - - public Todo_Relation titleNotLike(@NonNull String pattern) { - return where(schema.title, "NOT LIKE", pattern); - } - - public Todo_Relation titleLt(@NonNull String title) { - return where(schema.title, "<", title); - } - - public Todo_Relation titleLe(@NonNull String title) { - return where(schema.title, "<=", title); - } - - public Todo_Relation titleGt(@NonNull String title) { - return where(schema.title, ">", title); - } - - public Todo_Relation titleGe(@NonNull String title) { - return where(schema.title, ">=", title); - } - - public Todo_Relation doneEq(boolean done) { - return where(schema.done, "=", done); - } - - public Todo_Relation doneNotEq(boolean done) { - return where(schema.done, "<>", done); - } - - public Todo_Relation doneIn(@NonNull Collection values) { - return in(false, schema.done, values); - } - - public Todo_Relation doneNotIn(@NonNull Collection values) { - return in(true, schema.done, values); - } - - public final Todo_Relation doneIn(@NonNull Boolean... values) { - return doneIn(Arrays.asList(values)); - } - - public final Todo_Relation doneNotIn(@NonNull Boolean... values) { - return doneNotIn(Arrays.asList(values)); - } - - public Todo_Relation doneLt(boolean done) { - return where(schema.done, "<", done); - } - - public Todo_Relation doneLe(boolean done) { - return where(schema.done, "<=", done); - } - - public Todo_Relation doneGt(boolean done) { - return where(schema.done, ">", done); - } - - public Todo_Relation doneGe(boolean done) { - return where(schema.done, ">=", done); - } - - public Todo_Relation idEq(long id) { - return where(schema.id, "=", id); - } - - public Todo_Relation idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Todo_Relation idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Todo_Relation idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Todo_Relation idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Todo_Relation idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Todo_Relation idLt(long id) { - return where(schema.id, "<", id); - } - - public Todo_Relation idLe(long id) { - return where(schema.id, "<=", id); - } - - public Todo_Relation idGt(long id) { - return where(schema.id, ">", id); - } - - public Todo_Relation idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Todo_Relation idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } - - public Todo_Relation orderByTitleAsc() { - return orderBy(schema.title.orderInAscending()); - } - - public Todo_Relation orderByTitleDesc() { - return orderBy(schema.title.orderInDescending()); - } - - public Todo_Relation orderByDoneAsc() { - return orderBy(schema.done.orderInAscending()); - } - - public Todo_Relation orderByDoneDesc() { - return orderBy(schema.done.orderInDescending()); - } - - public Todo_Relation orderByCreatedTimeAsc() { - return orderBy(schema.createdTime.orderInAscending()); - } - - public Todo_Relation orderByCreatedTimeDesc() { - return orderBy(schema.createdTime.orderInDescending()); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Schema.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Schema.java deleted file mode 100644 index 6f4471ef..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Schema.java +++ /dev/null @@ -1,334 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import android.content.ContentValues; -import android.database.Cursor; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.github.gfx.android.orma.BuiltInSerializers; -import com.github.gfx.android.orma.ColumnDef; -import com.github.gfx.android.orma.OrmaConnection; -import com.github.gfx.android.orma.Schema; -import com.github.gfx.android.orma.annotation.OnConflict; -import com.github.gfx.android.orma.core.DatabaseStatement; -import com.github.gfx.android.orma.internal.Aliases; -import com.github.gfx.android.orma.internal.Schemas; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -public class Todo_Schema implements Schema { - public static final Todo_Schema INSTANCE = Schemas.register(new Todo_Schema()); - - @Nullable - private final String $alias; - - public final ColumnDef title; - - public final ColumnDef content; - - public final ColumnDef done; - - public final ColumnDef createdTime; - - public final ColumnDef id; - - private final String[] $defaultResultColumns; - - public Todo_Schema() { - this(null); - } - - public Todo_Schema(@Nullable Aliases.ColumnPath current) { - $alias = current != null ? current.getAlias() : null; - this.id = new ColumnDef(this, "id", long.class, "INTEGER", ColumnDef.PRIMARY_KEY | ColumnDef.AUTO_VALUE) { - @Override - @NonNull - public Long get(@NonNull Todo model) { - return model.id; - } - - @NonNull - @Override - public Long getSerialized(@NonNull Todo model) { - return model.id; - } - - @NonNull - @Override - public Long getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.getLong(index); - } - }; - this.title = new ColumnDef(this, "title", String.class, "TEXT", ColumnDef.INDEXED) { - @Override - @NonNull - public String get(@NonNull Todo model) { - return model.title; - } - - @NonNull - @Override - public String getSerialized(@NonNull Todo model) { - return model.title; - } - - @NonNull - @Override - public String getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.getString(index); - } - }; - this.content = new ColumnDef(this, "content", String.class, "TEXT", ColumnDef.NULLABLE) { - @Override - @Nullable - public String get(@NonNull Todo model) { - return model.content; - } - - @Nullable - @Override - public String getSerialized(@NonNull Todo model) { - return model.content; - } - - @Nullable - @Override - public String getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return cursor.isNull(index) ? null : cursor.getString(index); - } - }; - this.done = new ColumnDef(this, "done", boolean.class, "BOOLEAN", ColumnDef.INDEXED) { - @Override - @NonNull - public Boolean get(@NonNull Todo model) { - return model.done; - } - - @NonNull - @Override - public Boolean getSerialized(@NonNull Todo model) { - return model.done; - } - - @NonNull - @Override - public Boolean getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, - int index) { - return cursor.getLong(index) != 0; - } - }; - this.createdTime = new ColumnDef(this, "createdTime", Date.class, "INTEGER", ColumnDef.INDEXED) { - @Override - @NonNull - public Date get(@NonNull Todo model) { - return model.createdTime; - } - - @NonNull - @Override - public Long getSerialized(@NonNull Todo model) { - return BuiltInSerializers.serializeDate(model.createdTime); - } - - @NonNull - @Override - public Date getFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int index) { - return BuiltInSerializers.deserializeDate(cursor.getLong(index)); - } - }; - $defaultResultColumns = new String[]{ - title.getQualifiedName(), - content.getQualifiedName(), - done.getQualifiedName(), - createdTime.getQualifiedName(), - id.getQualifiedName() - }; - } - - @NonNull - @Override - public Class getModelClass() { - return Todo.class; - } - - @NonNull - @Override - public String getTableName() { - return "Todo"; - } - - @NonNull - @Override - public String getEscapedTableName() { - return "`Todo`"; - } - - @Nullable - @Override - public String getTableAlias() { - return $alias; - } - - @Nullable - @Override - public String getEscapedTableAlias() { - return $alias != null ? '`' + $alias + '`' : null; - } - - @NonNull - @Override - public String getSelectFromTableClause() { - return "`Todo`"+ ($alias != null ? " AS " + '`' + $alias + '`' : ""); - } - - @NonNull - @Override - public ColumnDef getPrimaryKey() { - return id; - } - - @NonNull - @Override - public List> getColumns() { - return Arrays.>asList( - title, - content, - done, - createdTime, - id - ); - } - - @NonNull - @Override - public String[] getDefaultResultColumns() { - return $defaultResultColumns; - } - - @NonNull - @Override - public String getCreateTableStatement() { - return "CREATE TABLE `Todo` (`title` TEXT NOT NULL, `content` TEXT , `done` BOOLEAN NOT NULL DEFAULT 0, `createdTime` INTEGER NOT NULL DEFAULT 0, `id` INTEGER PRIMARY KEY)"; - } - - @NonNull - @Override - public List getCreateIndexStatements() { - return Arrays.asList( - "CREATE INDEX `index_title_on_Todo` ON `Todo` (`title`)", - "CREATE INDEX `index_done_on_Todo` ON `Todo` (`done`)", - "CREATE INDEX `index_createdTime_on_Todo` ON `Todo` (`createdTime`)" - ); - } - - @NonNull - @Override - public String getDropTableStatement() { - return "DROP TABLE IF EXISTS `Todo`"; - } - - @NonNull - @Override - public String getInsertStatement(@OnConflict int onConflictAlgorithm, boolean withoutAutoId) { - StringBuilder s = new StringBuilder(); - s.append("INSERT"); - switch (onConflictAlgorithm) { - case OnConflict.NONE: /* nop */ break; - case OnConflict.ABORT: s.append(" OR ABORT"); break; - case OnConflict.FAIL: s.append(" OR FAIL"); break; - case OnConflict.IGNORE: s.append(" OR IGNORE"); break; - case OnConflict.REPLACE: s.append(" OR REPLACE"); break; - case OnConflict.ROLLBACK: s.append(" OR ROLLBACK"); break; - default: throw new IllegalArgumentException("Invalid OnConflict algorithm: " + onConflictAlgorithm); - } - if (withoutAutoId) { - s.append(" INTO `Todo` (`title`,`content`,`done`,`createdTime`) VALUES (?,?,?,?)"); - } - else { - s.append(" INTO `Todo` (`title`,`content`,`done`,`createdTime`,`id`) VALUES (?,?,?,?,?)"); - } - return s.toString(); - } - - /** - * Convert a model to {@code ContentValues). You can use the content values for UPDATE and/or INSERT. - */ - @NonNull - @Override - public ContentValues convertToContentValues(@NonNull OrmaConnection conn, @NonNull Todo model, - boolean withoutAutoId) { - ContentValues contentValues = new ContentValues(); - contentValues.put("title", model.title); - if (model.content != null) { - contentValues.put("content", model.content); - } - else { - contentValues.putNull("content"); - } - contentValues.put("done", model.done); - contentValues.put("createdTime", BuiltInSerializers.serializeDate(model.createdTime)); - if (!withoutAutoId) { - contentValues.put("id", model.id); - } - return contentValues; - } - - /** - * Convert a model to {@code Object[]}. Provided for debugging. - */ - @NonNull - @Override - public Object[] convertToArgs(@NonNull OrmaConnection conn, @NonNull Todo model, - boolean withoutAutoId) { - Object[] args = new Object[withoutAutoId ? 4 : 5]; - if (model.title != null) { - args[0] = model.title; - } - else { - throw new IllegalArgumentException("Todo.title" + " must not be null, or use @Nullable to declare it as NULL"); - } - if (model.content != null) { - args[1] = model.content; - } - args[2] = model.done ? 1 : 0; - if (model.createdTime != null) { - args[3] = BuiltInSerializers.serializeDate(model.createdTime); - } - else { - throw new IllegalArgumentException("Todo.createdTime" + " must not be null, or use @Nullable to declare it as NULL"); - } - if (!withoutAutoId) { - args[4] = model.id; - } - return args; - } - - @Override - public void bindArgs(@NonNull OrmaConnection conn, @NonNull DatabaseStatement statement, - @NonNull Todo model, boolean withoutAutoId) { - statement.bindString(1, model.title); - if (model.content != null) { - statement.bindString(2, model.content); - } - else { - statement.bindNull(2); - } - statement.bindLong(3, model.done ? 1 : 0); - statement.bindLong(4, BuiltInSerializers.serializeDate(model.createdTime)); - if (!withoutAutoId) { - statement.bindLong(5, model.id); - } - } - - @NonNull - @Override - public Todo newModelFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int offset) { - Todo model = new Todo(); - model.title = cursor.getString(offset + 0); - model.content = cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1); - model.done = cursor.getLong(offset + 2) != 0; - model.createdTime = BuiltInSerializers.deserializeDate(cursor.getLong(offset + 3)); - model.id = cursor.getLong(offset + 4); - return model; - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Selector.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Selector.java deleted file mode 100644 index 3f173cf7..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Selector.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxSelector; -import java.util.Arrays; -import java.util.Collection; - -public class Todo_Selector extends RxSelector { - final Todo_Schema schema; - - public Todo_Selector(RxOrmaConnection conn, Todo_Schema schema) { - super(conn); - this.schema = schema; - } - - public Todo_Selector(Todo_Selector that) { - super(that); - this.schema = that.getSchema(); - } - - public Todo_Selector(Todo_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Todo_Selector clone() { - return new Todo_Selector(this); - } - - @NonNull - @Override - public Todo_Schema getSchema() { - return schema; - } - - public Todo_Selector titleEq(@NonNull String title) { - return where(schema.title, "=", title); - } - - public Todo_Selector titleNotEq(@NonNull String title) { - return where(schema.title, "<>", title); - } - - public Todo_Selector titleIn(@NonNull Collection values) { - return in(false, schema.title, values); - } - - public Todo_Selector titleNotIn(@NonNull Collection values) { - return in(true, schema.title, values); - } - - public final Todo_Selector titleIn(@NonNull String... values) { - return titleIn(Arrays.asList(values)); - } - - public final Todo_Selector titleNotIn(@NonNull String... values) { - return titleNotIn(Arrays.asList(values)); - } - - public Todo_Selector titleGlob(@NonNull String pattern) { - return where(schema.title, "GLOB", pattern); - } - - public Todo_Selector titleNotGlob(@NonNull String pattern) { - return where(schema.title, "NOT GLOB", pattern); - } - - public Todo_Selector titleLike(@NonNull String pattern) { - return where(schema.title, "LIKE", pattern); - } - - public Todo_Selector titleNotLike(@NonNull String pattern) { - return where(schema.title, "NOT LIKE", pattern); - } - - public Todo_Selector titleLt(@NonNull String title) { - return where(schema.title, "<", title); - } - - public Todo_Selector titleLe(@NonNull String title) { - return where(schema.title, "<=", title); - } - - public Todo_Selector titleGt(@NonNull String title) { - return where(schema.title, ">", title); - } - - public Todo_Selector titleGe(@NonNull String title) { - return where(schema.title, ">=", title); - } - - public Todo_Selector doneEq(boolean done) { - return where(schema.done, "=", done); - } - - public Todo_Selector doneNotEq(boolean done) { - return where(schema.done, "<>", done); - } - - public Todo_Selector doneIn(@NonNull Collection values) { - return in(false, schema.done, values); - } - - public Todo_Selector doneNotIn(@NonNull Collection values) { - return in(true, schema.done, values); - } - - public final Todo_Selector doneIn(@NonNull Boolean... values) { - return doneIn(Arrays.asList(values)); - } - - public final Todo_Selector doneNotIn(@NonNull Boolean... values) { - return doneNotIn(Arrays.asList(values)); - } - - public Todo_Selector doneLt(boolean done) { - return where(schema.done, "<", done); - } - - public Todo_Selector doneLe(boolean done) { - return where(schema.done, "<=", done); - } - - public Todo_Selector doneGt(boolean done) { - return where(schema.done, ">", done); - } - - public Todo_Selector doneGe(boolean done) { - return where(schema.done, ">=", done); - } - - public Todo_Selector idEq(long id) { - return where(schema.id, "=", id); - } - - public Todo_Selector idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Todo_Selector idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Todo_Selector idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Todo_Selector idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Todo_Selector idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Todo_Selector idLt(long id) { - return where(schema.id, "<", id); - } - - public Todo_Selector idLe(long id) { - return where(schema.id, "<=", id); - } - - public Todo_Selector idGt(long id) { - return where(schema.id, ">", id); - } - - public Todo_Selector idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Todo_Selector idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } - - public Todo_Selector orderByTitleAsc() { - return orderBy(schema.title.orderInAscending()); - } - - public Todo_Selector orderByTitleDesc() { - return orderBy(schema.title.orderInDescending()); - } - - public Todo_Selector orderByDoneAsc() { - return orderBy(schema.done.orderInAscending()); - } - - public Todo_Selector orderByDoneDesc() { - return orderBy(schema.done.orderInDescending()); - } - - public Todo_Selector orderByCreatedTimeAsc() { - return orderBy(schema.createdTime.orderInAscending()); - } - - public Todo_Selector orderByCreatedTimeDesc() { - return orderBy(schema.createdTime.orderInDescending()); - } -} diff --git a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Updater.java b/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Updater.java deleted file mode 100644 index 9bbd1666..00000000 --- a/example/build/generated/source/apt/normal/debug/com/github/gfx/android/orma/example/orma/Todo_Updater.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.github.gfx.android.orma.example.orma; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.github.gfx.android.orma.BuiltInSerializers; -import com.github.gfx.android.orma.rx.RxOrmaConnection; -import com.github.gfx.android.orma.rx.RxUpdater; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; - -public class Todo_Updater extends RxUpdater { - final Todo_Schema schema; - - public Todo_Updater(RxOrmaConnection conn, Todo_Schema schema) { - super(conn); - this.schema = schema; - } - - public Todo_Updater(Todo_Updater that) { - super(that); - this.schema = that.getSchema(); - } - - public Todo_Updater(Todo_Relation relation) { - super(relation); - this.schema = relation.getSchema(); - } - - @Override - public Todo_Updater clone() { - return new Todo_Updater(this); - } - - @NonNull - @Override - public Todo_Schema getSchema() { - return schema; - } - - public Todo_Updater title(@NonNull String title) { - contents.put("`title`", title); - return this; - } - - public Todo_Updater content(@Nullable String content) { - if (content == null) { - contents.putNull("`content`"); - } - else { - contents.put("`content`", content); - } - return this; - } - - public Todo_Updater done(boolean done) { - contents.put("`done`", done); - return this; - } - - public Todo_Updater createdTime(@NonNull Date createdTime) { - contents.put("`createdTime`", BuiltInSerializers.serializeDate(createdTime)); - return this; - } - - public Todo_Updater titleEq(@NonNull String title) { - return where(schema.title, "=", title); - } - - public Todo_Updater titleNotEq(@NonNull String title) { - return where(schema.title, "<>", title); - } - - public Todo_Updater titleIn(@NonNull Collection values) { - return in(false, schema.title, values); - } - - public Todo_Updater titleNotIn(@NonNull Collection values) { - return in(true, schema.title, values); - } - - public final Todo_Updater titleIn(@NonNull String... values) { - return titleIn(Arrays.asList(values)); - } - - public final Todo_Updater titleNotIn(@NonNull String... values) { - return titleNotIn(Arrays.asList(values)); - } - - public Todo_Updater titleGlob(@NonNull String pattern) { - return where(schema.title, "GLOB", pattern); - } - - public Todo_Updater titleNotGlob(@NonNull String pattern) { - return where(schema.title, "NOT GLOB", pattern); - } - - public Todo_Updater titleLike(@NonNull String pattern) { - return where(schema.title, "LIKE", pattern); - } - - public Todo_Updater titleNotLike(@NonNull String pattern) { - return where(schema.title, "NOT LIKE", pattern); - } - - public Todo_Updater titleLt(@NonNull String title) { - return where(schema.title, "<", title); - } - - public Todo_Updater titleLe(@NonNull String title) { - return where(schema.title, "<=", title); - } - - public Todo_Updater titleGt(@NonNull String title) { - return where(schema.title, ">", title); - } - - public Todo_Updater titleGe(@NonNull String title) { - return where(schema.title, ">=", title); - } - - public Todo_Updater doneEq(boolean done) { - return where(schema.done, "=", done); - } - - public Todo_Updater doneNotEq(boolean done) { - return where(schema.done, "<>", done); - } - - public Todo_Updater doneIn(@NonNull Collection values) { - return in(false, schema.done, values); - } - - public Todo_Updater doneNotIn(@NonNull Collection values) { - return in(true, schema.done, values); - } - - public final Todo_Updater doneIn(@NonNull Boolean... values) { - return doneIn(Arrays.asList(values)); - } - - public final Todo_Updater doneNotIn(@NonNull Boolean... values) { - return doneNotIn(Arrays.asList(values)); - } - - public Todo_Updater doneLt(boolean done) { - return where(schema.done, "<", done); - } - - public Todo_Updater doneLe(boolean done) { - return where(schema.done, "<=", done); - } - - public Todo_Updater doneGt(boolean done) { - return where(schema.done, ">", done); - } - - public Todo_Updater doneGe(boolean done) { - return where(schema.done, ">=", done); - } - - public Todo_Updater idEq(long id) { - return where(schema.id, "=", id); - } - - public Todo_Updater idNotEq(long id) { - return where(schema.id, "<>", id); - } - - public Todo_Updater idIn(@NonNull Collection values) { - return in(false, schema.id, values); - } - - public Todo_Updater idNotIn(@NonNull Collection values) { - return in(true, schema.id, values); - } - - public final Todo_Updater idIn(@NonNull Long... values) { - return idIn(Arrays.asList(values)); - } - - public final Todo_Updater idNotIn(@NonNull Long... values) { - return idNotIn(Arrays.asList(values)); - } - - public Todo_Updater idLt(long id) { - return where(schema.id, "<", id); - } - - public Todo_Updater idLe(long id) { - return where(schema.id, "<=", id); - } - - public Todo_Updater idGt(long id) { - return where(schema.id, ">", id); - } - - public Todo_Updater idGe(long id) { - return where(schema.id, ">=", id); - } - - /** - * To build a condition id BETWEEN a AND b, which is equivalent to a <= id AND id <= b. - */ - public Todo_Updater idBetween(long idA, long idB) { - return whereBetween(schema.id, idA, idB); - } -} diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml index a6396865..f816d260 100644 --- a/example/src/main/AndroidManifest.xml +++ b/example/src/main/AndroidManifest.xml @@ -15,6 +15,7 @@ > diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d76b502e..d1b9d29a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Tue May 20 09:51:54 ICT 2025 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/library/build.gradle b/library/build.gradle index 26ee02ce..b77ab664 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.github.dcendents.android-maven' android { compileSdkVersion SDK_VERSION diff --git a/migration/build.gradle b/migration/build.gradle index 7059b619..6a7ceee7 100644 --- a/migration/build.gradle +++ b/migration/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.github.dcendents.android-maven' android { compileSdkVersion SDK_VERSION diff --git a/publish.gradle b/publish.gradle index d7d425f8..20e15747 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,80 +1,80 @@ -apply plugin: 'maven' -apply plugin: 'maven-publish' -apply plugin: 'com.jfrog.bintray' - - -group = metadata.groupId -version = metadata.version - -bintray { - user = findProperty('bintrayUser') - key = findProperty('bintrayKey') - configurations = ['archives'] - publish = true - pkg { - repo = 'maven' - name = archivesBaseName - desc = metadata.desc - userOrg = metadata.userOrg - websiteUrl = metadata.website - vcsUrl = metadata.repository - licenses = metadata.licences - } -} - -task ormaJavadoc(type: Javadoc) { - failOnError false - options.locale = 'en_US' - if (project.hasProperty('android')) { - source = android.sourceSets.main.java.sourceFiles - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - classpath += configurations.compile - } else { - source = sourceSets.main.allJava - } -} - -task sourcesJar(type: Jar) { - if (project.hasProperty('android')) { - from android.sourceSets.main.java.srcDirs - } else { - from sourceSets.main.allJava - } - classifier = 'sources' -} - -task javadocJar(type: Jar, dependsOn: ormaJavadoc) { - from ormaJavadoc.destinationDir - classifier = 'javadoc' -} - -artifacts { - archives javadocJar - archives sourcesJar -} - -install { - repositories { - mavenInstaller { - pom.project { - packaging 'aar' - artifactId archivesBaseName - url metadata.website - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer metadata.developer - } - scm { - connection metadata.repository - developerConnection metadata.repository - url metadata.website - } - } - } - } -} +//apply plugin: 'maven' +//apply plugin: 'maven-publish' +//apply plugin: 'com.jfrog.bintray' +// +// +//group = metadata.groupId +//version = metadata.version +// +//bintray { +// user = findProperty('bintrayUser') +// key = findProperty('bintrayKey') +// configurations = ['archives'] +// publish = true +// pkg { +// repo = 'maven' +// name = archivesBaseName +// desc = metadata.desc +// userOrg = metadata.userOrg +// websiteUrl = metadata.website +// vcsUrl = metadata.repository +// licenses = metadata.licences +// } +//} +// +//task ormaJavadoc(type: Javadoc) { +// failOnError false +// options.locale = 'en_US' +// if (project.hasProperty('android')) { +// source = android.sourceSets.main.java.sourceFiles +// classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) +// classpath += configurations.compile +// } else { +// source = sourceSets.main.allJava +// } +//} +// +//task sourcesJar(type: Jar) { +// if (project.hasProperty('android')) { +// from android.sourceSets.main.java.srcDirs +// } else { +// from sourceSets.main.allJava +// } +// classifier = 'sources' +//} +// +//task javadocJar(type: Jar, dependsOn: ormaJavadoc) { +// from ormaJavadoc.destinationDir +// classifier = 'javadoc' +//} +// +//artifacts { +// archives javadocJar +// archives sourcesJar +//} +// +//install { +// repositories { +// mavenInstaller { +// pom.project { +// packaging 'aar' +// artifactId archivesBaseName +// url metadata.website +// licenses { +// license { +// name 'The Apache Software License, Version 2.0' +// url 'http://www.apache.org/licenses/LICENSE-2.0.txt' +// } +// } +// developers { +// developer metadata.developer +// } +// scm { +// connection metadata.repository +// developerConnection metadata.repository +// url metadata.website +// } +// } +// } +// } +//}