dk.apaq.crud.CrudEvent Maven / Gradle / Ivy
/*
* CrudContainer
* Copyright (C) 2011 by Apaq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package dk.apaq.crud;
/**
* Event used when Crud's notifies of its actions.
*/
public class CrudEvent {
private final Crud crud;
/**
* Create new basic CrudEvent.
* @param crud The crud that generated the event.
*/
public CrudEvent(Crud crud) {
this.crud = crud;
}
/**
* Retrieves the Crud that generated the wvent.
* @return The crud.
*/
public Crud getCrud() {
return crud;
}
/**
* Crud event for events that carries an id of the entity
* @param The id type
* @param The bean type
*/
public static class WithId extends CrudEvent {
private final IDT id;
/**
* Create new CrudEvent with id.
* @param crud The Crud generating the event.
* @param id The id of the entity.
*/
public WithId(Crud crud, IDT id) {
super(crud);
this.id = id;
}
/**
* Retrieve the entity id.
* @return The entity id.
*/
public IDT getEntityId() {
return id;
}
}
/**
* Crud event for events that carries the entity
* @param The id type
* @param The bean type
*/
public static class WithEntity extends CrudEvent {
private final BT bean;
/**
* Create new CrudEvent with id and entity.
* @param crud The Crud generating the event.
* @param id The id of the entity.
* @param entity The entity it self.
*/
public WithEntity(Crud crud, BT bean) {
super(crud);
this.bean = bean;
}
/**
* Retieves the entity.
* @return
*/
public BT getEntity() {
return bean;
}
}
/**
* Crud event for events that carries an id of the entity and the entity itself
* @param The id type
* @param The bean type
*/
public static class WithIdAndEntity extends WithId {
private final BT bean;
/**
* Create new CrudEvent with id and entity.
* @param crud The Crud generating the event.
* @param id The id of the entity.
* @param entity The entity it self.
*/
public WithIdAndEntity(Crud crud, IDT id, BT bean) {
super(crud, id);
this.bean = bean;
}
/**
* Retieves the entity.
* @return
*/
public BT getEntity() {
return bean;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy