-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
220 additions
and
106 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
83 changes: 0 additions & 83 deletions
83
packages/katana_model/lib/src/model_initial_collection.dart
This file was deleted.
Oops, something went wrong.
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,165 @@ | ||
part of katana_model; | ||
|
||
/// {@template model_initial_value} | ||
/// Base class for data to be passed to various [ModelAdapter] `data`. | ||
/// | ||
/// You can parse for Json by using [toMap]. | ||
/// | ||
/// 各種[ModelAdapter]の`data`に渡すデータの基底クラス。 | ||
/// | ||
/// [toMap]を利用することでJson用にパースすることができます。 | ||
/// {@endtemplate} | ||
abstract class ModelInitialValue<T> { | ||
/// {@template model_initial_value} | ||
/// Base class for data to be passed to various [ModelAdapter] `data`. | ||
/// | ||
/// You can parse for Json by using [toMap]. | ||
/// | ||
/// 各種[ModelAdapter]の`data`に渡すデータの基底クラス。 | ||
/// | ||
/// [toMap]を利用することでJson用にパースすることができます。 | ||
/// {@endtemplate} | ||
const ModelInitialValue(); | ||
|
||
/// Path to the collection itself. | ||
/// | ||
/// コレクション自体のパス。 | ||
String get path; | ||
|
||
/// Parse for Json. | ||
/// | ||
/// Json用にパースする。 | ||
DynamicMap toMap(T value); | ||
|
||
/// Methods for filtering data as it is stored. | ||
/// | ||
/// Each element after being [toMap] and its corresponding [value] are passed to [rawData], so rewrite [rawData] and return it. | ||
/// | ||
/// データが保存される際にデータをフィルタリングするためのメソッド。 | ||
/// | ||
/// [rawData]に[toMap]されたあとの各要素とそれに対応する[value]が渡されるので[rawData]を書き換えて返してください。 | ||
@mustCallSuper | ||
DynamicMap filterOnSave(DynamicMap rawData, T value) { | ||
return rawData; | ||
} | ||
} | ||
|
||
/// {@template model_initial_document} | ||
/// Data to be passed to `data` of various [ModelAdapter]. | ||
/// | ||
/// Specify the path of the document itself in [path] and a value in [value]. | ||
/// | ||
/// You can parse for Json by using [toMap]. | ||
/// | ||
/// 各種[ModelAdapter]の`data`に渡すデータ。 | ||
/// | ||
/// [path]にドキュメント自体のパスを指定し、[value]に値を指定します。 | ||
/// | ||
/// [toMap]を利用することでJson用にパースすることができます。 | ||
/// {@endtemplate} | ||
abstract class ModelInitialDocument<T> extends ModelInitialValue<T> { | ||
/// {@template model_initial_document} | ||
/// Data to be passed to `data` of various [ModelAdapter]. | ||
/// | ||
/// Specify the path of the document itself in [path] and a value in [value]. | ||
/// | ||
/// You can parse for Json by using [toMap]. | ||
/// | ||
/// 各種[ModelAdapter]の`data`に渡すデータ。 | ||
/// | ||
/// [path]にドキュメント自体のパスを指定し、[value]に値を指定します。 | ||
/// | ||
/// [toMap]を利用することでJson用にパースすることができます。 | ||
/// {@endtemplate} | ||
const ModelInitialDocument(this.value); | ||
|
||
/// Initial value. | ||
/// | ||
/// 初期値。 | ||
final T value; | ||
|
||
@override | ||
String toString() { | ||
return value.toString(); | ||
} | ||
} | ||
|
||
/// {@template model_initial_collection} | ||
/// Data to be passed to `data` of various [ModelAdapter]. | ||
/// | ||
/// Specify the path to the collection itself in [path] and the ID and value Map in [value]. | ||
/// | ||
/// You can parse for Json by using [toMap]. | ||
/// | ||
/// 各種[ModelAdapter]の`data`に渡すデータ。 | ||
/// | ||
/// [path]にコレクション自体のパスを指定し、[value]にIDと値のMapを指定します。 | ||
/// | ||
/// [toMap]を利用することでJson用にパースすることができます。 | ||
/// {@endtemplate} | ||
abstract class ModelInitialCollection<T> extends ModelInitialValue<T> { | ||
/// {@template model_initial_collection} | ||
/// Data to be passed to `data` of various [ModelAdapter]. | ||
/// | ||
/// Specify the path to the collection itself in [path] and the ID and value Map in [value]. | ||
/// | ||
/// You can parse for Json by using [toMap]. | ||
/// | ||
/// 各種[ModelAdapter]の`data`に渡すデータ。 | ||
/// | ||
/// [path]にコレクション自体のパスを指定し、[value]にIDと値のMapを指定します。 | ||
/// | ||
/// [toMap]を利用することでJson用にパースすることができます。 | ||
/// {@endtemplate} | ||
const ModelInitialCollection(this.value); | ||
|
||
/// ID and value Map. | ||
/// | ||
/// IDと値のMap。 | ||
final Map<String, T> value; | ||
|
||
@override | ||
String toString() { | ||
return value.toString(); | ||
} | ||
} | ||
|
||
/// [ModelInitialDocument] using [DynamicMap]. | ||
/// | ||
/// [DynamicMap]を利用した[ModelInitialDocument]。 | ||
/// | ||
/// {@macro model_initial_document} | ||
class DynamicModelInitialDocument extends ModelInitialDocument<DynamicMap> { | ||
/// [ModelInitialDocument] using [DynamicMap]. | ||
/// | ||
/// [DynamicMap]を利用した[ModelInitialDocument]。 | ||
/// | ||
/// {@macro model_initial_document} | ||
const DynamicModelInitialDocument(this.path, super.value); | ||
|
||
@override | ||
final String path; | ||
|
||
@override | ||
DynamicMap toMap(DynamicMap value) => value; | ||
} | ||
|
||
/// [ModelInitialCollection] using [DynamicMap]. | ||
/// | ||
/// [DynamicMap]を利用した[ModelInitialCollection]。 | ||
/// | ||
/// {@macro model_initial_collection} | ||
class DynamicModelInitialCollection extends ModelInitialCollection<DynamicMap> { | ||
/// [ModelInitialCollection] using [DynamicMap]. | ||
/// | ||
/// [DynamicMap]を利用した[ModelInitialCollection]。 | ||
/// | ||
/// {@macro model_initial_collection} | ||
const DynamicModelInitialCollection(this.path, super.value); | ||
|
||
@override | ||
final String path; | ||
|
||
@override | ||
DynamicMap toMap(DynamicMap value) => 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
Oops, something went wrong.