refactor aggregate build process
This commit is contained in:
@ -4,6 +4,7 @@ import lombok.Getter;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Repräsentiert viele Events als aggregiertes Objekt.
|
||||
@ -13,12 +14,20 @@ public abstract class Aggregate {
|
||||
|
||||
protected long id;
|
||||
|
||||
public void apply(List<Event> events) {
|
||||
events.forEach(this::applyEvent);
|
||||
}
|
||||
|
||||
public void apply(Event event) {
|
||||
applyEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ruft die spezifische applyEvent-Methode im entsprechenden Aggregat auf.
|
||||
*
|
||||
* @param event Event, welches aggregiert wird
|
||||
*/
|
||||
public void applyEvent(Event event) {
|
||||
private void applyEvent(Event event) {
|
||||
try {
|
||||
Method method = this.getClass().getDeclaredMethod("applyEvent", event.getClass());
|
||||
method.setAccessible(true);
|
||||
|
||||
Reference in New Issue
Block a user