skadistats.clarity.event.EventListener Java Examples
The following examples show how to use
skadistats.clarity.event.EventListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: clarity Author: skadistats File: ExecutionModel.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
private void requireProcessorClass(Class<?> processorClass) { if (!hasProcessorForClass(processorClass)) { log.debug("require processor %s", processorClass.getName()); processors.put(processorClass, null); List<UsagePoint<? extends Annotation>> ups = findUsagePoints(processorClass); for (UsagePoint<? extends Annotation> up : ups) { usagePoints.add(up); if (up instanceof EventListener) { requireEventListener((EventListener) up); } else if (up instanceof InitializerMethod) { registerInitializer((InitializerMethod) up); } else { requireProvider(up); } } } }
Example #2
Source Project: clarity Author: skadistats File: BaseStringTableEmitter.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Initializer(OnStringTableEntry.class) public void initStringTableEntryEvent(final EventListener<OnStringTableEntry> eventListener) { final String tableName = eventListener.getAnnotation().value(); requestedTables.add(tableName); if ("*".equals(tableName)) { updateEventTables = requestedTables; } else { updateEventTables.add(tableName); } eventListener.setInvocationPredicate(args -> { StringTable t = (StringTable) args[0]; return "*".equals(tableName) || t.getName().equals(tableName); }); }
Example #3
Source Project: clarity Author: skadistats File: InputSourceProcessor.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Initializer(OnMessageContainer.class) public void initOnMessageContainerListener(final EventListener<OnMessageContainer> listener) { listener.setInvocationPredicate(args -> { Class<? extends GeneratedMessage> clazz = (Class<? extends GeneratedMessage>) args[0]; return listener.getAnnotation().value().isAssignableFrom(clazz); }); }
Example #4
Source Project: clarity Author: skadistats File: PropertyChange.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
public ListenerAdapter(EventListener<OnEntityPropertyChanged> listener) { classPattern = Pattern.compile(listener.getAnnotation().classPattern()); propertyPattern = Pattern.compile(listener.getAnnotation().propertyPattern()); int count = 1 << engineType.getIndexBits(); classMatchesForEntity = new TriStateTable(count); propertyMatchesForEntity = new Map[count]; for (int i = 0; i < count; i++) { propertyMatchesForEntity[i] = new HashMap<>(); } }
Example #5
Source Project: clarity Author: skadistats File: GameEvents.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Initializer(OnGameEventDescriptor.class) public void initOnGameEventDescriptor(final EventListener<OnGameEventDescriptor> eventListener) { eventListener.setInvocationPredicate(args -> { String v = eventListener.getAnnotation().value(); GameEventDescriptor ev = (GameEventDescriptor) args[0]; return v.length() == 0 || v.equals(ev.getName()); }); }
Example #6
Source Project: clarity Author: skadistats File: GameEvents.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Initializer(OnGameEvent.class) public void initOnGameEvent(final EventListener<OnGameEvent> eventListener) { eventListener.setInvocationPredicate(args -> { String v = eventListener.getAnnotation().value(); GameEvent ev = (GameEvent) args[0]; return v.length() == 0 || v.equals(ev.getName()); }); }
Example #7
Source Project: clarity Author: skadistats File: ExecutionModel.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
private void requireEventListener(EventListener eventListener) { log.debug("require event listener %s", eventListener.getUsagePointClass()); Set<EventListener> eventListeners = processedEvents.get(eventListener.getUsagePointClass()); if (eventListeners == null) { eventListeners = new HashSet<>(); processedEvents.put(eventListener.getUsagePointClass(), eventListeners); } eventListeners.add(eventListener); requireProvider(eventListener); }
Example #8
Source Project: clarity Author: skadistats File: ExecutionModel.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
private <A extends Annotation> Set<EventListener<A>> computeListenersForEvent(Class<A> eventType, Class... parameterTypes) { Set<EventListener<A>> listeners = new HashSet<>(); Set<EventListener> eventListeners = processedEvents.get(eventType); if (eventListeners != null) { for (@SuppressWarnings("unchecked") EventListener<A> listener : eventListeners) { if (listener.isInvokedForParameterClasses(parameterTypes)) { listeners.add(listener); } } } return listeners; }
Example #9
Source Project: parser Author: odota File: Wards.java License: MIT License | 4 votes |
@Initializer(OnWardKilled.class) public void initOnWardKilled(final Context ctx, final EventListener<OnWardKilled> listener) { evKilled = ctx.createEvent(OnWardKilled.class, Entity.class, String.class); }
Example #10
Source Project: parser Author: odota File: Wards.java License: MIT License | 4 votes |
@Initializer(OnWardExpired.class) public void initOnWardExpired(final Context ctx, final EventListener<OnWardExpired> listener) { evExpired = ctx.createEvent(OnWardExpired.class, Entity.class); }
Example #11
Source Project: parser Author: odota File: Wards.java License: MIT License | 4 votes |
@Initializer(OnWardPlaced.class) public void initOnWardPlaced(final Context ctx, final EventListener<OnWardPlaced> listener) { evPlaced = ctx.createEvent(OnWardPlaced.class, Entity.class); }
Example #12
Source Project: clarity-examples Author: skadistats File: SpawnsAndDeaths.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnEntitySpawned.class) public void initOnEntitySpawned(final Context ctx, final EventListener<OnEntitySpawned> eventListener) { init(ctx); evSpawned = ctx.createEvent(OnEntitySpawned.class, Entity.class); }
Example #13
Source Project: clarity-examples Author: skadistats File: SpawnsAndDeaths.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnEntityDying.class) public void initOnEntityDying(final Context ctx, final EventListener<OnEntityDying> eventListener) { init(ctx); evDying = ctx.createEvent(OnEntityDying.class, Entity.class); }
Example #14
Source Project: clarity-examples Author: skadistats File: SpawnsAndDeaths.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnEntityDied.class) public void initOnEntityDied(final Context ctx, final EventListener<OnEntityDied> eventListener) { init(ctx); evDied = ctx.createEvent(OnEntityDied.class, Entity.class); }
Example #15
Source Project: clarity Author: skadistats File: InputSourceProcessor.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnMessage.class) public void initOnMessageListener(final EventListener<OnMessage> listener) { listener.setParameterClasses(listener.getAnnotation().value()); unpackUserMessages |= engineType.isUserMessage(listener.getAnnotation().value()); }
Example #16
Source Project: clarity Author: skadistats File: InputSourceProcessor.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnPostEmbeddedMessage.class) public void initOnPostEmbeddedMessageListener(final EventListener<OnPostEmbeddedMessage> listener) { listener.setParameterClasses(listener.getAnnotation().value(), BitStream.class); unpackUserMessages |= engineType.isUserMessage(listener.getAnnotation().value()); }
Example #17
Source Project: clarity Author: skadistats File: Entities.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnEntityCreated.class) public void initOnEntityCreated(final EventListener<OnEntityCreated> listener) { listener.setInvocationPredicate(getInvocationPredicate(listener.getAnnotation().classPattern())); }
Example #18
Source Project: clarity Author: skadistats File: Entities.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnEntityDeleted.class) public void initOnEntityDeleted(final EventListener<OnEntityDeleted> listener) { listener.setInvocationPredicate(getInvocationPredicate(listener.getAnnotation().classPattern())); }
Example #19
Source Project: clarity Author: skadistats File: Entities.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnEntityUpdated.class) public void initOnEntityUpdated(final EventListener<OnEntityUpdated> listener) { listener.setInvocationPredicate(getInvocationPredicate(listener.getAnnotation().classPattern())); }
Example #20
Source Project: clarity Author: skadistats File: Entities.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnEntityEntered.class) public void initOnEntityEntered(final EventListener<OnEntityEntered> listener) { listener.setInvocationPredicate(getInvocationPredicate(listener.getAnnotation().classPattern())); }
Example #21
Source Project: clarity Author: skadistats File: Entities.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnEntityLeft.class) public void initOnEntityLeft(final EventListener<OnEntityLeft> listener) { listener.setInvocationPredicate(getInvocationPredicate(listener.getAnnotation().classPattern())); }
Example #22
Source Project: clarity Author: skadistats File: PropertyChange.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
@Initializer(OnEntityPropertyChanged.class) public void initListener(final EventListener<OnEntityPropertyChanged> listener) { ListenerAdapter adapter = new ListenerAdapter(listener); adapters.add(adapter); listener.setInvocationPredicate(adapter.invocationPredicate); }
Example #23
Source Project: clarity Author: skadistats File: ExecutionModel.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
public <A extends Annotation> Event<A> createEvent(Class<A> eventType, Class... parameterTypes) { Set<EventListener<A>> listeners = computeListenersForEvent(eventType, parameterTypes); return new Event<>(listeners); }