Skip to content

Commit

Permalink
Merge branch 'release/0.5.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewReitz committed Nov 30, 2014
2 parents ad7bedc + 5df4ad0 commit 32a5b1a
Show file tree
Hide file tree
Showing 18 changed files with 175 additions and 86 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## Version 0.5.0

- Added ability to define column, id, and table names.
- Renamed `Field` annotation to `Column`.
- Renamed `@Field` annotation to `@Column`.
- Removed `@OrmOnly` annotation and need for empty no arg constructors.

## Version 0.4.0 (11-27-2014)

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Serializable interface.

## Other Notes

- Empty constructors must be provided at package protected level or higher. There is the `@OrmOnly`
annotation provided to indicate to others that the constructor is only visible for Shillelagh
- Constructors must be provided at package protected level or higher (Put in a ticket if there is a
legitimate use case for private).
- Inner classes MUST be marked static.
- Don't forget to update your database version if you change your models
(Also create migration scripts).
Expand All @@ -62,19 +62,19 @@ jar in your application compile time. You can download the jars
<dependency>
<groupId>com.andrewreitz</groupId>
<artifactId>shillelagh</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>com.andrewreitz</groupId>
<artifactId>shillelagh-processor</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
<optional>true</optional>
</dependency>
```
## Gradle:
```groovy
compile 'com.andrewreitz:shillelagh:0.4.0'
provided 'com.andrewreitz:shillelagh:0.4.0'
compile 'com.andrewreitz:shillelagh:0.5.0'
provided 'com.andrewreitz:shillelagh:0.5.0'
```

# License
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.2'
classpath 'com.android.tools.build:gradle:0.14.4'
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ final class TableObject {

private static final String SERIALIZE_FUNCTION = "ShillelaghUtil.serialize";
private static final String DESERIALIZE_FUNCTION = "ShillelaghUtil.deserialize";
private static final String NEW_INSTANCE_FUNCTION = "ShillelaghUtil.createInstance";
private static final String GET_ID_FUNCTION = "getId";
private static final String SELECT_ALL_FUNCTION = "selectAll";
private static final String PARENT_INSERT_FUNCTION = "parentInsert";
Expand Down Expand Up @@ -337,7 +338,8 @@ private void emitSingleMap(JavaWriter javaWriter) throws IOException {
String targetClass = getTargetClass();
javaWriter.beginMethod(targetClass, $$MAP_SINGLE_FUNCTION, EnumSet.of(PUBLIC, STATIC), "Cursor",
"cursor", "SQLiteDatabase", "db")
.emitStatement("%s tableObject = new %s()", targetClass, getTargetClass())
.emitStatement("%s tableObject = %s(%s.class)", targetClass, NEW_INSTANCE_FUNCTION,
getTargetClass())
.emitStatement("tableObject.%s = cursor.getLong(cursor.getColumnIndex(\"%s\"))",
idColumn.getMemberName(), idColumn.getColumnName());

Expand Down
2 changes: 1 addition & 1 deletion shillelagh-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ dependencies {
compile project(':shillelagh')
provided project(':shillelagh-processor')

compile 'com.netflix.rxjava:rxjava-android:0.20.6'
compile 'io.reactivex:rxandroid:0.23.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,12 @@
package com.example.shillelagh.model;

import shillelagh.Column;
import shillelagh.OrmOnly;
import shillelagh.Table;

@Table
public class Author extends Base {
public final class Author extends Base {
@Column String name;

/**
* Used internally by Shillelagh. OrmOnly Annotation is only a documentation annotation, and
* is not required for Shillelagh usage.
*/
@OrmOnly Author() { }

public Author(String name) {
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class Base {
@Id long id;

public long getId() {
public final long getId() {
return id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,16 @@
import java.util.List;

import shillelagh.Column;
import shillelagh.OrmOnly;
import shillelagh.Table;

@Table public class Book extends Base {
@Table
public final class Book extends Base {
@Column String title;
@Column Author author;
@Column Date published;
@Column List<Chapter> chapters;
@Column(isBlob = true) Image image;

/**
* Used internally by Shillelagh. OrmOnly Annotation is only a documentation annotation, and
* is not required for Shillelagh usage.
*/
@OrmOnly Book() { }

public Book(String title, Author author, Date published, List<Chapter> chapters, Image image) {
this.title = title;
this.author = author;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,12 @@
package com.example.shillelagh.model;

import shillelagh.Column;
import shillelagh.OrmOnly;
import shillelagh.Table;

@Table
public class Chapter extends Base {
@Column String chapter;

/**
* Used internally by Shillelagh. OrmOnly Annotation is only a documentation annotation, and
* is not required for Shillelagh usage.
*/
@OrmOnly Chapter() { }

public Chapter(String chapter) {
this.chapter = chapter;
}
Expand Down
2 changes: 1 addition & 1 deletion shillelagh-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
compile project(':shillelagh')
provided project(':shillelagh-processor')

compile 'com.netflix.rxjava:rxjava-android:0.20.6'
compile 'io.reactivex:rxandroid:0.23.0'

androidTestCompile 'com.squareup.assertj:assertj-android:1.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import shillelagh.Column;
import shillelagh.Id;
import shillelagh.OrmOnly;
import shillelagh.Table;

@Table
Expand All @@ -29,8 +28,6 @@ public class SimpleObject {
@Column String address;
@Column long customerId;

@OrmOnly SimpleObject() { /* Used internally by shillelagh */ }

public SimpleObject(String name, String address, long customerId) {
this.name = name;
this.address = address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@

import shillelagh.Column;
import shillelagh.Id;
import shillelagh.OrmOnly;
import shillelagh.Table;

@Table public class TestOneToMany {
@Id long id;
@Column String someValue;
@Column List<OneToManyChild> children;

@OrmOnly TestOneToMany() {}

public TestOneToMany(String someValue, List<OneToManyChild> children) {
this.someValue = someValue;
this.children = children;
Expand All @@ -48,8 +45,6 @@ public List<OneToManyChild> getChildren() {
@Column String testString;
@Column int testInt;

@OrmOnly OneToManyChild() { }

public OneToManyChild(String testString, int testInt) {
this.testString = testString;
this.testInt = testInt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@

import shillelagh.Column;
import shillelagh.Id;
import shillelagh.OrmOnly;
import shillelagh.Table;

@Table public class TestOneToOne {
@Id long id;
@Column OneToOneChild child;

@OrmOnly TestOneToOne() { }

public TestOneToOne(OneToOneChild child) {
this.child = child;
}
Expand Down Expand Up @@ -59,8 +56,6 @@ public void setId(long id) {
this.id = id;
}

@OrmOnly OneToOneChild() {}

public OneToOneChild(String childName) {
this.childName = childName;
}
Expand Down
11 changes: 7 additions & 4 deletions shillelagh/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven-publish'
apply from: rootProject.file('gradle/javaDoc.gradle')
apply from: rootProject.file('gradle/bintray.gradle')
Expand All @@ -24,8 +24,11 @@ targetCompatibility = JavaVersion.VERSION_1_6
sourceCompatibility = JavaVersion.VERSION_1_6

dependencies {
compile 'com.google.android:android:+', optional
compile 'com.netflix.rxjava:rxjava-core:+', optional
compile 'com.google.android:android:4.1.1.4', optional
compile 'io.reactivex:rxjava:1.0.1', optional

testCompile "org.codehaus.groovy:groovy-all:2.3.6"
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
}

publishing {
Expand Down Expand Up @@ -72,4 +75,4 @@ publishing {
}
}
}
}
}
10 changes: 5 additions & 5 deletions shillelagh/src/main/java/shillelagh/Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public class Builder<T> {
}

/** Executes a query and returns the results as a list */
public List<T> toList() {
public final List<T> toList() {
return shillelagh.rawQuery(tableObject, query.toString());
}

/** Executes a query and returns the results wrapped in an observable */
public Observable<T> toObservable() {
public final Observable<T> toObservable() {
if (!HAS_RX_JAVA) {
throw new RuntimeException(
"RxJava not available! Add RxJava to your build to use this feature");
Expand All @@ -55,17 +55,17 @@ public Observable<T> toObservable() {
}

/** Executes a query and returns the results in a cursor */
public Cursor toCursor() {
public final Cursor toCursor() {
return shillelagh.rawQuery(query.toString());
}

/** Returns the created query as a string */
@Override public String toString() {
@Override public final String toString() {
return query.toString().trim();
}

/** Check to ensure that the column name provided is valid */
void checkColumnName(String columnName) {
final void checkColumnName(String columnName) {
try {
tableObject.getDeclaredField(columnName);
} catch (NoSuchFieldException e) {
Expand Down
28 changes: 0 additions & 28 deletions shillelagh/src/main/java/shillelagh/OrmOnly.java

This file was deleted.

Loading

0 comments on commit 32a5b1a

Please sign in to comment.