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 File: ExecutionModel.java From clarity with 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 File: ExecutionModel.java From clarity with 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 #3
Source File: ExecutionModel.java From clarity with 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 #4
Source File: GameEvents.java From clarity with 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 #5
Source File: BaseStringTableEmitter.java From clarity with 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 #6
Source File: GameEvents.java From clarity with 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 #7
Source File: InputSourceProcessor.java From clarity with 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 #8
Source File: PropertyChange.java From clarity with 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 #9
Source File: Entities.java From clarity with 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 #10
Source File: ExecutionModel.java From clarity with 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); }
Example #11
Source File: PropertyChange.java From clarity with 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 #12
Source File: Entities.java From clarity with 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 #13
Source File: Entities.java From clarity with 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 #14
Source File: Entities.java From clarity with 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 #15
Source File: Wards.java From parser with 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 #16
Source File: Entities.java From clarity with 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 #17
Source File: InputSourceProcessor.java From clarity with 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 #18
Source File: InputSourceProcessor.java From clarity with 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 #19
Source File: SpawnsAndDeaths.java From clarity-examples with 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 #20
Source File: SpawnsAndDeaths.java From clarity-examples with 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 #21
Source File: SpawnsAndDeaths.java From clarity-examples with 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 #22
Source File: Wards.java From parser with 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 #23
Source File: Wards.java From parser with MIT License | 4 votes |
@Initializer(OnWardExpired.class) public void initOnWardExpired(final Context ctx, final EventListener<OnWardExpired> listener) { evExpired = ctx.createEvent(OnWardExpired.class, Entity.class); }