package io.vertx.core.eventbus.impl;
import io.vertx.core.Context;
import io.vertx.core.spi.metrics.EventBusMetrics;
public class HandlerHolder<T> {
private final Context context;
private final HandlerRegistration<T> handler;
private final boolean replyHandler;
private final boolean localOnly;
private boolean removed;
public HandlerHolder(HandlerRegistration<T> handler, boolean replyHandler, boolean localOnly,
Context context) {
this.context = context;
this.handler = handler;
this.replyHandler = replyHandler;
this.localOnly = localOnly;
}
boolean setRemoved() {
boolean unregistered = false;
synchronized (this) {
if (!removed) {
removed = true;
unregistered = true;
}
}
return unregistered;
}
public synchronized boolean isRemoved() {
return removed;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
HandlerHolder that = (HandlerHolder) o;
if (handler != null ? !handler.equals(that.handler) : that.handler != null) return false;
return true;
}
@Override
public int hashCode() {
return handler != null ? handler.hashCode() : 0;
}
public Context getContext() {
return context;
}
public HandlerRegistration<T> getHandler() {
return handler;
}
public boolean isReplyHandler() {
return replyHandler;
}
public boolean isLocalOnly() {
return localOnly;
}
;
}