-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move annotations to separate module to make the generator testable (#68
- Loading branch information
1 parent
9297188
commit fc60a51
Showing
20 changed files
with
336 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
library floor; | ||
|
||
export 'package:floor/src/annotations.dart'; | ||
export 'package:floor/src/database.dart'; | ||
export 'package:floor_annotation/floor_annotation.dart'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Floor | ||
**A supportive SQLite abstraction for your Flutter applications.** | ||
|
||
This library holds all the annotations. | ||
|
||
Run the generator with `flutter packages pub run build_runner build`. | ||
To automatically run it, whenever a file changes, use `flutter packages pub run build_runner watch`. | ||
|
||
*Floor - the bottom layer of a [Room](https://developer.android.com/topic/libraries/architecture/room).* | ||
|
||
## Bugs and Feedback | ||
For bugs, questions and discussions please use the [Github Issues](https://github.com/vitusortner/floor/issues). | ||
|
||
## License | ||
Copyright 2019 Vitus Ortner | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
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,13 @@ | ||
library floor_annotation; | ||
|
||
export 'src/column_info.dart'; | ||
export 'src/database.dart'; | ||
export 'src/delete.dart'; | ||
export 'src/entity.dart'; | ||
export 'src/foreign_key.dart'; | ||
export 'src/insert.dart'; | ||
export 'src/on_conflict_strategy.dart'; | ||
export 'src/primary_key.dart'; | ||
export 'src/query.dart'; | ||
export 'src/transaction.dart'; | ||
export 'src/update.dart'; |
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,10 @@ | ||
/// Allows customization of the column associated with this field. | ||
class ColumnInfo { | ||
/// The custom name of the column. | ||
final String name; | ||
|
||
/// Defines if the associated column is allowed to contain 'null'. | ||
final bool nullable; | ||
|
||
const ColumnInfo({this.name, this.nullable = true}); | ||
} |
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,5 @@ | ||
/// Marks a class as a FloorDatabase. | ||
class Database { | ||
/// Marks a class as a FloorDatabase. | ||
const Database(); | ||
} |
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,7 @@ | ||
/// Marks a method as a delete method. | ||
class Delete { | ||
const Delete(); | ||
} | ||
|
||
/// Marks a method as a delete method. | ||
const delete = Delete(); |
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,15 @@ | ||
import 'package:floor_annotation/src/foreign_key.dart'; | ||
|
||
/// Marks a class as a database entity (table). | ||
class Entity { | ||
/// The table name of the SQLite table. | ||
final String tableName; | ||
|
||
/// List of [ForeignKey] constraints on this entity. | ||
final List<ForeignKey> foreignKeys; | ||
|
||
const Entity({this.tableName, this.foreignKeys}); | ||
} | ||
|
||
/// Marks a class as a database entity (table). | ||
const entity = Entity(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:floor_annotation/src/on_conflict_strategy.dart'; | ||
|
||
/// Marks a method as an insert method. | ||
class Insert { | ||
/// How to handle conflicts. Defaults to [OnConflictStrategy.ABORT]. | ||
final int onConflict; | ||
|
||
/// Marks a method as an insert method. | ||
const Insert({this.onConflict = OnConflictStrategy.ABORT}); | ||
} | ||
|
||
/// Marks a method as an insert method. | ||
/// | ||
/// Defaults conflict strategy to [OnConflictStrategy.ABORT]. | ||
const insert = Insert(); |
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,20 @@ | ||
/// Set of conflict handling strategies for insert and update methods. | ||
/// | ||
/// Check SQLite conflict documentation for details. | ||
abstract class OnConflictStrategy { | ||
/// OnConflict strategy constant to replace the old data and continue the | ||
/// transaction. | ||
static const REPLACE = 1; | ||
|
||
/// OnConflict strategy constant to rollback the transaction. | ||
static const ROLLBACK = 2; | ||
|
||
/// OnConflict strategy constant to abort the transaction. | ||
static const ABORT = 3; | ||
|
||
/// OnConflict strategy constant to fail the transaction. | ||
static const FAIL = 4; | ||
|
||
/// OnConflict strategy constant to ignore the conflict. | ||
static const IGNORE = 5; | ||
} |
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,8 @@ | ||
/// Marks a field in an [Entity] as the primary key. | ||
class PrimaryKey { | ||
/// Let SQLite auto generate the unique id. | ||
final bool autoGenerate; | ||
|
||
/// Defaults [autoGenerate] to false. | ||
const PrimaryKey({this.autoGenerate = false}); | ||
} |
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,7 @@ | ||
/// Marks a method as a query method. | ||
class Query { | ||
/// The SQLite query. | ||
final String value; | ||
|
||
const Query(this.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// Marks a method as a transaction method. | ||
class _Transaction { | ||
const _Transaction(); | ||
} | ||
|
||
/// Marks a method as a transaction method. | ||
const transaction = _Transaction(); |
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,15 @@ | ||
import 'package:floor_annotation/src/on_conflict_strategy.dart'; | ||
|
||
/// Marks a method as an update method. | ||
class Update { | ||
/// How to handle conflicts. Defaults to [OnConflictStrategy.ABORT]. | ||
final int onConflict; | ||
|
||
/// Marks a method as an update method. | ||
const Update({this.onConflict = OnConflictStrategy.ABORT}); | ||
} | ||
|
||
/// Marks a method as an update method. | ||
/// | ||
/// Defaults conflict strategy to [OnConflictStrategy.ABORT]. | ||
const update = Update(); |
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,13 @@ | ||
name: floor_annotation | ||
description: > | ||
A supportive SQLite abstraction for your Flutter applications. | ||
This library is the runtime dependency. | ||
version: 0.0.1 | ||
homepage: https://github.com/vitusortner/floor | ||
author: vitusortner | ||
|
||
environment: | ||
sdk: '>=2.1.0 <3.0.0' | ||
|
||
dependencies: | ||
meta: ^1.1.6 |
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 |
---|---|---|
|
@@ -19,3 +19,5 @@ dependencies: | |
dev_dependencies: | ||
test: ^1.5.3 | ||
build_test: ^0.10.6 | ||
floor_annotation: | ||
path: ../floor_annotation/ |
Oops, something went wrong.