com.github.panchitoboy.common.ecb.boundary.Boundary Maven / Gradle / Ivy
package com.github.panchitoboy.common.ecb.boundary;
import com.github.panchitoboy.common.ecb.control.Control;
import com.github.panchitoboy.common.ecb.helper.ClassHelper;
import java.io.Serializable;
import java.util.List;
import javax.inject.Inject;
import javax.validation.Valid;
public abstract class Boundary {
@Inject
ClassHelper entityClass;
@Inject
Control control;
public ClassHelper getClassHelper() {
return entityClass;
}
public Control getControl() {
return control;
}
public T find(Serializable id) {
return getControl().find(getClassHelper().getInjectionClass(), id);
}
public List findAll() {
return getControl().findAll(getClassHelper().getInjectionClass());
}
public T create(@Valid T entity) {
getControl().create(entity);
return entity;
}
public T update(@Valid T entity) {
getControl().update(entity);
return entity;
}
public T remove(Serializable id) {
T instance = find(id);
getControl().remove(instance);
return instance;
}
}