-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1416 from Raizlabs/develop
4.1.0
- Loading branch information
Showing
125 changed files
with
2,161 additions
and
957 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.raizlabs.android.dbflow.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Description: Maps an arbitrary object and its corresponding fields into a set of columns. It is similar | ||
* to {@link ForeignKey} except it's not represented in the DB hierarchy. | ||
*/ | ||
@Retention(RetentionPolicy.CLASS) | ||
@Target(ElementType.FIELD) | ||
public @interface ColumnMap { | ||
|
||
/** | ||
* Defines explicit references for a composite {@link ColumnMap} definition. | ||
* | ||
* @return override explicit usage of all fields and provide custom references. | ||
*/ | ||
ColumnMapReference[] references() default {}; | ||
} |
30 changes: 30 additions & 0 deletions
30
dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnMapReference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.raizlabs.android.dbflow.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Description: Allows a {@link ColumnMap} to specify a reference override for its fields. Anything not | ||
* defined here will not be used. | ||
*/ | ||
@Retention(RetentionPolicy.CLASS) | ||
@Target(ElementType.FIELD) | ||
public @interface ColumnMapReference { | ||
|
||
/** | ||
* @return The local column name that will be referenced in the DB | ||
*/ | ||
String columnName(); | ||
|
||
/** | ||
* @return The column name in the referenced table | ||
*/ | ||
String columnMapFieldName(); | ||
|
||
/** | ||
* @return Specify the {@link NotNull} annotation here and it will get pasted into the reference definition. | ||
*/ | ||
NotNull notNull() default @NotNull(onNullConflict = ConflictAction.NONE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/OneToManyExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.raizlabs.android.dbflow.kotlinextensions | ||
|
||
import com.raizlabs.android.dbflow.sql.queriable.ModelQueriable | ||
import kotlin.properties.ReadWriteProperty | ||
import kotlin.reflect.KProperty | ||
|
||
|
||
fun <T : Any> oneToMany(query: () -> ModelQueriable<T>) = OneToMany(query) | ||
|
||
/** | ||
* Description: Wraps a [OneToMany] annotation getter into a concise property setter. | ||
*/ | ||
class OneToMany<T : Any>(private val query: () -> ModelQueriable<T>) : ReadWriteProperty<Any, List<T>?> { | ||
|
||
private var list: List<T>? = null | ||
|
||
override fun getValue(thisRef: Any, property: KProperty<*>): List<T>? { | ||
if (list?.isEmpty() ?: true) { | ||
list = query().list | ||
} | ||
return list | ||
} | ||
|
||
override fun setValue(thisRef: Any, property: KProperty<*>, value: List<T>?) { | ||
list = value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.