Search in sources :

Example 6 with EventClass

use of io.spine.type.EventClass in project core-java by SpineEventEngine.

the class IdSetFunctions method findAndApply.

/**
     * Finds a function for the passed event and applies it.
     *
     * <p>If there is no function for the passed event applies the default function.
     *
     * @param event   the event message
     * @param context the event context
     * @return the set of entity IDs
     */
public Set<I> findAndApply(Message event, EventContext context) {
    final EventClass eventClass = EventClass.of(event);
    final IdSetEventFunction<I, Message> func = map.get(eventClass);
    if (func != null) {
        final Set<I> result = func.apply(event, context);
        return result;
    }
    final Set<I> result = defaultFunction.apply(event, context);
    return result;
}
Also used : EventClass(io.spine.type.EventClass) Message(com.google.protobuf.Message)

Example 7 with EventClass

use of io.spine.type.EventClass in project core-java by SpineEventEngine.

the class IdSetFunctions method remove.

/**
     * Removes a function for the passed event class.
     */
public <E extends Message> void remove(Class<E> eventClass) {
    final EventClass clazz = EventClass.of(eventClass);
    map.remove(clazz);
}
Also used : EventClass(io.spine.type.EventClass)

Aggregations

EventClass (io.spine.type.EventClass)7 Message (com.google.protobuf.Message)3 IdSetEventFunction (io.spine.server.entity.idfunc.IdSetEventFunction)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 EventFilter (io.spine.server.event.EventFilter)1 ConstraintViolation (io.spine.validate.ConstraintViolation)1