Skip to content

Commit

Permalink
regen examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed Sep 19, 2016
1 parent 12badf7 commit 9e2d838
Show file tree
Hide file tree
Showing 15 changed files with 245 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@
import android.support.annotation.NonNull;
import com.github.gfx.android.orma.Deleter;
import com.github.gfx.android.orma.OrmaConnection;
import com.github.gfx.android.orma.Schema;
import java.util.Arrays;
import java.util.Collection;

public class Category_Deleter extends Deleter<Category, Category_Deleter> {
public Category_Deleter(OrmaConnection conn, Schema<Category> schema) {
super(conn, schema);
final Category_Schema schema;

public Category_Deleter(OrmaConnection conn, Category_Schema schema) {
super(conn);
this.schema = schema;
}

public Category_Deleter(Category_Relation relation) {
super(relation);
this.schema = (Category_Schema) relation.getSchema();
}

@Override
@NonNull
public Category_Schema getSchema() {
return schema;
}

public Category_Deleter idEq(long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,33 @@
import android.support.annotation.NonNull;
import com.github.gfx.android.orma.OrmaConnection;
import com.github.gfx.android.orma.Relation;
import com.github.gfx.android.orma.Schema;
import java.util.Arrays;
import java.util.Collection;

public class Category_Relation extends Relation<Category, Category_Relation> {
public Category_Relation(OrmaConnection conn, Schema<Category> schema) {
super(conn, schema);
final Category_Schema schema;

public Category_Relation(OrmaConnection conn, Category_Schema schema) {
super(conn);
this.schema = schema;
}

public Category_Relation(Category_Relation relation) {
super(relation);
this.schema = (Category_Schema) relation.getSchema();
}

@Override
public Category_Relation clone() {
return new Category_Relation(this);
}

@Override
@NonNull
public Category_Schema getSchema() {
return schema;
}

@NonNull
@CheckResult
public Category reload(@NonNull Category model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
public class Category_Schema implements Schema<Category> {
public static final Category_Schema INSTANCE = Schemas.register(new Category_Schema());

public static final ColumnDef<Category, String> name = new ColumnDef<Category, String>(INSTANCE, "name", String.class, "TEXT", ColumnDef.UNIQUE) {
public final String alias;

public final ColumnDef<Category, String> name = new ColumnDef<Category, String>(this, "name", String.class, "TEXT", ColumnDef.UNIQUE) {
@Override
@NonNull
public String get(@NonNull Category model) {
Expand All @@ -29,7 +31,7 @@ public String getSerialized(@NonNull Category model) {
}
};

public static final ColumnDef<Category, Long> id = new ColumnDef<Category, Long>(INSTANCE, "id", long.class, "INTEGER", ColumnDef.PRIMARY_KEY | ColumnDef.AUTO_VALUE) {
public final ColumnDef<Category, Long> id = new ColumnDef<Category, Long>(this, "id", long.class, "INTEGER", ColumnDef.PRIMARY_KEY | ColumnDef.AUTO_VALUE) {
@Override
@NonNull
public Long get(@NonNull Category model) {
Expand All @@ -43,16 +45,24 @@ public Long getSerialized(@NonNull Category model) {
}
};

public static final List<ColumnDef<Category, ?>> $COLUMNS = Arrays.<ColumnDef<Category, ?>>asList(
final List<ColumnDef<Category, ?>> $COLUMNS = Arrays.<ColumnDef<Category, ?>>asList(
name,
id
);

public static final String[] $DEFAULT_RESULT_COLUMNS = {
final String[] $DEFAULT_RESULT_COLUMNS = {
"`name`",
"`id`"
};

Category_Schema(@NonNull String alias) {
this.alias = alias;
}

Category_Schema() {
this("Category");
}

@NonNull
@Override
public Class<Category> getModelClass() {
Expand All @@ -71,6 +81,18 @@ public String getEscapedTableName() {
return "`Category`";
}

@NonNull
@Override
public String getTableAlias() {
return alias;
}

@NonNull
@Override
public String getEscapedTableAlias() {
return '`' + alias + '`';
}

@NonNull
@Override
public String getSelectFromTableClause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@

import android.support.annotation.NonNull;
import com.github.gfx.android.orma.OrmaConnection;
import com.github.gfx.android.orma.Schema;
import com.github.gfx.android.orma.Selector;
import com.github.gfx.android.orma.internal.OrmaConditionBase;
import java.util.Arrays;
import java.util.Collection;

public class Category_Selector extends Selector<Category, Category_Selector> {
public Category_Selector(OrmaConnection conn, Schema<Category> schema) {
super(conn, schema);
final Category_Schema schema;

public Category_Selector(OrmaConnection conn, Category_Schema schema) {
super(conn);
this.schema = schema;
}

public Category_Selector(OrmaConditionBase<Category, ?> condition) {
super(condition);
this.schema = (Category_Schema) condition.getSchema();
}

@Override
public Category_Selector clone() {
return new Category_Selector(this);
}

@Override
@NonNull
public Category_Schema getSchema() {
return schema;
}

public Category_Selector idEq(long id) {
return where("`id` = ?", id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@

import android.support.annotation.NonNull;
import com.github.gfx.android.orma.OrmaConnection;
import com.github.gfx.android.orma.Schema;
import com.github.gfx.android.orma.Updater;
import java.util.Arrays;
import java.util.Collection;

public class Category_Updater extends Updater<Category, Category_Updater> {
public Category_Updater(OrmaConnection conn, Schema<Category> schema) {
super(conn, schema);
final Category_Schema schema;

public Category_Updater(OrmaConnection conn, Category_Schema schema) {
super(conn);
this.schema = schema;
}

public Category_Updater(Category_Relation relation) {
super(relation);
this.schema = (Category_Schema) relation.getSchema();
}

@Override
@NonNull
public Category_Schema getSchema() {
return schema;
}

public Category_Updater name(@NonNull String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@
import android.support.annotation.NonNull;
import com.github.gfx.android.orma.Deleter;
import com.github.gfx.android.orma.OrmaConnection;
import com.github.gfx.android.orma.Schema;
import java.util.Arrays;
import java.util.Collection;

public class Item_Deleter extends Deleter<Item, Item_Deleter> {
public Item_Deleter(OrmaConnection conn, Schema<Item> schema) {
super(conn, schema);
final Item_Schema schema;

public Item_Deleter(OrmaConnection conn, Item_Schema schema) {
super(conn);
this.schema = schema;
}

public Item_Deleter(Item_Relation relation) {
super(relation);
this.schema = (Item_Schema) relation.getSchema();
}

@Override
@NonNull
public Item_Schema getSchema() {
return schema;
}

public Item_Deleter categoryEq(@NonNull Category category) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,33 @@
import android.support.annotation.NonNull;
import com.github.gfx.android.orma.OrmaConnection;
import com.github.gfx.android.orma.Relation;
import com.github.gfx.android.orma.Schema;
import java.util.Arrays;
import java.util.Collection;

public class Item_Relation extends Relation<Item, Item_Relation> {
public Item_Relation(OrmaConnection conn, Schema<Item> schema) {
super(conn, schema);
final Item_Schema schema;

public Item_Relation(OrmaConnection conn, Item_Schema schema) {
super(conn);
this.schema = schema;
}

public Item_Relation(Item_Relation relation) {
super(relation);
this.schema = (Item_Schema) relation.getSchema();
}

@Override
public Item_Relation clone() {
return new Item_Relation(this);
}

@Override
@NonNull
public Item_Schema getSchema() {
return schema;
}

@NonNull
@CheckResult
public Item reload(@NonNull Item model) {
Expand Down Expand Up @@ -95,18 +104,18 @@ public Item_Relation nameGe(@NonNull String name) {
}

public Item_Relation orderByCategoryAsc() {
return orderBy(Item_Schema.category.orderInAscending());
return orderBy(schema.category.orderInAscending());
}

public Item_Relation orderByCategoryDesc() {
return orderBy(Item_Schema.category.orderInDescending());
return orderBy(schema.category.orderInDescending());
}

public Item_Relation orderByNameAsc() {
return orderBy(Item_Schema.name.orderInAscending());
return orderBy(schema.name.orderInAscending());
}

public Item_Relation orderByNameDesc() {
return orderBy(Item_Schema.name.orderInDescending());
return orderBy(schema.name.orderInDescending());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
public class Item_Schema implements Schema<Item> {
public static final Item_Schema INSTANCE = Schemas.register(new Item_Schema());

public static final ColumnDef<Item, Category> category = new ColumnDef<Item, Category>(INSTANCE, "category", Category.class, "INTEGER", ColumnDef.INDEXED) {
public final String alias;

public final ColumnDef<Item, Category> category = new ColumnDef<Item, Category>(this, "category", Category.class, "INTEGER", ColumnDef.INDEXED) {
@Override
@NonNull
public Category get(@NonNull Item model) {
Expand All @@ -28,7 +30,7 @@ public Long getSerialized(@NonNull Item model) {
}
};

public static final ColumnDef<Item, String> name = new ColumnDef<Item, String>(INSTANCE, "name", String.class, "TEXT", ColumnDef.PRIMARY_KEY) {
public final ColumnDef<Item, String> name = new ColumnDef<Item, String>(this, "name", String.class, "TEXT", ColumnDef.PRIMARY_KEY) {
@Override
@NonNull
public String get(@NonNull Item model) {
Expand All @@ -42,19 +44,27 @@ public String getSerialized(@NonNull Item model) {
}
};

public static final List<ColumnDef<Item, ?>> $COLUMNS = Arrays.<ColumnDef<Item, ?>>asList(
final List<ColumnDef<Item, ?>> $COLUMNS = Arrays.<ColumnDef<Item, ?>>asList(
category,
name
);

public static final String[] $DEFAULT_RESULT_COLUMNS = {
final String[] $DEFAULT_RESULT_COLUMNS = {
"`Item`.`category`",
"`Category`.`name`",
"`Category`.`id`"
,
"`Item`.`name`"
};

Item_Schema(@NonNull String alias) {
this.alias = alias;
}

Item_Schema() {
this("Item");
}

@NonNull
@Override
public Class<Item> getModelClass() {
Expand All @@ -73,6 +83,18 @@ public String getEscapedTableName() {
return "`Item`";
}

@NonNull
@Override
public String getTableAlias() {
return alias;
}

@NonNull
@Override
public String getEscapedTableAlias() {
return '`' + alias + '`';
}

@NonNull
@Override
public String getSelectFromTableClause() {
Expand Down
Loading

0 comments on commit 9e2d838

Please sign in to comment.