Skip to content

Commit bc1cf60

Browse files
authored
Merge pull request #1416 from Raizlabs/develop
4.1.0
2 parents 38fe8f0 + d1be504 commit bc1cf60

File tree

125 files changed

+2161
-957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+2161
-957
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Image](https://github.com/agrosner/DBFlow/blob/develop/dbflow_banner.png?raw=true)
22

3-
[![JitPack.io](https://img.shields.io/badge/JitPack.io-4.0.5-red.svg?style=flat)](https://jitpack.io/#Raizlabs/DBFlow) [![Android Weekly](http://img.shields.io/badge/Android%20Weekly-%23129-2CB3E5.svg?style=flat)](http://androidweekly.net/issues/issue-129) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DBFlow-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1134)
3+
[![JitPack.io](https://img.shields.io/badge/JitPack.io-4.1.0-red.svg?style=flat)](https://jitpack.io/#Raizlabs/DBFlow) [![Android Weekly](http://img.shields.io/badge/Android%20Weekly-%23129-2CB3E5.svg?style=flat)](http://androidweekly.net/issues/issue-129) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DBFlow-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1134)
44

55
A robust, powerful, and very simple ORM android database library with **annotation processing**.
66

@@ -41,14 +41,18 @@ Add the library to the project-level build.gradle, using the apt plugin to enabl
4141

4242
```groovy
4343
44-
def dbflow_version = "4.0.5"
44+
apply plugin: 'kotlin-kapt' // required for kotlin.
45+
46+
def dbflow_version = "4.1.0"
4547
// or dbflow_version = "develop-SNAPSHOT" for grabbing latest dependency in your project on the develop branch
4648
// or 10-digit short-hash of a specific commit. (Useful for bugs fixed in develop, but not in a release yet)
4749
4850
dependencies {
51+
52+
// if Java use this. If using Kotlin do NOT use this.
4953
annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
5054
51-
// use kapt for kotlin apt if you're a Kotlin user
55+
// Use if Kotlin user.
5256
kapt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
5357
5458
compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
@@ -75,10 +79,6 @@ Add the library to the project-level build.gradle, using the apt plugin to enabl
7579
7680
}
7781
78-
// if you're building with Kotlin
79-
kapt {
80-
generateStubs = true
81-
}
8282
```
8383

8484
# Pull Requests

build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
buildscript {
2-
ext.kotlin_version = '1.1.3-2'
2+
ext.kotlin_version = '1.1.4-2'
33
repositories {
44
jcenter()
5+
google()
56
}
67
dependencies {
7-
classpath 'com.android.tools.build:gradle:2.3.3'
8+
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
89
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
9-
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
10+
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.3'
1011
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1112
}
1213
}
1314

1415
allprojects {
1516
repositories {
1617
jcenter()
18+
google()
1719
maven { url "https://www.jitpack.io" }
1820
}
1921
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.raizlabs.android.dbflow.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* Description: Maps an arbitrary object and its corresponding fields into a set of columns. It is similar
10+
* to {@link ForeignKey} except it's not represented in the DB hierarchy.
11+
*/
12+
@Retention(RetentionPolicy.CLASS)
13+
@Target(ElementType.FIELD)
14+
public @interface ColumnMap {
15+
16+
/**
17+
* Defines explicit references for a composite {@link ColumnMap} definition.
18+
*
19+
* @return override explicit usage of all fields and provide custom references.
20+
*/
21+
ColumnMapReference[] references() default {};
22+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.raizlabs.android.dbflow.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* Description: Allows a {@link ColumnMap} to specify a reference override for its fields. Anything not
10+
* defined here will not be used.
11+
*/
12+
@Retention(RetentionPolicy.CLASS)
13+
@Target(ElementType.FIELD)
14+
public @interface ColumnMapReference {
15+
16+
/**
17+
* @return The local column name that will be referenced in the DB
18+
*/
19+
String columnName();
20+
21+
/**
22+
* @return The column name in the referenced table
23+
*/
24+
String columnMapFieldName();
25+
26+
/**
27+
* @return Specify the {@link NotNull} annotation here and it will get pasted into the reference definition.
28+
*/
29+
NotNull notNull() default @NotNull(onNullConflict = ConflictAction.NONE);
30+
}

dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Database.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,23 @@
2626
int version();
2727

2828
/**
29-
* @return The name of the DB. Optional as it will default to the class name.
29+
* @deprecated use DatabaseConfig.databaseName() to change the name.
3030
*/
31+
@Deprecated
3132
String name() default "";
3233

3334
/**
34-
* @return Specify the extension of the file name : {fileName}.{extension}. Default is ".db"
35+
* @deprecated use DatabaseConfig.extension() to change the extension.
3536
*/
37+
@Deprecated
3638
String databaseExtension() default "";
3739

40+
/**
41+
* @deprecated use DatabaseConfig.inMemoryBuilder() instead.
42+
*/
43+
@Deprecated
44+
boolean inMemory() default false;
45+
3846
/**
3947
* @return If true, SQLite will throw exceptions when {@link ForeignKey} constraints are not respected.
4048
* Default is false and will not throw exceptions.
@@ -52,11 +60,6 @@
5260
*/
5361
boolean backupEnabled() default false;
5462

55-
/**
56-
* @return true if you want it to be in-memory, false if not.
57-
*/
58-
boolean inMemory() default false;
59-
6063
/**
6164
* @return Global default insert conflict that can be applied to any table when it leaves
6265
* its {@link ConflictAction} as NONE.
@@ -72,6 +75,8 @@
7275
/**
7376
* @return Marks all generated classes within this database with this character. For example
7477
* "TestTable" becomes "TestTable$Table" for a "$" separator.
78+
* @deprecated Generated class files will become '_' only in next major release.
7579
*/
80+
@Deprecated
7681
String generatedClassSeparator() default "_";
7782
}

dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ForeignKeyReference.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@
2424
*/
2525
String foreignKeyColumnName();
2626

27+
/**
28+
* @return Specify the {@link NotNull} annotation here and it will get pasted into the reference definition.
29+
*/
30+
NotNull notNull() default @NotNull(onNullConflict = ConflictAction.NONE);
2731
}

dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/OneToMany.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ enum Method {
5555
/**
5656
* @return If true, the underlying variable that we use is private, requiring us to provide
5757
* a setter for it.
58+
* @deprecated has no effect on the visibility of the call since we now autodetect visibility.
5859
*/
60+
@Deprecated
5961
boolean isVariablePrivate() default false;
6062

6163
/**

dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Table.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
*/
7474
boolean assignDefaultValuesFromCursor() default true;
7575

76+
/**
77+
* @return When false, this table gets generated and associated with database, however it will not immediately
78+
* get created upon startup. This is useful for keeping around legacy tables for migrations.
79+
*/
80+
boolean createWithDatabase() default true;
81+
7682
/**
7783
* @return The cache size for this Table.
7884
*/

dbflow-kotlinextensions/build.gradle

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ android {
2626
}
2727

2828
dependencies {
29-
compile fileTree(dir: 'libs', include: ['*.jar'])
30-
testCompile 'junit:junit:4.12'
31-
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
32-
33-
compile project("${dbflow_project_prefix}dbflow-core")
34-
compile project("${dbflow_project_prefix}dbflow")
29+
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
30+
api project("${dbflow_project_prefix}dbflow-core")
31+
api project("${dbflow_project_prefix}dbflow")
3532
}
3633

3734
apply from: '../kotlin-artifacts.gradle'
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.raizlabs.android.dbflow.kotlinextensions
2+
3+
import com.raizlabs.android.dbflow.sql.queriable.ModelQueriable
4+
import kotlin.properties.ReadWriteProperty
5+
import kotlin.reflect.KProperty
6+
7+
8+
fun <T : Any> oneToMany(query: () -> ModelQueriable<T>) = OneToMany(query)
9+
10+
/**
11+
* Description: Wraps a [OneToMany] annotation getter into a concise property setter.
12+
*/
13+
class OneToMany<T : Any>(private val query: () -> ModelQueriable<T>) : ReadWriteProperty<Any, List<T>?> {
14+
15+
private var list: List<T>? = null
16+
17+
override fun getValue(thisRef: Any, property: KProperty<*>): List<T>? {
18+
if (list?.isEmpty() ?: true) {
19+
list = query().list
20+
}
21+
return list
22+
}
23+
24+
override fun setValue(thisRef: Any, property: KProperty<*>, value: List<T>?) {
25+
list = value
26+
}
27+
}

0 commit comments

Comments
 (0)