Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add boxed type for Schema#getPrimaryKey() #377

Merged
merged 2 commits into from
Jan 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ The versioning follows [Semantic Versioning](http://semver.org/):

Note that _experimental_ features, annotated with `@Experimental` may change without notice.

## NEXT

* [#377](https://github.com/gfx/Android-Orma/pull/377): `Schema#getPrimaryKey` holds the boxed type of the primary key, instead of wildcard type

## v4.1.1 2017/01/25

https://github.com/gfx/Android-Orma/compare/v4.1.0...v4.1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public String getSelectFromTableClause() {

@NonNull
@Override
public ColumnDef<Category, ?> getPrimaryKey() {
public ColumnDef<Category, Long> getPrimaryKey() {
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public String getSelectFromTableClause() {

@NonNull
@Override
public ColumnDef<Entry, ?> getPrimaryKey() {
public ColumnDef<Entry, Long> getPrimaryKey() {
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public String getSelectFromTableClause() {

@NonNull
@Override
public ColumnDef<Item2, ?> getPrimaryKey() {
public ColumnDef<Item2, String> getPrimaryKey() {
return name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public String getSelectFromTableClause() {

@NonNull
@Override
public ColumnDef<Item, ?> getPrimaryKey() {
public ColumnDef<Item, String> getPrimaryKey() {
return name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public String getSelectFromTableClause() {

@NonNull
@Override
public ColumnDef<Todo, ?> getPrimaryKey() {
public ColumnDef<Todo, Long> getPrimaryKey() {
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public FieldSpecDefinition buildColumnFieldSpec(ColumnDefinition c) {
.build());

return new FieldSpecDefinition(
c,
FieldSpec.builder(c.getColumnDefType(), c.name).addModifiers(publicFinal).build(),
columnDefType.build());
}
Expand Down Expand Up @@ -477,7 +478,7 @@ public List<MethodSpec> buildMethodSpecs() {
MethodSpec.methodBuilder("getPrimaryKey")
.addAnnotations(Annotations.overrideAndNonNull())
.addModifiers(Modifier.PUBLIC)
.returns(Types.getColumnDef(schema.getModelClassName(), Types.WildcardType))
.returns(Types.getColumnDef(schema.getModelClassName(), primaryKeyFieldSpecDef.column.getBoxType()))
.addStatement("return $N", primaryKeyFieldSpecDef.fieldSpec)
.build()
);
Expand Down Expand Up @@ -837,11 +838,14 @@ private CodeBlock cursorGetter(ColumnDefinition column, CodeBlock index) {

private static class FieldSpecDefinition {

FieldSpec fieldSpec;
final ColumnDefinition column;

TypeSpec initializer;
final FieldSpec fieldSpec;

FieldSpecDefinition(FieldSpec fieldSpec, TypeSpec initializer) {
final TypeSpec initializer;

FieldSpecDefinition(ColumnDefinition column, FieldSpec fieldSpec, TypeSpec initializer) {
this.column = column;
this.fieldSpec = fieldSpec;
this.initializer = initializer;
}
Expand Down