diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2017-04-19 16:52:31 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2017-04-19 16:52:31 +0200 |
commit | 4eaaddb6813b0f563c9022e67f7a4d4a2fc8bae1 (patch) | |
tree | e0be79c1294562957089ca8641f65d6cf83677af /java/MyMyBatis/src/AbstractModel.java | |
parent | 6fcde2655e8aedd56bff1de4e85bb83fee15c591 (diff) | |
download | share-4eaaddb6813b0f563c9022e67f7a4d4a2fc8bae1.zip share-4eaaddb6813b0f563c9022e67f7a4d4a2fc8bae1.tar.gz |
java : MyMyBatis : use java 8 default interface implementation to gain free save() and delete() methods
Diffstat (limited to 'java/MyMyBatis/src/AbstractModel.java')
-rw-r--r-- | java/MyMyBatis/src/AbstractModel.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/java/MyMyBatis/src/AbstractModel.java b/java/MyMyBatis/src/AbstractModel.java index 81bab76..365472c 100644 --- a/java/MyMyBatis/src/AbstractModel.java +++ b/java/MyMyBatis/src/AbstractModel.java @@ -1,7 +1,15 @@ package ch.asynk; -public interface AbstractModel<TIdentity> +public interface AbstractModel<TIdentity, TObject> { boolean isUnsaved(); + + TObject self(); + + AbstractMapper<TIdentity, TObject> getDAO(); + + default void save() { getDAO().save(self()); } + + default int delete() { return getDAO().delete(self()); } } |