*/
package org.opendaylight.controller.cluster.datastore.messages;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorSelection;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
/**
* Local message DTO that contains information about the primary shard.
public class PrimaryShardInfo {
private final ActorSelection primaryShardActor;
private final short primaryShardVersion;
- private final Optional<DataTree> localShardDataTree;
+ private final ReadOnlyDataTree localShardDataTree;
+
+ public PrimaryShardInfo(@NonNull ActorSelection primaryShardActor, short primaryShardVersion,
+ @NonNull ReadOnlyDataTree localShardDataTree) {
+ this.primaryShardActor = requireNonNull(primaryShardActor);
+ this.primaryShardVersion = primaryShardVersion;
+ this.localShardDataTree = requireNonNull(localShardDataTree);
+ }
- public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, short primaryShardVersion,
- @Nonnull Optional<DataTree> localShardDataTree) {
- this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor);
+ public PrimaryShardInfo(@NonNull ActorSelection primaryShardActor, short primaryShardVersion) {
+ this.primaryShardActor = requireNonNull(primaryShardActor);
this.primaryShardVersion = primaryShardVersion;
- this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree);
+ this.localShardDataTree = null;
}
/**
* Returns an ActorSelection representing the primary shard actor.
*/
- public @Nonnull ActorSelection getPrimaryShardActor() {
+ public @NonNull ActorSelection getPrimaryShardActor() {
return primaryShardActor;
}
* Returns an Optional whose value contains the primary shard's DataTree if the primary shard is local
* to the caller. Otherwise the Optional value is absent.
*/
- public @Nonnull Optional<DataTree> getLocalShardDataTree() {
- return localShardDataTree;
+ public @NonNull Optional<ReadOnlyDataTree> getLocalShardDataTree() {
+ return Optional.ofNullable(localShardDataTree);
}
}