*/
package org.opendaylight.controller.cluster.access.client;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
/**
- * Base behavior attached to {@link AbstractClientActor}. Exposes
- * @author user
+ * Base behavior attached to {@link AbstractClientActor}.
*
* @param <C> Type of associated context
*
* @author Robert Varga
*/
@Beta
-public abstract class AbstractClientActorBehavior<C extends AbstractClientActorContext> {
- private final C context;
+public abstract class AbstractClientActorBehavior<C extends AbstractClientActorContext> implements AutoCloseable {
+ private final @NonNull C context;
- AbstractClientActorBehavior(final @Nonnull C context) {
+ AbstractClientActorBehavior(final @NonNull C context) {
// Hidden to prevent outside subclasses. Users instantiated this via ClientActorBehavior
- this.context = Preconditions.checkNotNull(context);
+ this.context = requireNonNull(context);
}
/**
*
* @return A client actor context instance.
*/
- protected final @Nonnull C context() {
+ protected final @NonNull C context() {
return context;
}
*
* @return Persistence identifier
*/
- protected final @Nonnull String persistenceId() {
+ protected final @NonNull String persistenceId() {
return context.persistenceId();
}
/**
* Return an {@link ActorRef} of this ClientActor.
*
- * @return
+ * @return Actor associated with this behavior
*/
- public final @Nonnull ActorRef self() {
+ public final @NonNull ActorRef self() {
return context.self();
}
+ @Override
+ public void close() {
+ }
+
/**
* Implementation-internal method for handling an incoming command message.
*
* @param command Command message
* @return Behavior which should be used with the next message. Return null if this actor should shut down.
*/
- abstract @Nullable AbstractClientActorBehavior<?> onReceiveCommand(@Nonnull Object command);
+ abstract @Nullable AbstractClientActorBehavior<?> onReceiveCommand(@NonNull Object command);
/**
* Implementation-internal method for handling an incoming recovery message coming from persistence.
* @param recover Recover message
* @return Behavior which should be used with the next message. Return null if this actor should shut down.
*/
- abstract @Nullable AbstractClientActorBehavior<?> onReceiveRecover(@Nonnull Object recover);
+ abstract @Nullable AbstractClientActorBehavior<?> onReceiveRecover(@NonNull Object recover);
}