TakeInterest.java
package org.microspace.event;
import org.microspace.annotation.ThreadId;
import org.microspace.table.column.Accessor;
import org.microspace.table.query.TableQuery;
/**
* A Take Handler interest.
* @author Gaspar Sinai - {@literal gaspar.sinai@microspace.org}
* @version 2016-06-26
* @param <T> is the type of the {@link ThreadId ThreadId} annotated field.
* @param <M> is the type of the message.
*/
class TakeInterest<T,M> {
private final TableQuery<M> query;
private final TakeHandler<M> handler;
private final Accessor<M> accessor;
private boolean performTake;
private boolean mergeMessages;
public TakeInterest(Accessor<M> accessor, TableQuery<M> query, TakeHandler<M> handler) {
this.accessor = accessor;
this.query = query;
this.handler = handler;
this.performTake = !(accessor.isUpdatableRecord() || accessor.isLocalRecord());
this.mergeMessages = accessor.isUpdatableRecord();
}
public TableQuery<M> getQuery() {
return query;
}
public TakeHandler<M> getHandler() {
return handler;
}
@SuppressWarnings("unchecked")
public T getThreadId (M message) {
return (T) accessor.getThreadIdGetSetPair().get(message);
}
public boolean isPerformTake() {
return performTake;
}
public boolean isMergeMessages() {
return mergeMessages;
}
public Accessor<M> getAccessor () {
return accessor;
}
}