com.alon.spring.crud.domain.service.BiHookable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of crud-api-base Show documentation
Show all versions of crud-api-base Show documentation
Fornece implementação básica e expansível para criação API's CRUD com Spring Boot e Spring Data JPA.
package com.alon.spring.crud.domain.service;
import org.springframework.data.domain.Page;
import java.util.function.BiFunction;
import static com.alon.spring.crud.domain.service.BiHookManager.addHook;
import static com.alon.spring.crud.domain.service.BiHookManager.executeHook;
import static com.alon.spring.crud.domain.service.LifeCycleHook.*;
public interface BiHookable {
default void addBeforeSearchHook(
BiFunction function) {
addHook(this, BEFORE_SEARCH, function);
}
default void addAfterSearchHook(
BiFunction, MASTER_ENTITY_ID_TYPE, Page> function) {
addHook(this, AFTER_SEARCH, function);
}
default void addBeforeReadHook(
BiFunction function) {
addHook(this, BEFORE_READ, function);
}
default void addAfterReadHook(
BiFunction function) {
addHook(this, AFTER_READ, function);
}
default void addBeforeCreateHook(
BiFunction function) {
addHook(this, BEFORE_CREATE, function);
}
default void addAfterCreateHook(
BiFunction function) {
addHook(this, AFTER_CREATE, function);
}
default void addBeforeUpdateHook(
BiFunction function) {
addHook(this, BEFORE_UPDATE, function);
}
default void addAfterUpdateHook(
BiFunction function) {
addHook(this, AFTER_UPDATE, function);
}
default void addBeforeDeleteHook(
BiFunction function) {
addHook(this, BEFORE_DELETE, function);
}
default void addAfterDeleteHook(
BiFunction function) {
addHook(this, AFTER_DELETE, function);
}
default SearchCriteria executeBeforeSearchHooks(SearchCriteria search, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, BEFORE_SEARCH, search, masterId);
}
default Page executeAfterSearchHooks(Page page, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, AFTER_SEARCH, page, masterId);
}
default ENTITY_ID_TYPE executeBeforeReadHooks(ENTITY_ID_TYPE id, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, BEFORE_READ, id, masterId);
}
default ENTITY_TYPE executeAfterReadHooks(ENTITY_TYPE entity, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, AFTER_READ, entity, masterId);
}
default ENTITY_TYPE executeBeforeCreateHooks(ENTITY_TYPE entity, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, BEFORE_CREATE, entity, masterId);
}
default ENTITY_TYPE executeAfterCreateHooks(ENTITY_TYPE entity, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, AFTER_CREATE, entity, masterId);
}
default ENTITY_TYPE executeBeforeUpdateHooks(ENTITY_TYPE entity, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, BEFORE_UPDATE, entity, masterId);
}
default ENTITY_TYPE executeAfterUpdateHooks(ENTITY_TYPE entity, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, AFTER_UPDATE, entity, masterId);
}
default ENTITY_ID_TYPE executeBeforeDeleteHooks(ENTITY_ID_TYPE id, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, BEFORE_DELETE, id, masterId);
}
default ENTITY_ID_TYPE executeAfterDeleteHooks(ENTITY_ID_TYPE id, MASTER_ENTITY_ID_TYPE masterId) {
return executeHook(this, AFTER_DELETE, id, masterId);
}
default void clearHooks(LifeCycleHook... hookTypes) {
BiHookManager.clearHooks(this, hookTypes);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy