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
2 changed files
with
91 additions
and
77 deletions.
There are no files selected for viewing
97 changes: 28 additions & 69 deletions
97
activejdbc/src/main/java/org/javalite/activejdbc/CallbackSupport.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 |
---|---|---|
@@ -1,92 +1,51 @@ | ||
/* | ||
Copyright 2009-2014 Igor Polevoy | ||
Copyright 2009-2015 Igor Polevoy | ||
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 | ||
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 | ||
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. | ||
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. | ||
*/ | ||
|
||
|
||
package org.javalite.activejdbc; | ||
|
||
/** | ||
* @author Igor Polevoy | ||
* @author Eric Nielsen | ||
*/ | ||
class CallbackSupport { | ||
abstract class CallbackSupport { | ||
|
||
void fireBeforeSave(Model m){ | ||
beforeSave(); | ||
for (CallbackListener callback : m.modelRegistryLocal().callbacks()) { | ||
callback.beforeSave(m); | ||
} | ||
protected void beforeSave() { | ||
// overridable | ||
} | ||
|
||
void fireAfterSave(Model m){ | ||
afterSave(); | ||
for (CallbackListener callback : m.modelRegistryLocal().callbacks()) { | ||
callback.afterSave(m); | ||
} | ||
protected void afterSave() { | ||
// overridable | ||
} | ||
|
||
void fireBeforeCreate(Model m){ | ||
beforeCreate(); | ||
for (CallbackListener callback : m.modelRegistryLocal().callbacks()) { | ||
callback.beforeCreate(m); | ||
} | ||
protected void beforeCreate() { | ||
// overridable | ||
} | ||
|
||
void fireAfterCreate(Model m){ | ||
afterCreate(); | ||
for (CallbackListener callback : m.modelRegistryLocal().callbacks()) { | ||
callback.afterCreate(m); | ||
} | ||
protected void afterCreate() { | ||
// overridable | ||
} | ||
|
||
void fireBeforeDelete(Model m){ | ||
beforeDelete(); | ||
for (CallbackListener callback : m.modelRegistryLocal().callbacks()) { | ||
callback.beforeDelete(m); | ||
} | ||
protected void beforeDelete() { | ||
// overridable | ||
} | ||
|
||
void fireAfterDelete(Model m){ | ||
afterDelete(); | ||
for (CallbackListener callback : m.modelRegistryLocal().callbacks()) { | ||
callback.afterDelete(m); | ||
} | ||
protected void afterDelete() { | ||
// overridable | ||
} | ||
|
||
void fireBeforeValidation(Model m){ | ||
beforeValidation(); | ||
for(CallbackListener callback: m.modelRegistryLocal().callbacks()) | ||
callback.beforeValidation(m); | ||
protected void beforeValidation() { | ||
// overridable | ||
} | ||
|
||
void fireAfterValidation(Model m){ | ||
afterValidation(); | ||
for (CallbackListener callback : m.modelRegistryLocal().callbacks()) { | ||
callback.afterValidation(m); | ||
} | ||
protected void afterValidation() { | ||
// overridable | ||
} | ||
|
||
//overridable instance methods | ||
protected void beforeSave(){} | ||
protected void afterSave(){} | ||
|
||
protected void beforeCreate(){} | ||
protected void afterCreate(){} | ||
|
||
protected void beforeDelete(){} | ||
protected void afterDelete(){} | ||
|
||
protected void beforeValidation(){} | ||
protected void afterValidation(){} | ||
} |
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