-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from cyklon73/internal
InternalEvents
- Loading branch information
Showing
5 changed files
with
140 additions
and
19 deletions.
There are no files selected for viewing
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
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
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
32 changes: 32 additions & 0 deletions
32
src/main/java/de/cyklon/jevent/internal/EventCallJEvent.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package de.cyklon.jevent.internal; | ||
|
||
import de.cyklon.jevent.Event; | ||
import de.cyklon.jevent.EventManager; | ||
|
||
public class EventCallJEvent extends InternalJEvent { | ||
|
||
private final Event initialEvent; | ||
private Event event; | ||
|
||
public EventCallJEvent(EventManager manager, Event event) { | ||
super(manager); | ||
this.event = event; | ||
this.initialEvent = event; | ||
} | ||
|
||
public Event getEvent() { | ||
return event; | ||
} | ||
|
||
public void setEvent(Event event) { | ||
this.event = event; | ||
} | ||
|
||
public Event getInitialEvent() { | ||
return initialEvent; | ||
} | ||
|
||
public boolean isEventModified() { | ||
return !initialEvent.equals(event); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/de/cyklon/jevent/internal/InternalJEvent.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.cyklon.jevent.internal; | ||
|
||
import de.cyklon.jevent.CancellableEvent; | ||
import de.cyklon.jevent.Event; | ||
import de.cyklon.jevent.EventManager; | ||
import de.cyklon.reflection.entities.ReflectClass; | ||
import de.cyklon.reflection.entities.ReflectPackage; | ||
|
||
public abstract class InternalJEvent extends CancellableEvent { | ||
|
||
private static final ReflectPackage INTERNAL_PACKAGE = ReflectClass.wrap(InternalJEvent.class).getPackage(); | ||
|
||
private final EventManager manager; | ||
|
||
protected InternalJEvent(EventManager manager) { | ||
this.manager = manager; | ||
} | ||
|
||
public EventManager getManager() { | ||
return manager; | ||
} | ||
|
||
public static <T extends Event> boolean isInternal(T event) { | ||
return ReflectClass.getClass(event).getPackage().equals(INTERNAL_PACKAGE); | ||
} | ||
} |