From b4bf55727093657662d8c16a50fa85f87978a586 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 7 Feb 2019 17:53:09 +0100 Subject: [PATCH] Reduce JSR305 proliferation retention=runtime annotations are mixing really badly with Java EE injection and Java 11. Make sure we do not use javax.annotation package in APIs and reduce overall proliferation inside implementations. Change-Id: I569815f0336efdc0de662c3b80f0fa6e5dd47d8a Signed-off-by: Robert Varga --- .../blueprint/BlueprintBundleTracker.java | 5 +- ...ractDependentComponentFactoryMetadata.java | 5 +- .../ext/DataStoreAppConfigMetadata.java | 13 ++--- .../timer/HashedWheelTimerCloseable.java | 10 ++-- .../controller/cluster/access/ABIVersion.java | 18 +++--- .../access/AbstractVersionException.java | 12 ++-- .../AbortLocalTransactionRequest.java | 6 +- .../AbstractReadPathTransactionRequest.java | 13 +++-- .../CommitLocalTransactionRequest.java | 15 ++--- .../access/commands/ConnectClientRequest.java | 11 ++-- .../access/commands/ConnectClientSuccess.java | 26 ++++----- .../commands/ExistsTransactionRequest.java | 6 +- .../commands/ReadTransactionRequest.java | 6 +- .../access/concepts/AbstractMessageProxy.java | 17 +++--- .../concepts/AbstractRequestFailureProxy.java | 8 +-- .../access/concepts/AbstractRequestProxy.java | 10 ++-- .../concepts/AbstractResponseProxy.java | 7 +-- .../access/concepts/AbstractSuccessProxy.java | 7 +-- .../cluster/access/concepts/FrontendType.java | 18 +++--- .../cluster/access/concepts/Message.java | 35 +++++------- .../cluster/access/concepts/Request.java | 23 ++++---- .../access/concepts/RequestException.java | 13 +++-- .../access/concepts/RequestFailure.java | 21 +++---- .../access/concepts/RequestSuccess.java | 8 +-- .../cluster/access/concepts/Response.java | 8 +-- .../concepts/TransactionIdentifier.java | 11 ++-- .../access/concepts/FailureEnvelopeTest.java | 20 +++---- .../client/AbstractClientActorBehavior.java | 28 ++++------ .../client/AbstractClientActorContext.java | 21 ++++--- .../client/AbstractClientConnection.java | 25 +++++---- .../access/client/BackendInfoResolver.java | 15 ++--- .../access/client/ClientActorBehavior.java | 25 ++++----- .../access/client/ClientActorContext.java | 32 +++++------ .../access/client/InternalCommand.java | 6 +- .../access/client/RequestCallback.java | 6 +- .../cluster/dom/api/CDSDataTreeProducer.java | 4 +- .../cluster/dom/api/CDSShardAccess.java | 12 ++-- .../dom/api/LeaderLocationListener.java | 4 +- .../impl/AbstractCloseTracked.java | 2 +- .../trace/closetracker/impl/CloseTracked.java | 2 +- .../closetracker/impl/CloseTrackedTrait.java | 11 ++-- .../impl/AbstractTracingWriteTransaction.java | 9 ++- .../md/sal/trace/dom/impl/TracingBroker.java | 5 +- .../messagebus/app/impl/EventSourceTopic.java | 10 ++-- .../cluster/example/ExampleActor.java | 11 ++-- .../controller/cluster/raft/ConfigParams.java | 11 ++-- .../cluster/raft/DefaultConfigParamsImpl.java | 12 ++-- .../controller/cluster/raft/ElectionTerm.java | 6 +- .../cluster/raft/FollowerLogInformation.java | 23 ++++---- .../cluster/raft/PeerAddressResolver.java | 3 +- .../controller/cluster/raft/RaftActor.java | 24 ++++---- .../cluster/raft/RaftActorContext.java | 55 +++++++------------ .../cluster/raft/RaftActorContextImpl.java | 33 +++++------ .../RaftActorLeadershipTransferCohort.java | 4 +- .../cluster/raft/RaftActorRecoveryCohort.java | 5 +- .../RaftActorServerConfigurationSupport.java | 15 ++--- .../cluster/raft/RaftActorSnapshotCohort.java | 11 ++-- .../cluster/raft/ReplicatedLog.java | 17 +++--- .../cluster/raft/ReplicatedLogImpl.java | 11 ++-- .../cluster/raft/SnapshotManager.java | 6 +- .../raft/base/messages/ApplySnapshot.java | 20 +++---- .../base/messages/CaptureSnapshotReply.java | 19 +++---- .../messages/FollowerInitialSyncUpStatus.java | 12 ++-- .../base/messages/LeaderTransitioning.java | 12 ++-- .../base/messages/SendInstallSnapshot.java | 21 ++++--- .../raft/behaviors/AbstractLeader.java | 15 +++-- .../cluster/raft/behaviors/Follower.java | 5 +- .../raft/behaviors/IsolatedLeader.java | 2 +- .../cluster/raft/behaviors/Leader.java | 13 +++-- .../raft/behaviors/RaftActorBehavior.java | 9 +-- .../raft/client/messages/FindLeaderReply.java | 5 +- .../client/messages/GetSnapshotReply.java | 17 +++--- .../client/messages/OnDemandRaftState.java | 5 +- .../messages/AbstractServerChangeReply.java | 15 ++--- .../cluster/raft/messages/AppendEntries.java | 23 ++++---- .../messages/ChangeServersVotingStatus.java | 24 ++++---- .../raft/messages/RemoveServerReply.java | 3 +- .../raft/persisted/MigratedSerializable.java | 4 +- .../persisted/ServerConfigurationPayload.java | 7 +-- .../cluster/raft/persisted/ServerInfo.java | 12 ++-- .../cluster/raft/MockRaftActor.java | 2 - ...otsWithLaggingFollowerIntegrationTest.java | 2 +- .../cluster/raft/persisted/ByteState.java | 17 +++--- .../binding/api/DataObjectModification.java | 27 +++++---- .../binding/api/DataTreeChangeListener.java | 4 +- .../binding/api/DataTreeChangeService.java | 6 +- .../sal/binding/api/DataTreeIdentifier.java | 18 +++--- .../sal/binding/api/DataTreeModification.java | 8 +-- .../sal/binding/api/ForwardingDataBroker.java | 4 +- ...FunctionalNotificationListenerAdapter.java | 3 +- ...BindingDOMNotificationListenerAdapter.java | 3 +- .../BindingDOMRpcImplementationAdapter.java | 11 ++-- .../impl/BindingToNormalizedNodeCodec.java | 2 - .../impl/ContextReferenceExtractor.java | 11 ++-- .../md/sal/binding/spi/AdapterLoader.java | 10 ++-- .../cluster/ActorSystemProvider.java | 7 +-- .../stream/NormalizedNodeInputOutput.java | 8 +-- .../AbstractDataTreeModificationCursor.java | 23 ++++---- .../cluster/io/FileBackedOutputStream.java | 7 +-- .../io/FileBackedOutputStreamFactory.java | 2 +- .../cluster/messaging/MessageAssembler.java | 16 +++--- .../cluster/messaging/MessageSlicer.java | 20 ++++--- .../notifications/LeaderStateChanged.java | 12 ++-- .../persistence/LocalSnapshotStore.java | 7 +-- .../RemoteYangTextSourceProvider.java | 5 +- .../RemoteYangTextSourceProviderImpl.java | 9 ++- .../sal/common/api/MappingCheckedFuture.java | 5 +- .../api/data/AsyncWriteTransaction.java | 3 - .../sal/common/util/jmx/AbstractMXBean.java | 7 +-- .../jmx/ThreadExecutorStatsMXBeanImpl.java | 12 ++-- .../cluster/sharding/CDSShardAccessImpl.java | 29 ++++------ .../dom/api/DOMDataTreeChangeListener.java | 4 +- .../sal/dom/api/DOMDataTreeChangeService.java | 6 +- .../md/sal/dom/api/DOMDataTreeIdentifier.java | 18 +++--- .../md/sal/dom/api/DOMExtensibleService.java | 4 +- .../sal/dom/api/DOMNotificationListener.java | 4 +- .../api/DOMNotificationPublishService.java | 13 ++--- .../sal/dom/api/DOMNotificationService.java | 6 +- .../dom/api/DOMRpcAvailabilityListener.java | 6 +- .../md/sal/dom/api/DOMRpcIdentifier.java | 23 ++++---- .../md/sal/dom/api/DOMRpcImplementation.java | 6 +- ...pcImplementationNotAvailableException.java | 11 ++-- .../md/sal/dom/api/DOMRpcProviderService.java | 10 ++-- .../md/sal/dom/api/DOMRpcService.java | 8 +-- .../broker/impl/AbstractDOMDataBroker.java | 6 +- .../dom/broker/impl/PingPongDataBroker.java | 9 +-- .../broker/impl/PingPongTransactionChain.java | 29 +++++----- .../impl/jmx/CommitStatsMXBeanImpl.java | 7 +-- .../LegacyShardedDOMDataBrokerAdapter.java | 3 - ...aBrokerDelegatingReadWriteTransaction.java | 16 +++--- .../broker/impl/DOMDataTreeListenerTest.java | 3 +- .../impl/DOMNotificationRouterTest.java | 6 +- .../compat/LegacyDOMDataBrokerAdapter.java | 15 +++-- .../md/sal/dom/spi/DefaultDOMRpcResult.java | 15 ++--- .../sal/dom/spi/ForwardingDOMDataBroker.java | 4 +- .../ForwardingDOMDataReadOnlyTransaction.java | 4 +- ...ForwardingDOMDataReadWriteTransaction.java | 4 +- .../ForwardingDOMDataWriteTransaction.java | 4 +- .../spi/ForwardingDOMRpcImplementation.java | 4 +- .../spi/ForwardingDOMRpcProviderService.java | 4 +- .../sal/dom/spi/ForwardingDOMRpcResult.java | 4 +- .../sal/dom/spi/ForwardingDOMRpcService.java | 4 +- .../spi/ForwardingDOMTransactionChain.java | 4 +- .../spi/data/AbstractDOMStoreTransaction.java | 23 ++++---- .../AbstractDOMStoreTreeChangePublisher.java | 10 ++-- .../spi/data/DOMStoreTreeChangePublisher.java | 6 +- .../data/SnapshotBackedWriteTransaction.java | 2 +- .../data/statistics/DOMStoreStatsTracker.java | 8 +-- .../impl/InMemoryDOMDataStoreFactory.java | 14 ++--- .../InMemoryDOMStoreTreeChangePublisher.java | 4 +- .../remote/rpc/RemoteDOMRpcFuture.java | 8 +-- .../controller/remote/rpc/RpcListener.java | 15 ++--- .../remote/rpc/messages/ExecuteRpc.java | 19 +++---- .../remote/rpc/messages/RpcResponse.java | 7 +-- .../remote/rpc/registry/gossip/Bucket.java | 4 +- .../rpc/registry/gossip/BucketImpl.java | 9 +-- .../provider/CarDataTreeChangeListener.java | 4 +- .../it/provider/impl/GetConstantService.java | 8 +-- .../impl/IdIntsDOMDataTreeLIstener.java | 8 +-- .../it/provider/impl/IdIntsListener.java | 4 +- .../it/provider/impl/PrefixShardHandler.java | 6 +- .../impl/RoutedGetConstantService.java | 8 +-- .../impl/SingletonGetConstantService.java | 8 +-- 163 files changed, 834 insertions(+), 964 deletions(-) diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java index b79d3662f9..ebc6975923 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java @@ -16,11 +16,11 @@ import java.util.Enumeration; import java.util.HashSet; import java.util.Hashtable; import java.util.List; -import javax.annotation.Nullable; import org.apache.aries.blueprint.NamespaceHandler; import org.apache.aries.blueprint.services.BlueprintExtenderService; import org.apache.aries.quiesce.participant.QuiesceParticipant; import org.apache.aries.util.AriesFrameworkUtil; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.blueprint.ext.OpendaylightNamespaceHandler; import org.opendaylight.yangtools.util.xml.UntrustedXML; import org.osgi.framework.Bundle; @@ -342,8 +342,7 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus return bundlesToDestroy; } - @Nullable - private Bundle findBundleWithHighestUsedServiceId(final Collection containerBundles) { + private @Nullable Bundle findBundleWithHighestUsedServiceId(final Collection containerBundles) { ServiceReference highestServiceRef = null; for (Bundle bundle : containerBundles) { ServiceReference[] references = bundle.getRegisteredServices(); diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java index 37343b9362..b7953e4d6f 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java @@ -14,13 +14,13 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; -import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import org.apache.aries.blueprint.di.AbstractRecipe; import org.apache.aries.blueprint.di.ExecutionContext; import org.apache.aries.blueprint.di.Recipe; import org.apache.aries.blueprint.ext.DependentComponentFactoryMetadata; import org.apache.aries.blueprint.services.ExtendedBlueprintContainer; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.blueprint.BlueprintContainerRestartService; import org.osgi.framework.ServiceReference; import org.osgi.service.blueprint.container.ComponentDefinitionException; @@ -225,8 +225,7 @@ abstract class AbstractDependentComponentFactoryMetadata implements DependentCom } @SuppressWarnings("unchecked") - @Nullable - protected T getOSGiService(final Class serviceInterface) { + protected @Nullable T getOSGiService(final Class serviceInterface) { try { ServiceReference serviceReference = container().getBundleContext().getServiceReference(serviceInterface); diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigMetadata.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigMetadata.java index b2801d052f..b018fc493a 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigMetadata.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigMetadata.java @@ -17,11 +17,11 @@ import java.util.Collection; import java.util.Objects; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import javax.xml.parsers.ParserConfigurationException; import javax.xml.stream.XMLStreamException; import org.apache.aries.blueprint.services.ExtendedBlueprintContainer; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.blueprint.ext.DataStoreAppConfigDefaultXMLReader.ConfigURLProvider; import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataBroker; @@ -79,9 +79,9 @@ public class DataStoreAppConfigMetadata extends AbstractDependentComponentFactor // project are still used - conversion to the mdsal binding classes hasn't occurred yet. private volatile BindingNormalizedNodeSerializer bindingSerializer; - public DataStoreAppConfigMetadata(@Nonnull final String id, @Nonnull final String appConfigBindingClassName, - @Nullable final String appConfigListKeyValue, @Nullable final String defaultAppConfigFileName, - @Nonnull final UpdateStrategy updateStrategyValue, @Nullable final Element defaultAppConfigElement) { + public DataStoreAppConfigMetadata(final String id, final @NonNull String appConfigBindingClassName, + final @Nullable String appConfigListKeyValue, final @Nullable String defaultAppConfigFileName, + final @NonNull UpdateStrategy updateStrategyValue, final @Nullable Element defaultAppConfigElement) { super(id); this.defaultAppConfigElement = defaultAppConfigElement; this.defaultAppConfigFileName = defaultAppConfigFileName; @@ -279,8 +279,7 @@ public class DataStoreAppConfigMetadata extends AbstractDependentComponentFactor } } - @Nullable - private NormalizedNode parsePossibleDefaultAppConfigElement(final SchemaContext schemaContext, + private @Nullable NormalizedNode parsePossibleDefaultAppConfigElement(final SchemaContext schemaContext, final DataSchemaNode dataSchema) throws URISyntaxException, IOException, ParserConfigurationException, SAXException, XMLStreamException { if (defaultAppConfigElement == null) { diff --git a/opendaylight/config/netty-timer-config/src/main/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerCloseable.java b/opendaylight/config/netty-timer-config/src/main/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerCloseable.java index de187bbe9b..b519af1b99 100644 --- a/opendaylight/config/netty-timer-config/src/main/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerCloseable.java +++ b/opendaylight/config/netty-timer-config/src/main/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerCloseable.java @@ -14,7 +14,7 @@ import io.netty.util.TimerTask; import java.util.Set; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; public final class HashedWheelTimerCloseable implements AutoCloseable, Timer { @@ -39,13 +39,13 @@ public final class HashedWheelTimerCloseable implements AutoCloseable, Timer { return this.timer.stop(); } - public static HashedWheelTimerCloseable newInstance(@Nullable final Long duration, - @Nullable final Integer ticksPerWheel) { + public static HashedWheelTimerCloseable newInstance(final @Nullable Long duration, + final @Nullable Integer ticksPerWheel) { return newInstance(null, duration, ticksPerWheel); } - public static HashedWheelTimerCloseable newInstance(@Nullable final ThreadFactory threadFactory, - @Nullable final Long duration, @Nullable final Integer ticksPerWheel) { + public static HashedWheelTimerCloseable newInstance(final @Nullable ThreadFactory threadFactory, + final @Nullable Long duration, final @Nullable Integer ticksPerWheel) { TimeUnit unit = TimeUnit.MILLISECONDS; if(!nullOrNonPositive(duration) && threadFactory == null && nullOrNonPositive(ticksPerWheel)) { return new HashedWheelTimerCloseable(new HashedWheelTimer(duration, unit)); diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/ABIVersion.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/ABIVersion.java index b476536b74..3eddf3eb56 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/ABIVersion.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/ABIVersion.java @@ -7,13 +7,14 @@ */ package org.opendaylight.controller.cluster.access; +import static com.google.common.base.Preconditions.checkArgument; + import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.WritableObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +51,7 @@ public enum ABIVersion implements WritableObject { private final short value; ABIVersion(final int intVersion) { - Preconditions.checkArgument(intVersion >= 0 && intVersion <= 65535); + checkArgument(intVersion >= 0 && intVersion <= 65535); value = (short) intVersion; } @@ -69,8 +70,7 @@ public enum ABIVersion implements WritableObject { * * @return Current {@link ABIVersion} */ - @Nonnull - public static ABIVersion current() { + public static @NonNull ABIVersion current() { return BORON; } @@ -83,8 +83,7 @@ public enum ABIVersion implements WritableObject { * @throws FutureVersionException if the specified integer identifies a future version * @throws PastVersionException if the specified integer identifies a past version which is no longer supported */ - @Nonnull - public static ABIVersion valueOf(final short value) throws FutureVersionException, PastVersionException { + public static @NonNull ABIVersion valueOf(final short value) throws FutureVersionException, PastVersionException { switch (Short.toUnsignedInt(value)) { case 0: case 1: @@ -112,8 +111,7 @@ public enum ABIVersion implements WritableObject { * @return An {@link ABIVersion} * @throws IOException If read fails or an unsupported version is encountered */ - @Nonnull - public static ABIVersion readFrom(@Nonnull final DataInput in) throws IOException { + public static @NonNull ABIVersion readFrom(final @NonNull DataInput in) throws IOException { final short s = in.readShort(); try { return valueOf(s); @@ -122,7 +120,7 @@ public enum ABIVersion implements WritableObject { } } - public static ABIVersion inexactReadFrom(@Nonnull final DataInput in) throws IOException { + public static @NonNull ABIVersion inexactReadFrom(final @NonNull DataInput in) throws IOException { final short onWire = in.readShort(); try { return ABIVersion.valueOf(onWire); diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/AbstractVersionException.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/AbstractVersionException.java index e416fc63ac..0567ef1191 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/AbstractVersionException.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/AbstractVersionException.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.cluster.access; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * Abstract base exception used for reporting version mismatches from {@link ABIVersion}. @@ -19,12 +20,12 @@ import javax.annotation.Nonnull; @Beta public abstract class AbstractVersionException extends Exception { private static final long serialVersionUID = 1L; - private final ABIVersion closestVersion; + private final @NonNull ABIVersion closestVersion; private final int version; AbstractVersionException(final String message, final short version, final ABIVersion closestVersion) { super(message); - this.closestVersion = Preconditions.checkNotNull(closestVersion); + this.closestVersion = requireNonNull(closestVersion); this.version = Short.toUnsignedInt(version); } @@ -42,8 +43,7 @@ public abstract class AbstractVersionException extends Exception { * * @return Closest supported {@link ABIVersion} */ - @Nonnull - public final ABIVersion getClosestVersion() { + public final @NonNull ABIVersion getClosestVersion() { return closestVersion; } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequest.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequest.java index 19df54628f..3898ee22b3 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequest.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequest.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.access.commands; import akka.actor.ActorRef; import com.google.common.annotations.Beta; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; /** @@ -23,8 +23,8 @@ import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier public final class AbortLocalTransactionRequest extends AbstractLocalTransactionRequest { private static final long serialVersionUID = 1L; - public AbortLocalTransactionRequest(@Nonnull final TransactionIdentifier identifier, - @Nonnull final ActorRef replyTo) { + public AbortLocalTransactionRequest(final @NonNull TransactionIdentifier identifier, + final @NonNull ActorRef replyTo) { super(identifier, 0, replyTo); } } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadPathTransactionRequest.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadPathTransactionRequest.java index fee3b03624..fa53a599aa 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadPathTransactionRequest.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadPathTransactionRequest.java @@ -7,11 +7,12 @@ */ package org.opendaylight.controller.cluster.access.commands; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -32,12 +33,13 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public abstract class AbstractReadPathTransactionRequest> extends AbstractReadTransactionRequest { private static final long serialVersionUID = 1L; - private final YangInstanceIdentifier path; + + private final @NonNull YangInstanceIdentifier path; AbstractReadPathTransactionRequest(final TransactionIdentifier identifier, final long sequence, final ActorRef replyTo, final YangInstanceIdentifier path, final boolean snapshotOnly) { super(identifier, sequence, replyTo, snapshotOnly); - this.path = Preconditions.checkNotNull(path); + this.path = requireNonNull(path); } AbstractReadPathTransactionRequest(final T request, final ABIVersion version) { @@ -45,8 +47,7 @@ public abstract class AbstractReadPathTransactionRequest alternates; + private final @NonNull List alternates; @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "See justification above.") private final DataTree dataTree; - private final ActorRef backend; + private final @NonNull ActorRef backend; private final int maxMessages; ConnectClientSuccess(final ClientIdentifier target, final long sequence, final ActorRef backend, final List alternates, final Optional dataTree, final int maxMessages) { super(target, sequence); - this.backend = Preconditions.checkNotNull(backend); + this.backend = requireNonNull(backend); this.alternates = ImmutableList.copyOf(alternates); this.dataTree = dataTree.orElse(null); - Preconditions.checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages); + checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages); this.maxMessages = maxMessages; } - public ConnectClientSuccess(@Nonnull final ClientIdentifier target, final long sequence, - @Nonnull final ActorRef backend, @Nonnull final List alternates, - @Nonnull final DataTree dataTree, final int maxMessages) { + public ConnectClientSuccess(final @NonNull ClientIdentifier target, final long sequence, + final @NonNull ActorRef backend, final @NonNull List alternates, + final @NonNull DataTree dataTree, final int maxMessages) { this(target, sequence, backend, alternates, Optional.of(dataTree), maxMessages); } @@ -64,13 +66,11 @@ public final class ConnectClientSuccess extends RequestSuccess getAlternates() { + public @NonNull List getAlternates() { return alternates; } - @Nonnull - public ActorRef getBackend() { + public @NonNull ActorRef getBackend() { return backend; } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequest.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequest.java index f5534a8fbc..ab2316c28e 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequest.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequest.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.access.commands; import akka.actor.ActorRef; import com.google.common.annotations.Beta; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -23,8 +23,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public final class ExistsTransactionRequest extends AbstractReadPathTransactionRequest { private static final long serialVersionUID = 1L; - public ExistsTransactionRequest(@Nonnull final TransactionIdentifier identifier, final long sequence, - @Nonnull final ActorRef replyTo, @Nonnull final YangInstanceIdentifier path, final boolean snapshotOnly) { + public ExistsTransactionRequest(final @NonNull TransactionIdentifier identifier, final long sequence, + final @NonNull ActorRef replyTo, final @NonNull YangInstanceIdentifier path, final boolean snapshotOnly) { super(identifier, sequence, replyTo, path, snapshotOnly); } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequest.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequest.java index 4eb5d1adc7..92caa59b7a 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequest.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequest.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.access.commands; import akka.actor.ActorRef; import com.google.common.annotations.Beta; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -23,8 +23,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public final class ReadTransactionRequest extends AbstractReadPathTransactionRequest { private static final long serialVersionUID = 1L; - public ReadTransactionRequest(@Nonnull final TransactionIdentifier identifier, final long sequence, - @Nonnull final ActorRef replyTo, @Nonnull final YangInstanceIdentifier path, final boolean snapshotOnly) { + public ReadTransactionRequest(final @NonNull TransactionIdentifier identifier, final long sequence, + final @NonNull ActorRef replyTo, final @NonNull YangInstanceIdentifier path, final boolean snapshotOnly) { super(identifier, sequence, replyTo, path, snapshotOnly); } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/AbstractMessageProxy.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/AbstractMessageProxy.java index 8a59168136..0367527a5e 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/AbstractMessageProxy.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/AbstractMessageProxy.java @@ -7,13 +7,14 @@ */ package org.opendaylight.controller.cluster.access.concepts; -import com.google.common.base.Verify; +import static com.google.common.base.Verify.verifyNotNull; + import java.io.DataInput; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.WritableIdentifier; import org.opendaylight.yangtools.concepts.WritableObjects; @@ -34,7 +35,7 @@ abstract class AbstractMessageProxy, WritableIde } Proxy(final byte[] serialized) { - this.serialized = Preconditions.checkNotNull(serialized); + this.serialized = requireNonNull(serialized); } @Override @@ -67,7 +68,6 @@ public final class FrontendType implements Comparable, WritableIde } } - @RegEx private static final String SIMPLE_STRING_REGEX = "^[a-zA-Z0-9-_.*+:=,!~';]+$"; private static final Pattern SIMPLE_STRING_PATTERN = Pattern.compile(SIMPLE_STRING_REGEX); private static final long serialVersionUID = 1L; @@ -78,12 +78,12 @@ public final class FrontendType implements Comparable, WritableIde private volatile byte[] serialized; private FrontendType(final String name) { - this.name = Preconditions.checkNotNull(name); + this.name = requireNonNull(name); } FrontendType(final String name, final byte[] serialized) { this(name); - this.serialized = Verify.verifyNotNull(serialized); + this.serialized = verifyNotNull(serialized); } /** @@ -97,8 +97,8 @@ public final class FrontendType implements Comparable, WritableIde * @throws IllegalArgumentException if the string is null, empty or contains invalid characters */ public static FrontendType forName(final String name) { - Preconditions.checkArgument(!Strings.isNullOrEmpty(name)); - Preconditions.checkArgument(SIMPLE_STRING_PATTERN.matcher(name).matches(), + checkArgument(!Strings.isNullOrEmpty(name)); + checkArgument(SIMPLE_STRING_PATTERN.matcher(name).matches(), "Supplied name %s does not patch pattern %s", name, SIMPLE_STRING_REGEX); return new FrontendType(name); } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Message.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Message.java index 8788c0df98..2bc33cd1e4 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Message.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Message.java @@ -7,14 +7,15 @@ */ package org.opendaylight.controller.cluster.access.concepts; +import static com.google.common.base.Verify.verifyNotNull; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; import java.io.Serializable; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.concepts.WritableIdentifier; @@ -56,13 +57,13 @@ public abstract class Message externalizableProxy(@Nonnull ABIVersion reqVersion); + abstract @NonNull AbstractMessageProxy externalizableProxy(@NonNull ABIVersion reqVersion); protected final Object writeReplace() { return externalizableProxy(version); diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Request.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Request.java index 5c8df78741..093a3f1eb0 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Request.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Request.java @@ -7,11 +7,12 @@ */ package org.opendaylight.controller.cluster.access.concepts; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.yangtools.concepts.WritableIdentifier; @@ -27,16 +28,16 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier; @Beta public abstract class Request> extends Message { private static final long serialVersionUID = 1L; - private final ActorRef replyTo; + private final @NonNull ActorRef replyTo; - protected Request(@Nonnull final T target, final long sequence, @Nonnull final ActorRef replyTo) { + protected Request(final @NonNull T target, final long sequence, final @NonNull ActorRef replyTo) { super(target, sequence); - this.replyTo = Preconditions.checkNotNull(replyTo); + this.replyTo = requireNonNull(replyTo); } - protected Request(@Nonnull final C request, @Nonnull final ABIVersion version) { + protected Request(final @NonNull C request, final @NonNull ABIVersion version) { super(request, version); - this.replyTo = Preconditions.checkNotNull(request.getReplyTo()); + this.replyTo = requireNonNull(request.getReplyTo()); } /** @@ -44,8 +45,7 @@ public abstract class Request toRequestFailure(@Nonnull RequestException cause); + public abstract @NonNull RequestFailure toRequestFailure(@NonNull RequestException cause); @Override protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) { @@ -64,5 +63,5 @@ public abstract class Request externalizableProxy(@Nonnull ABIVersion version); + protected abstract AbstractRequestProxy externalizableProxy(ABIVersion version); } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestException.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestException.java index 4f2a0585da..7267edea4f 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestException.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestException.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.cluster.access.concepts; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * A failure cause behind a {@link RequestFailure} to process a {@link Request}. @@ -20,12 +21,12 @@ import javax.annotation.Nonnull; public abstract class RequestException extends Exception { private static final long serialVersionUID = 1L; - protected RequestException(@Nonnull final String message) { - super(Preconditions.checkNotNull(message)); + protected RequestException(final @NonNull String message) { + super(requireNonNull(message)); } - protected RequestException(@Nonnull final String message, @Nonnull final Throwable cause) { - super(Preconditions.checkNotNull(message), Preconditions.checkNotNull(cause)); + protected RequestException(final @NonNull String message, final @NonNull Throwable cause) { + super(requireNonNull(message), requireNonNull(cause)); } public abstract boolean isRetriable(); diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestFailure.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestFailure.java index 13eb4bc618..db5a15b0bc 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestFailure.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestFailure.java @@ -7,10 +7,11 @@ */ package org.opendaylight.controller.cluster.access.concepts; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.yangtools.concepts.WritableIdentifier; @@ -26,16 +27,17 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier; public abstract class RequestFailure> extends Response { private static final long serialVersionUID = 1L; - private final RequestException cause; - protected RequestFailure(@Nonnull final C failure, @Nonnull final ABIVersion version) { + private final @NonNull RequestException cause; + + protected RequestFailure(final @NonNull C failure, final @NonNull ABIVersion version) { super(failure, version); - this.cause = Preconditions.checkNotNull(failure.getCause()); + this.cause = requireNonNull(failure.getCause()); } - protected RequestFailure(@Nonnull final T target, final long sequence, @Nonnull final RequestException cause) { + protected RequestFailure(final @NonNull T target, final long sequence, final @NonNull RequestException cause) { super(target, sequence); - this.cause = Preconditions.checkNotNull(cause); + this.cause = requireNonNull(cause); } /** @@ -43,8 +45,7 @@ public abstract class RequestFailure externalizableProxy(@Nonnull ABIVersion version); + protected abstract AbstractRequestFailureProxy externalizableProxy(ABIVersion version); } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestSuccess.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestSuccess.java index 65d43184cc..9b60d21b0d 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestSuccess.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RequestSuccess.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster.access.concepts; import com.google.common.annotations.Beta; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.yangtools.concepts.WritableIdentifier; @@ -24,14 +24,14 @@ public abstract class RequestSuccess { private static final long serialVersionUID = 1L; - protected RequestSuccess(@Nonnull final C success, @Nonnull final ABIVersion version) { + protected RequestSuccess(final @NonNull C success, final @NonNull ABIVersion version) { super(success, version); } - protected RequestSuccess(@Nonnull final T target, final long sequence) { + protected RequestSuccess(final @NonNull T target, final long sequence) { super(target, sequence); } @Override - protected abstract AbstractSuccessProxy externalizableProxy(@Nonnull ABIVersion version); + protected abstract AbstractSuccessProxy externalizableProxy(ABIVersion version); } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Response.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Response.java index cc6188bd84..f733a9e919 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Response.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Response.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster.access.concepts; import com.google.common.annotations.Beta; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.yangtools.concepts.WritableIdentifier; @@ -26,14 +26,14 @@ import org.opendaylight.yangtools.concepts.WritableIdentifier; public abstract class Response> extends Message { private static final long serialVersionUID = 1L; - Response(@Nonnull final T target, final long sequence) { + Response(final @NonNull T target, final long sequence) { super(target, sequence); } - Response(@Nonnull final C response, @Nonnull final ABIVersion version) { + Response(final @NonNull C response, final @NonNull ABIVersion version) { super(response, version); } @Override - abstract AbstractResponseProxy externalizableProxy(@Nonnull ABIVersion version); + abstract AbstractResponseProxy externalizableProxy(ABIVersion version); } diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/TransactionIdentifier.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/TransactionIdentifier.java index 5f96074fce..8fa0b62702 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/TransactionIdentifier.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/TransactionIdentifier.java @@ -7,15 +7,16 @@ */ package org.opendaylight.controller.cluster.access.concepts; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.io.DataInput; import java.io.DataOutput; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.WritableIdentifier; import org.opendaylight.yangtools.concepts.WritableObjects; @@ -39,7 +40,7 @@ public final class TransactionIdentifier implements WritableIdentifier { } Proxy(final LocalHistoryIdentifier historyId, final long transactionId) { - this.historyId = Preconditions.checkNotNull(historyId); + this.historyId = requireNonNull(historyId); this.transactionId = transactionId; } @@ -65,8 +66,8 @@ public final class TransactionIdentifier implements WritableIdentifier { private final long transactionId; private String shortString; - public TransactionIdentifier(@Nonnull final LocalHistoryIdentifier historyId, final long transactionId) { - this.historyId = Preconditions.checkNotNull(historyId); + public TransactionIdentifier(final @NonNull LocalHistoryIdentifier historyId, final long transactionId) { + this.historyId = requireNonNull(historyId); this.transactionId = transactionId; } diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/FailureEnvelopeTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/FailureEnvelopeTest.java index 2f56dd4aab..733c3c7525 100644 --- a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/FailureEnvelopeTest.java +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/FailureEnvelopeTest.java @@ -7,10 +7,10 @@ */ package org.opendaylight.controller.cluster.access.concepts; +import static org.junit.Assert.assertEquals; + import java.io.DataInput; import java.io.IOException; -import javax.annotation.Nonnull; -import org.junit.Assert; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.yangtools.concepts.WritableIdentifier; @@ -25,11 +25,11 @@ public class FailureEnvelopeTest extends AbstractEnvelopeTest { @Override protected void doAdditionalAssertions(final FailureEnvelope envelope, final FailureEnvelope resolvedObject) { - Assert.assertEquals(envelope.getExecutionTimeNanos(), resolvedObject.getExecutionTimeNanos()); + assertEquals(envelope.getExecutionTimeNanos(), resolvedObject.getExecutionTimeNanos()); final RequestException expectedCause = envelope.getMessage().getCause(); final RequestException actualCause = resolvedObject.getMessage().getCause(); - Assert.assertEquals(expectedCause.getMessage(), actualCause.getMessage()); - Assert.assertEquals(expectedCause.isRetriable(), actualCause.isRetriable()); + assertEquals(expectedCause.getMessage(), actualCause.getMessage()); + assertEquals(expectedCause.isRetriable(), actualCause.isRetriable()); } private static class MockRequestFailureProxy extends AbstractRequestFailureProxy { @@ -43,16 +43,14 @@ public class FailureEnvelopeTest extends AbstractEnvelopeTest { super(mockFailure); } - @Nonnull @Override - protected MockFailure createFailure(@Nonnull final WritableIdentifier target, final long sequence, - @Nonnull final RequestException failureCause) { + protected MockFailure createFailure(final WritableIdentifier target, final long sequence, + final RequestException failureCause) { return new MockFailure(target, failureCause, sequence); } - @Nonnull @Override - protected WritableIdentifier readTarget(@Nonnull final DataInput in) throws IOException { + protected WritableIdentifier readTarget(final DataInput in) throws IOException { return TransactionIdentifier.readFrom(in); } @@ -75,7 +73,5 @@ public class FailureEnvelopeTest extends AbstractEnvelopeTest { protected MockFailure cloneAsVersion(final ABIVersion version) { return this; } - } - } diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorBehavior.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorBehavior.java index f80ae7c6aa..4188a41fd5 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorBehavior.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorBehavior.java @@ -7,11 +7,12 @@ */ 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}. @@ -22,11 +23,11 @@ import javax.annotation.Nullable; */ @Beta public abstract class AbstractClientActorBehavior implements AutoCloseable { - private final C context; + private final @NonNull C context; - AbstractClientActorBehavior(@Nonnull final 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); } /** @@ -34,8 +35,7 @@ public abstract class AbstractClientActorBehavior onReceiveCommand(@Nonnull Object command); + abstract @Nullable AbstractClientActorBehavior onReceiveCommand(@NonNull Object command); /** * Implementation-internal method for handling an incoming recovery message coming from persistence. @@ -79,6 +76,5 @@ public abstract class AbstractClientActorBehavior onReceiveRecover(@Nonnull Object recover); + abstract @Nullable AbstractClientActorBehavior onReceiveRecover(@NonNull Object recover); } diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorContext.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorContext.java index 9f0bcbc25f..a09d06c61f 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorContext.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientActorContext.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.cluster.access.client; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.Mutable; /** @@ -19,22 +20,20 @@ import org.opendaylight.yangtools.concepts.Mutable; * @author Robert Varga */ abstract class AbstractClientActorContext implements Mutable { - private final String persistenceId; - private final ActorRef self; + private final @NonNull String persistenceId; + private final @NonNull ActorRef self; - AbstractClientActorContext(@Nonnull final ActorRef self, @Nonnull final String persistenceId) { - this.persistenceId = Preconditions.checkNotNull(persistenceId); - this.self = Preconditions.checkNotNull(self); + AbstractClientActorContext(final @NonNull ActorRef self, final @NonNull String persistenceId) { + this.persistenceId = requireNonNull(persistenceId); + this.self = requireNonNull(self); } // TODO: rename this to logContext() - @Nonnull - final String persistenceId() { + final @NonNull String persistenceId() { return persistenceId; } - @Nonnull - public final ActorRef self() { + public final @NonNull ActorRef self() { return self; } } diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnection.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnection.java index c32f7b2532..03d4691cb4 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnection.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnection.java @@ -7,11 +7,12 @@ */ package org.opendaylight.controller.cluster.access.client; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; import java.util.Optional; @@ -20,9 +21,9 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; -import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.NotThreadSafe; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.concepts.Request; import org.opendaylight.controller.cluster.access.concepts.RequestException; import org.opendaylight.controller.cluster.access.concepts.Response; @@ -77,7 +78,7 @@ public abstract class AbstractClientConnection { private final ClientActorContext context; @GuardedBy("lock") private final TransmitQueue queue; - private final Long cookie; + private final @NonNull Long cookie; private final String backendName; @GuardedBy("lock") @@ -93,10 +94,10 @@ public abstract class AbstractClientConnection { // Private constructor to avoid code duplication. private AbstractClientConnection(final AbstractClientConnection oldConn, final TransmitQueue newQueue, final String backendName) { - this.context = Preconditions.checkNotNull(oldConn.context); - this.cookie = Preconditions.checkNotNull(oldConn.cookie); - this.backendName = Preconditions.checkNotNull(backendName); - this.queue = Preconditions.checkNotNull(newQueue); + this.context = requireNonNull(oldConn.context); + this.cookie = requireNonNull(oldConn.cookie); + this.backendName = requireNonNull(backendName); + this.queue = requireNonNull(newQueue); // Will be updated in finishReplay if needed. this.lastReceivedTicks = oldConn.lastReceivedTicks; } @@ -105,9 +106,9 @@ public abstract class AbstractClientConnection { // Do not allow subclassing outside of this package AbstractClientConnection(final ClientActorContext context, final Long cookie, final String backendName, final int queueDepth) { - this.context = Preconditions.checkNotNull(context); - this.cookie = Preconditions.checkNotNull(cookie); - this.backendName = Preconditions.checkNotNull(backendName); + this.context = requireNonNull(context); + this.cookie = requireNonNull(cookie); + this.backendName = requireNonNull(backendName); this.queue = new TransmitQueue.Halted(queueDepth); this.lastReceivedTicks = currentTime(); } @@ -123,14 +124,14 @@ public abstract class AbstractClientConnection { AbstractClientConnection(final AbstractClientConnection oldConn, final T newBackend, final int queueDepth) { this(oldConn, new TransmitQueue.Transmitting(oldConn.queue, queueDepth, newBackend, oldConn.currentTime(), - Preconditions.checkNotNull(oldConn.context).messageSlicer()), newBackend.getName()); + requireNonNull(oldConn.context).messageSlicer()), newBackend.getName()); } public final ClientActorContext context() { return context; } - public final @Nonnull Long cookie() { + public final @NonNull Long cookie() { return cookie; } diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfoResolver.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfoResolver.java index fc633adaa6..5c5cda5bae 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfoResolver.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfoResolver.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.cluster.access.client; import akka.actor.ActorRef; import java.util.concurrent.CompletionStage; import java.util.function.Consumer; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.Registration; /** @@ -35,8 +35,7 @@ public abstract class BackendInfoResolver implements Auto * @param cookie Backend cookie * @return A {@link CompletionStage} resulting in information about the backend */ - @Nonnull - public abstract CompletionStage getBackendInfo(@Nonnull Long cookie); + public abstract @NonNull CompletionStage getBackendInfo(@NonNull Long cookie); /** * Request re-resolution of a particular backend identified by a cookie, indicating a particular information as @@ -46,8 +45,8 @@ public abstract class BackendInfoResolver implements Auto * @param staleInfo Stale backend information * @return A {@link CompletionStage} resulting in information about the backend */ - @Nonnull - public abstract CompletionStage refreshBackendInfo(@Nonnull Long cookie, @Nonnull T staleInfo); + public abstract @NonNull CompletionStage refreshBackendInfo(@NonNull Long cookie, + @NonNull T staleInfo); /** * Registers a callback to be notified when BackendInfo that may have been previously obtained is now stale and @@ -56,11 +55,9 @@ public abstract class BackendInfoResolver implements Auto * @param callback the callback that takes the backend cookie whose BackendInfo is now stale. * @return a Registration */ - @Nonnull - public abstract Registration notifyWhenBackendInfoIsStale(Consumer callback); + public abstract @NonNull Registration notifyWhenBackendInfoIsStale(Consumer callback); - @Nonnull - public abstract String resolveCookieName(Long cookie); + public abstract @NonNull String resolveCookieName(Long cookie); @Override public void close() { diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java index 6ede15bf40..53c6bd92b1 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java @@ -7,8 +7,9 @@ */ package org.opendaylight.controller.cluster.access.client; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; import com.google.common.base.Verify; import java.util.Collection; @@ -17,9 +18,9 @@ import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.access.commands.NotLeaderException; import org.opendaylight.controller.cluster.access.commands.OutOfSequenceEnvelopeException; import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; @@ -61,7 +62,7 @@ public abstract class ClientActorBehavior extends * @param enqueuedEntries Previously-enqueued entries * @return A {@link ReconnectForwarder} to handle any straggler messages which arrive after this method returns. */ - @Nonnull ReconnectForwarder finishReconnect(@Nonnull Collection enqueuedEntries); + @NonNull ReconnectForwarder finishReconnect(@NonNull Collection enqueuedEntries); } private static final Logger LOG = LoggerFactory.getLogger(ClientActorBehavior.class); @@ -86,10 +87,10 @@ public abstract class ClientActorBehavior extends private final MessageAssembler responseMessageAssembler; private final Registration staleBackendInfoReg; - protected ClientActorBehavior(@Nonnull final ClientActorContext context, - @Nonnull final BackendInfoResolver resolver) { + protected ClientActorBehavior(final @NonNull ClientActorContext context, + final @NonNull BackendInfoResolver resolver) { super(context); - this.resolver = Preconditions.checkNotNull(resolver); + this.resolver = requireNonNull(resolver); final ClientActorConfig config = context.config(); responseMessageAssembler = MessageAssembler.builder().logContext(persistenceId()) @@ -110,7 +111,6 @@ public abstract class ClientActorBehavior extends } @Override - @Nonnull public final ClientIdentifier getIdentifier() { return context().getIdentifier(); } @@ -275,7 +275,7 @@ public abstract class ClientActorBehavior extends * * @param cause Failure cause */ - protected abstract void haltClient(@Nonnull Throwable cause); + protected abstract void haltClient(@NonNull Throwable cause); /** * Override this method to handle any command which is not handled by the base behavior. @@ -283,15 +283,14 @@ public abstract class ClientActorBehavior extends * @param command the command to process * @return Next behavior to use, null if this actor should shut down. */ - @Nullable - protected abstract ClientActorBehavior onCommand(@Nonnull Object command); + protected abstract @Nullable ClientActorBehavior onCommand(@NonNull Object command); /** * Override this method to provide a backend resolver instance. * * @return a backend resolver instance */ - protected final @Nonnull BackendInfoResolver resolver() { + protected final @NonNull BackendInfoResolver resolver() { return resolver; } @@ -303,7 +302,7 @@ public abstract class ClientActorBehavior extends * @return ConnectionConnectCohort which will be used to complete the process of bringing the connection up. */ @GuardedBy("connectionsLock") - @Nonnull protected abstract ConnectionConnectCohort connectionUp(@Nonnull ConnectedClientConnection newConn); + protected abstract @NonNull ConnectionConnectCohort connectionUp(@NonNull ConnectedClientConnection newConn); private void backendConnectFinished(final Long shard, final AbstractClientConnection oldConn, final T backend, final Throwable failure) { diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorContext.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorContext.java index 7e392af375..f85e8e244c 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorContext.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorContext.java @@ -7,16 +7,17 @@ */ package org.opendaylight.controller.cluster.access.client; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.actor.Cancellable; import akka.actor.Scheduler; import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.base.Ticker; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; import javax.annotation.concurrent.ThreadSafe; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; import org.opendaylight.controller.cluster.common.actor.Dispatchers; import org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory; @@ -49,11 +50,11 @@ public class ClientActorContext extends AbstractClientActorContext implements Id ClientActorContext(final ActorRef self, final String persistenceId, final ActorSystem system, final ClientIdentifier identifier, final ClientActorConfig config) { super(self, persistenceId); - this.identifier = Preconditions.checkNotNull(identifier); - this.scheduler = Preconditions.checkNotNull(system).scheduler(); + this.identifier = requireNonNull(identifier); + this.scheduler = requireNonNull(system).scheduler(); this.executionContext = system.dispatcher(); this.dispatchers = new Dispatchers(system.dispatchers()); - this.config = Preconditions.checkNotNull(config); + this.config = requireNonNull(config); messageSlicer = MessageSlicer.builder().messageSliceSize(config.getMaximumMessageSliceSize()) .logContext(persistenceId).expireStateAfterInactivity(config.getRequestTimeout(), TimeUnit.NANOSECONDS) @@ -62,23 +63,19 @@ public class ClientActorContext extends AbstractClientActorContext implements Id } @Override - @Nonnull public ClientIdentifier getIdentifier() { return identifier; } - @Nonnull - public ClientActorConfig config() { + public @NonNull ClientActorConfig config() { return config; } - @Nonnull - public Dispatchers dispatchers() { + public @NonNull Dispatchers dispatchers() { return dispatchers; } - @Nonnull - public MessageSlicer messageSlicer() { + public @NonNull MessageSlicer messageSlicer() { return messageSlicer; } @@ -89,8 +86,7 @@ public class ClientActorContext extends AbstractClientActorContext implements Id * * @return Client actor time source */ - @Nonnull - public Ticker ticker() { + public @NonNull Ticker ticker() { return Ticker.systemTicker(); } @@ -100,13 +96,13 @@ public class ClientActorContext extends AbstractClientActorContext implements Id * @param command Block of code which needs to be execute * @param BackendInfo type */ - public void executeInActor(@Nonnull final InternalCommand command) { - self().tell(Preconditions.checkNotNull(command), ActorRef.noSender()); + public void executeInActor(final @NonNull InternalCommand command) { + self().tell(requireNonNull(command), ActorRef.noSender()); } - public Cancellable executeInActor(@Nonnull final InternalCommand command, + public Cancellable executeInActor(final @NonNull InternalCommand command, final FiniteDuration delay) { - return scheduler.scheduleOnce(Preconditions.checkNotNull(delay), self(), Preconditions.checkNotNull(command), + return scheduler.scheduleOnce(requireNonNull(delay), self(), requireNonNull(command), executionContext, ActorRef.noSender()); } } diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/InternalCommand.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/InternalCommand.java index c841f1350a..08735529d8 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/InternalCommand.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/InternalCommand.java @@ -8,8 +8,8 @@ package org.opendaylight.controller.cluster.access.client; import akka.dispatch.ControlMessage; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; /** * This interface is used to pass the unit of work via the actors mailbox. The command can alter behavior of the actor @@ -25,5 +25,5 @@ public interface InternalCommand extends ControlMessage { * @param currentBehavior Current Behavior * @return Next behavior to use in the client actor */ - @Nullable ClientActorBehavior execute(@Nonnull ClientActorBehavior currentBehavior); + @Nullable ClientActorBehavior execute(@NonNull ClientActorBehavior currentBehavior); } diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/RequestCallback.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/RequestCallback.java index 90af8cb2e1..e5a949a31d 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/RequestCallback.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/RequestCallback.java @@ -7,8 +7,8 @@ */ package org.opendaylight.controller.cluster.access.client; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.access.concepts.Response; @FunctionalInterface @@ -19,5 +19,5 @@ interface RequestCallback { * @param response Response to the request * @return Next client actor behavior */ - @Nullable ClientActorBehavior complete(@Nonnull Response response); + @Nullable ClientActorBehavior complete(@NonNull Response response); } diff --git a/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSDataTreeProducer.java b/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSDataTreeProducer.java index 0d54235aa3..5aa88a22c0 100644 --- a/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSDataTreeProducer.java +++ b/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSDataTreeProducer.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster.dom.api; import com.google.common.annotations.Beta; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer; @@ -35,6 +35,6 @@ public interface CDSDataTreeProducer extends DOMDataTreeProducer { * are violated, for example if this producer is bound and this thread * is currently not executing from a listener context. */ - @Nonnull CDSShardAccess getShardAccess(@Nonnull DOMDataTreeIdentifier subtree); + @NonNull CDSShardAccess getShardAccess(@NonNull DOMDataTreeIdentifier subtree); } diff --git a/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSShardAccess.java b/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSShardAccess.java index d08b99a50f..2051e21d64 100644 --- a/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSShardAccess.java +++ b/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/CDSShardAccess.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.dom.api; import com.google.common.annotations.Beta; import java.util.concurrent.CompletionStage; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; /** @@ -27,7 +27,7 @@ public interface CDSShardAccess { * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated * {@link CDSDataTreeProducer} is no longer valid. */ - @Nonnull DOMDataTreeIdentifier getShardIdentifier(); + @NonNull DOMDataTreeIdentifier getShardIdentifier(); /** * Return the shard leader location relative to the local node. @@ -36,7 +36,7 @@ public interface CDSShardAccess { * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated * {@link CDSDataTreeProducer} is no longer valid. */ - @Nonnull LeaderLocation getLeaderLocation(); + @NonNull LeaderLocation getLeaderLocation(); /** * Request the shard leader to be moved to the local node. The request will be evaluated against shard state and @@ -56,7 +56,7 @@ public interface CDSShardAccess { * @throws IllegalStateException if the {@link CDSDataTreeProducer} from which the associated * {@link CDSDataTreeProducer} is no longer valid. */ - @Nonnull CompletionStage makeLeaderLocal(); + @NonNull CompletionStage makeLeaderLocal(); /** * Register a listener to shard location changes. Each listener object can be registered at most once. @@ -68,6 +68,6 @@ public interface CDSShardAccess { * {@link CDSDataTreeProducer} is no longer valid. * @throws NullPointerException if listener is null. */ - @Nonnull LeaderLocationListenerRegistration registerLeaderLocationListener( - @Nonnull L listener); + @NonNull LeaderLocationListenerRegistration registerLeaderLocationListener( + @NonNull L listener); } diff --git a/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/LeaderLocationListener.java b/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/LeaderLocationListener.java index 489539a688..4f5fd4e83e 100644 --- a/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/LeaderLocationListener.java +++ b/opendaylight/md-sal/cds-dom-api/src/main/java/org/opendaylight/controller/cluster/dom/api/LeaderLocationListener.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.dom.api; import com.google.common.annotations.Beta; import java.util.EventListener; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * Listener for shard leader location changes. @@ -23,5 +23,5 @@ public interface LeaderLocationListener extends EventListener { * * @param location Current leader location as known by the local node. */ - void onLeaderLocationChanged(@Nonnull LeaderLocation location); + void onLeaderLocationChanged(@NonNull LeaderLocation location); } diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/AbstractCloseTracked.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/AbstractCloseTracked.java index 785e2ef6ae..fa27d98e89 100644 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/AbstractCloseTracked.java +++ b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/AbstractCloseTracked.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.md.sal.trace.closetracker.impl; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; /** * Convenience abstract base class for {@link CloseTracked} implementors. diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTracked.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTracked.java index ef42c4025c..af77e18f5a 100644 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTracked.java +++ b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTracked.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.md.sal.trace.closetracker.impl; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; /** * Object which can track where something has been created, and if it has been correctly "closed". diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java index 30e81c42df..f96daaa425 100644 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java +++ b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.md.sal.trace.closetracker.impl; +import static java.util.Objects.requireNonNull; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Objects; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; /** * Implementation of {@link CloseTracked} which can be used as a field in @@ -31,6 +32,7 @@ public class CloseTrackedTrait> implements CloseTracke private final CloseTrackedRegistry closeTrackedRegistry; private final CloseTracked realCloseTracked; + @SuppressFBWarnings(value = "NP_STORE_INTO_NONNULL_FIELD", justification = "SpotBugs and JDT annotations") public CloseTrackedTrait(CloseTrackedRegistry transactionChainRegistry, CloseTracked realCloseTracked) { if (transactionChainRegistry.isDebugContextEnabled()) { // NB: We're NOT doing the (expensive) getStackTrace() here just yet (only below) @@ -39,13 +41,12 @@ public class CloseTrackedTrait> implements CloseTracke } else { this.allocationContext = null; } - this.realCloseTracked = Objects.requireNonNull(realCloseTracked, "realCloseTracked"); - this.closeTrackedRegistry = Objects.requireNonNull(transactionChainRegistry, "transactionChainRegistry"); + this.realCloseTracked = requireNonNull(realCloseTracked, "realCloseTracked"); + this.closeTrackedRegistry = requireNonNull(transactionChainRegistry, "transactionChainRegistry"); this.closeTrackedRegistry.add(this); } @Override - @Nullable @SuppressFBWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") public StackTraceElement[] getAllocationContextStackTrace() { return allocationContext != null ? allocationContext.getStackTrace() : null; diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/AbstractTracingWriteTransaction.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/AbstractTracingWriteTransaction.java index acd9f9154d..a8f21f9719 100644 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/AbstractTracingWriteTransaction.java +++ b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/AbstractTracingWriteTransaction.java @@ -7,13 +7,13 @@ */ package org.opendaylight.controller.md.sal.trace.dom.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.FluentFuture; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import java.util.Set; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.mdsal.common.api.CommitInfo; @@ -27,8 +27,8 @@ abstract class AbstractTracingWriteTransaction implements DOMDataWriteTransactio private final List logs = new ArrayList<>(); AbstractTracingWriteTransaction(DOMDataWriteTransaction delegate, TracingBroker tracingBroker) { - this.delegate = Objects.requireNonNull(delegate); - this.tracingBroker = Objects.requireNonNull(tracingBroker); + this.delegate = requireNonNull(delegate); + this.tracingBroker = requireNonNull(tracingBroker); recordOp(null, null, "instantiate", null); } @@ -114,7 +114,6 @@ abstract class AbstractTracingWriteTransaction implements DOMDataWriteTransactio } @Override - @Nonnull public Object getIdentifier() { return delegate.getIdentifier(); } diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java index 7103a00768..8291a72c25 100644 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java +++ b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java @@ -16,7 +16,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; @@ -319,7 +318,6 @@ public class TracingBroker implements TracingDOMDataBroker { return new TracingReadOnlyTransaction(delegate.newReadOnlyTransaction(), readOnlyTransactionsRegistry); } - @Nonnull @Override public Map, DOMDataBrokerExtension> getSupportedExtensions() { Map, DOMDataBrokerExtension> res = delegate.getSupportedExtensions(); @@ -331,10 +329,9 @@ public class TracingBroker implements TracingDOMDataBroker { res = new HashMap<>(res); res.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() { - @Nonnull @Override public ListenerRegistration registerDataTreeChangeListener( - @Nonnull DOMDataTreeIdentifier domDataTreeIdentifier, @Nonnull L listener) { + DOMDataTreeIdentifier domDataTreeIdentifier, L listener) { if (isRegistrationWatched(domDataTreeIdentifier.getRootIdentifier(), domDataTreeIdentifier.getDatastoreType())) { LOG.warn("{} registration (registerDataTreeChangeListener) for {} from {}.", diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java index f2ac8d5f44..6c9e17b5bf 100644 --- a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java +++ b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java @@ -7,7 +7,8 @@ */ package org.opendaylight.controller.messagebus.app.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -19,7 +20,6 @@ import java.util.UUID; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.ExecutionException; import java.util.regex.Pattern; -import javax.annotation.Nonnull; import org.opendaylight.mdsal.binding.api.DataObjectModification; import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; @@ -64,8 +64,8 @@ public final class EventSourceTopic implements DataTreeChangeListener, Aut private EventSourceTopic(final NotificationPattern notificationPattern, final String nodeIdRegexPattern, final EventSourceService sourceService) { - this.notificationPattern = Preconditions.checkNotNull(notificationPattern); - this.sourceService = Preconditions.checkNotNull(sourceService); + this.notificationPattern = requireNonNull(notificationPattern); + this.sourceService = requireNonNull(sourceService); this.nodeIdPattern = Pattern.compile(nodeIdRegexPattern); this.topicId = new TopicId(getUUIDIdent()); this.listenerRegistration = null; @@ -122,7 +122,7 @@ public final class EventSourceTopic implements DataTreeChangeListener, Aut Futures.addCallback(future, new FutureCallback>() { @Override - public void onSuccess(@Nonnull final Optional data) { + public void onSuccess(final Optional data) { if (data.isPresent()) { final List nodes = data.get().getNode(); if (nodes != null) { diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java index a1916f1500..a2bcc8a724 100644 --- a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java +++ b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java @@ -18,7 +18,6 @@ import java.io.OutputStream; import java.io.Serializable; import java.util.HashMap; import java.util.Map; -import javax.annotation.Nonnull; import org.apache.commons.lang3.SerializationUtils; import org.opendaylight.controller.cluster.example.messages.KeyValue; import org.opendaylight.controller.cluster.example.messages.KeyValueSaved; @@ -50,10 +49,9 @@ public class ExampleActor extends RaftActor implements RaftActorRecoveryCohort, } private final Map state = new HashMap<>(); - - private long persistIdentifier = 1; private final Optional roleChangeNotifier; + private long persistIdentifier = 1; public ExampleActor(String id, Map peerAddresses, Optional configParams) { @@ -155,16 +153,17 @@ public class ExampleActor extends RaftActor implements RaftActorRecoveryCohort, } } - @Override protected void onStateChanged() { + @Override + protected void onStateChanged() { } - @Override public String persistenceId() { + @Override + public String persistenceId() { return getId(); } @Override - @Nonnull protected RaftActorRecoveryCohort getRaftActorRecoveryCohort() { return this; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ConfigParams.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ConfigParams.java index 8d6b965d9b..fb571f11f8 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ConfigParams.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ConfigParams.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.cluster.raft; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.policy.RaftPolicy; import scala.concurrent.duration.FiniteDuration; @@ -98,16 +98,14 @@ public interface ConfigParams { * * @return an instance of RaftPolicy, if set, or an instance of the DefaultRaftPolicy. */ - @Nonnull - RaftPolicy getRaftPolicy(); + @NonNull RaftPolicy getRaftPolicy(); /** * Returns the PeerAddressResolver. * * @return the PeerAddressResolver instance. */ - @Nonnull - PeerAddressResolver getPeerAddressResolver(); + @NonNull PeerAddressResolver getPeerAddressResolver(); /** * Returns the custom RaftPolicy class name. @@ -121,8 +119,7 @@ public interface ConfigParams { * * @return the directory in which to create temp files. */ - @Nonnull - String getTempFileDirectory(); + @NonNull String getTempFileDirectory(); /** * Returns the threshold in terms of number of bytes when streaming data before it should switch from storing in diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/DefaultConfigParamsImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/DefaultConfigParamsImpl.java index 932069edda..53728043fb 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/DefaultConfigParamsImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/DefaultConfigParamsImpl.java @@ -7,12 +7,14 @@ */ package org.opendaylight.controller.cluster.raft; -import com.google.common.base.Preconditions; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Strings; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.policy.DefaultRaftPolicy; import org.opendaylight.controller.cluster.raft.policy.RaftPolicy; import org.slf4j.Logger; @@ -192,8 +194,8 @@ public class DefaultConfigParamsImpl implements ConfigParams { return peerAddressResolver; } - public void setPeerAddressResolver(@Nonnull final PeerAddressResolver peerAddressResolver) { - this.peerAddressResolver = Preconditions.checkNotNull(peerAddressResolver); + public void setPeerAddressResolver(final @NonNull PeerAddressResolver peerAddressResolver) { + this.peerAddressResolver = requireNonNull(peerAddressResolver); } @Override @@ -202,7 +204,7 @@ public class DefaultConfigParamsImpl implements ConfigParams { } public void setSyncIndexThreshold(final long syncIndexThreshold) { - Preconditions.checkArgument(syncIndexThreshold >= 0); + checkArgument(syncIndexThreshold >= 0); this.syncIndexThreshold = syncIndexThreshold; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java index 264f7a5d63..61aafef513 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java @@ -5,10 +5,9 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; /** * ElectionTerm contains information about a RaftActors election term. @@ -33,8 +32,7 @@ public interface ElectionTerm { * * @return candidate id that received the vote or null if no candidate was voted for. */ - @Nullable - String getVotedFor(); + @Nullable String getVotedFor(); /** * This method updates the in-memory election term state. This method should be called when recovering election diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformation.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformation.java index ca3de5944b..a5f24990f6 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformation.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformation.java @@ -5,15 +5,16 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft; +import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.raft.behaviors.LeaderInstallSnapshotState; /** @@ -65,7 +66,7 @@ public final class FollowerLogInformation { this.nextIndex = context.getCommitIndex(); this.matchIndex = matchIndex; this.context = context; - this.peerInfo = Preconditions.checkNotNull(peerInfo); + this.peerInfo = requireNonNull(peerInfo); } /** @@ -301,8 +302,7 @@ public final class FollowerLogInformation { * * @return the LeaderInstallSnapshotState if a snapshot install is in progress, null otherwise. */ - @Nullable - public LeaderInstallSnapshotState getInstallSnapshotState() { + public @Nullable LeaderInstallSnapshotState getInstallSnapshotState() { return installSnapshotState; } @@ -311,9 +311,9 @@ public final class FollowerLogInformation { * * @param state the LeaderInstallSnapshotState */ - public void setLeaderInstallSnapshotState(@Nonnull final LeaderInstallSnapshotState state) { + public void setLeaderInstallSnapshotState(final @NonNull LeaderInstallSnapshotState state) { if (this.installSnapshotState == null) { - this.installSnapshotState = Preconditions.checkNotNull(state); + this.installSnapshotState = requireNonNull(state); } } @@ -321,7 +321,7 @@ public final class FollowerLogInformation { * Clears the LeaderInstallSnapshotState when an install snapshot is complete. */ public void clearLeaderInstallSnapshotState() { - Preconditions.checkState(installSnapshotState != null); + checkState(installSnapshotState != null); installSnapshotState.close(); installSnapshotState = null; } @@ -349,8 +349,7 @@ public final class FollowerLogInformation { needsLeaderAddress = value; } - @Nullable - public String needsLeaderAddress(String leaderId) { + public @Nullable String needsLeaderAddress(String leaderId) { return needsLeaderAddress ? context.getPeerAddress(leaderId) : null; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/PeerAddressResolver.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/PeerAddressResolver.java index c7d81570c4..ac9be2562d 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/PeerAddressResolver.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/PeerAddressResolver.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.cluster.raft; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; /** * Interface to resolve raft actor peer addresses. @@ -31,5 +31,6 @@ public interface PeerAddressResolver { * @param address the peer's actor's address */ default void setResolved(String peerId, String address) { + } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java index 6cbeda6098..775ab0cdef 100755 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java @@ -6,17 +6,17 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft; +import static com.google.common.base.Verify.verify; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.PoisonPill; import akka.actor.Status; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; import com.google.common.collect.Lists; import java.util.Collection; import java.util.HashMap; @@ -24,9 +24,9 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.apache.commons.lang3.time.DurationFormatUtils; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.DataPersistenceProvider; import org.opendaylight.controller.cluster.DelegatingPersistentDataProvider; import org.opendaylight.controller.cluster.NonPersistentDataProvider; @@ -327,7 +327,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { } private void initiateLeadershipTransfer(final RaftActorLeadershipTransferCohort.OnComplete onComplete, - @Nullable final String followerId, final long newLeaderTimeoutInMillis) { + final @Nullable String followerId, final long newLeaderTimeoutInMillis) { LOG.debug("{}: Initiating leader transfer", persistenceId()); RaftActorLeadershipTransferCohort leadershipTransferInProgress = context.getRaftActorLeadershipTransferCohort(); @@ -814,8 +814,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { /** * Returns the RaftActorRecoveryCohort to participate in persistence recovery. */ - @Nonnull - protected abstract RaftActorRecoveryCohort getRaftActorRecoveryCohort(); + protected abstract @NonNull RaftActorRecoveryCohort getRaftActorRecoveryCohort(); /** * This method is called when recovery is complete. @@ -825,8 +824,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { /** * Returns the RaftActorSnapshotCohort to participate in snapshot captures. */ - @Nonnull - protected abstract RaftActorSnapshotCohort getRaftActorSnapshotCohort(); + protected abstract @NonNull RaftActorSnapshotCohort getRaftActorSnapshotCohort(); /** * This method will be called by the RaftActor when the state of the @@ -948,7 +946,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { @Nullable abstract String getLastLeaderId(); - @Nullable abstract short getLeaderPayloadVersion(); + abstract short getLeaderPayloadVersion(); } /** @@ -964,7 +962,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { final RaftActorBehavior behavior) { this.lastValidLeaderId = lastValidLeaderId; this.lastLeaderId = lastLeaderId; - this.behavior = Preconditions.checkNotNull(behavior); + this.behavior = requireNonNull(behavior); this.leaderPayloadVersion = behavior.getLeaderPayloadVersion(); } @@ -1027,7 +1025,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { BehaviorState capture(final RaftActorBehavior behavior) { if (behavior == null) { - Verify.verify(lastValidLeaderId == null, "Null behavior with non-null last leader"); + verify(lastValidLeaderId == null, "Null behavior with non-null last leader"); return NULL_BEHAVIOR_STATE; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java index aed050c3c0..b5f3afdc16 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft; import akka.actor.ActorRef; @@ -18,8 +17,8 @@ import java.util.Collection; import java.util.Optional; import java.util.function.Consumer; import java.util.function.LongSupplier; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.DataPersistenceProvider; import org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory; import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; @@ -77,8 +76,7 @@ public interface RaftActorContext { * * @return the ElectionTerm. */ - @Nonnull - ElectionTerm getTermInformation(); + @NonNull ElectionTerm getTermInformation(); /** * Returns the index of highest log entry known to be committed. @@ -114,31 +112,28 @@ public interface RaftActorContext { * * @param replicatedLog the ReplicatedLog instance. */ - void setReplicatedLog(@Nonnull ReplicatedLog replicatedLog); + void setReplicatedLog(@NonNull ReplicatedLog replicatedLog); /** * Returns the ReplicatedLog instance. * * @return the ReplicatedLog instance. */ - @Nonnull - ReplicatedLog getReplicatedLog(); + @NonNull ReplicatedLog getReplicatedLog(); /** * Returns the The ActorSystem associated with this context. * * @return the ActorSystem. */ - @Nonnull - ActorSystem getActorSystem(); + @NonNull ActorSystem getActorSystem(); /** * Returns the logger to be used for logging messages. * * @return the logger. */ - @Nonnull - Logger getLogger(); + @NonNull Logger getLogger(); /** * Gets the address of a peer as a String. This is the same format in which a consumer would provide the address. @@ -146,8 +141,7 @@ public interface RaftActorContext { * @param peerId the id of the peer. * @return the address of the peer or null if the address has not yet been resolved. */ - @Nullable - String getPeerAddress(String peerId); + @Nullable String getPeerAddress(String peerId); /** * Updates the peers and information to match the given ServerConfigurationPayload. @@ -161,16 +155,14 @@ public interface RaftActorContext { * * @return list of PeerInfo */ - @Nonnull - Collection getPeers(); + @NonNull Collection getPeers(); /** * Returns the id's for each peer. * * @return the list of peer id's. */ - @Nonnull - Collection getPeerIds(); + @NonNull Collection getPeerIds(); /** * Returns the PeerInfo for the given peer. @@ -178,8 +170,7 @@ public interface RaftActorContext { * @param peerId the id of the peer * @return the PeerInfo or null if not found */ - @Nullable - PeerInfo getPeerInfo(String peerId); + @Nullable PeerInfo getPeerInfo(String peerId); /** * Adds a new peer. @@ -203,8 +194,7 @@ public interface RaftActorContext { * @param peerId the id of the peer. * @return the actorSelection corresponding to the peer or null if the address has not yet been resolved. */ - @Nullable - ActorSelection getPeerActorSelection(String peerId); + @Nullable ActorSelection getPeerActorSelection(String peerId); /** * Sets the address of a peer. @@ -219,24 +209,21 @@ public interface RaftActorContext { * * @return the ConfigParams instance. */ - @Nonnull - ConfigParams getConfigParams(); + @NonNull ConfigParams getConfigParams(); /** * Returns the SnapshotManager instance. * * @return the SnapshotManager instance. */ - @Nonnull - SnapshotManager getSnapshotManager(); + @NonNull SnapshotManager getSnapshotManager(); /** * Returns the DataPersistenceProvider instance. * * @return the DataPersistenceProvider instance. */ - @Nonnull - DataPersistenceProvider getPersistenceProvider(); + @NonNull DataPersistenceProvider getPersistenceProvider(); /** * Determines if there are any peer followers. @@ -273,8 +260,7 @@ public interface RaftActorContext { * * @return the RaftPolicy instance. */ - @Nonnull - RaftPolicy getRaftPolicy(); + @NonNull RaftPolicy getRaftPolicy(); /** * Determines if there have been any dynamic server configuration changes applied. @@ -296,8 +282,7 @@ public interface RaftActorContext { * @return the peer information as a ServerConfigurationPayload or null if no dynamic server configurations have * been applied. */ - @Nullable - ServerConfigurationPayload getPeerServerInfo(boolean includeSelf); + @Nullable ServerConfigurationPayload getPeerServerInfo(boolean includeSelf); /** * Determines if this peer is a voting member of the cluster. @@ -333,16 +318,14 @@ public interface RaftActorContext { * * @return the {@link FileBackedOutputStreamFactory}; */ - @Nonnull - FileBackedOutputStreamFactory getFileBackedOutputStreamFactory(); + @NonNull FileBackedOutputStreamFactory getFileBackedOutputStreamFactory(); /** * Returns the RaftActorLeadershipTransferCohort if leadership transfer is in progress. * * @return the RaftActorLeadershipTransferCohort if leadership transfer is in progress, null otherwise */ - @Nullable - RaftActorLeadershipTransferCohort getRaftActorLeadershipTransferCohort(); + @Nullable RaftActorLeadershipTransferCohort getRaftActorLeadershipTransferCohort(); /** * Sets the RaftActorLeadershipTransferCohort for transferring leadership. diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java index 9c8fbe496c..634bbd4343 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorContext; import akka.actor.ActorRef; import akka.actor.ActorSelection; @@ -15,7 +16,6 @@ import akka.actor.ActorSystem; import akka.actor.Props; import akka.cluster.Cluster; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -26,8 +26,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Consumer; import java.util.function.LongSupplier; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.DataPersistenceProvider; import org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory; import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; @@ -94,25 +93,25 @@ public class RaftActorContextImpl implements RaftActorContext { private RaftActorLeadershipTransferCohort leadershipTransferCohort; public RaftActorContextImpl(final ActorRef actor, final ActorContext context, final String id, - @Nonnull final ElectionTerm termInformation, final long commitIndex, final long lastApplied, - @Nonnull final Map peerAddresses, - @Nonnull final ConfigParams configParams, @Nonnull final DataPersistenceProvider persistenceProvider, - @Nonnull final Consumer applyStateConsumer, @Nonnull final Logger logger) { + final @NonNull ElectionTerm termInformation, final long commitIndex, final long lastApplied, + final @NonNull Map peerAddresses, + final @NonNull ConfigParams configParams, final @NonNull DataPersistenceProvider persistenceProvider, + final @NonNull Consumer applyStateConsumer, final @NonNull Logger logger) { this.actor = actor; this.context = context; this.id = id; - this.termInformation = Preconditions.checkNotNull(termInformation); + this.termInformation = requireNonNull(termInformation); this.commitIndex = commitIndex; this.lastApplied = lastApplied; - this.configParams = Preconditions.checkNotNull(configParams); - this.persistenceProvider = Preconditions.checkNotNull(persistenceProvider); - this.log = Preconditions.checkNotNull(logger); - this.applyStateConsumer = Preconditions.checkNotNull(applyStateConsumer); + this.configParams = requireNonNull(configParams); + this.persistenceProvider = requireNonNull(persistenceProvider); + this.log = requireNonNull(logger); + this.applyStateConsumer = requireNonNull(applyStateConsumer); fileBackedOutputStreamFactory = new FileBackedOutputStreamFactory( configParams.getFileBackedStreamingThreshold(), configParams.getTempFileDirectory()); - for (Map.Entry e: Preconditions.checkNotNull(peerAddresses).entrySet()) { + for (Map.Entry e : requireNonNull(peerAddresses).entrySet()) { peerInfoMap.put(e.getKey(), new PeerInfo(e.getKey(), e.getValue(), VotingState.VOTING)); } } @@ -404,7 +403,7 @@ public class RaftActorContextImpl implements RaftActorContext { } void setCurrentBehavior(final RaftActorBehavior behavior) { - this.currentBehavior = Preconditions.checkNotNull(behavior); + this.currentBehavior = requireNonNull(behavior); } @Override @@ -429,15 +428,13 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override - @Nullable public RaftActorLeadershipTransferCohort getRaftActorLeadershipTransferCohort() { return leadershipTransferCohort; } @Override @SuppressWarnings("checkstyle:hiddenField") - public void setRaftActorLeadershipTransferCohort( - @Nullable final RaftActorLeadershipTransferCohort leadershipTransferCohort) { + public void setRaftActorLeadershipTransferCohort(final RaftActorLeadershipTransferCohort leadershipTransferCohort) { this.leadershipTransferCohort = leadershipTransferCohort; } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java index 5b27d50130..a572f308e5 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java @@ -16,7 +16,7 @@ import com.google.common.base.Stopwatch; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.raft.base.messages.LeaderTransitioning; import org.opendaylight.controller.cluster.raft.behaviors.Leader; import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior; @@ -69,7 +69,7 @@ public class RaftActorLeadershipTransferCohort { this(raftActor, null); } - RaftActorLeadershipTransferCohort(final RaftActor raftActor, @Nullable final String requestedFollowerId) { + RaftActorLeadershipTransferCohort(final RaftActor raftActor, final @Nullable String requestedFollowerId) { this.raftActor = raftActor; this.requestedFollowerId = requestedFollowerId; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoveryCohort.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoveryCohort.java index e107be96c4..1f9b93acd7 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoveryCohort.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoveryCohort.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.cluster.raft; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; @@ -52,6 +52,5 @@ public interface RaftActorRecoveryCohort { * * @return the snapshot or null if there's no snapshot to restore */ - @Nullable - Snapshot getRestoreFromSnapshot(); + @Nullable Snapshot getRestoreFromSnapshot(); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupport.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupport.java index 3a3511668c..29641cb00e 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupport.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupport.java @@ -7,10 +7,11 @@ */ package org.opendaylight.controller.cluster.raft; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.Cancellable; -import com.google.common.base.Preconditions; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; @@ -19,7 +20,7 @@ import java.util.List; import java.util.Map; import java.util.Queue; import java.util.UUID; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; import org.opendaylight.controller.cluster.raft.base.messages.SnapshotComplete; import org.opendaylight.controller.cluster.raft.base.messages.TimeoutNow; @@ -247,7 +248,7 @@ class RaftActorServerConfigurationSupport { } protected void operationComplete(final ServerOperationContext operationContext, - @Nullable final ServerChangeStatus replyStatus) { + final @Nullable ServerChangeStatus replyStatus) { if (replyStatus != null) { sendReply(operationContext, replyStatus); } @@ -453,7 +454,7 @@ class RaftActorServerConfigurationSupport { InstallingSnapshot(final AddServerContext addServerContext, final Cancellable installSnapshotTimer) { super(addServerContext); - this.installSnapshotTimer = Preconditions.checkNotNull(installSnapshotTimer); + this.installSnapshotTimer = requireNonNull(installSnapshotTimer); } @Override @@ -497,7 +498,7 @@ class RaftActorServerConfigurationSupport { WaitingForPriorSnapshotComplete(final AddServerContext addServerContext, final Cancellable snapshotTimer) { super(addServerContext); - this.snapshotTimer = Preconditions.checkNotNull(snapshotTimer); + this.snapshotTimer = requireNonNull(snapshotTimer); } @Override @@ -609,7 +610,7 @@ class RaftActorServerConfigurationSupport { private final RemoveServerContext removeServerContext; protected RemoveServerState(final RemoveServerContext removeServerContext) { - this.removeServerContext = Preconditions.checkNotNull(removeServerContext); + this.removeServerContext = requireNonNull(removeServerContext); } @@ -880,7 +881,7 @@ class RaftActorServerConfigurationSupport { private final String loggingContext; ServerOperationTimeout(final String loggingContext) { - this.loggingContext = Preconditions.checkNotNull(loggingContext, "loggingContext should not be null"); + this.loggingContext = requireNonNull(loggingContext, "loggingContext should not be null"); } String getLoggingContext() { diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorSnapshotCohort.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorSnapshotCohort.java index a02b295dbc..8887a650c0 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorSnapshotCohort.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorSnapshotCohort.java @@ -12,8 +12,8 @@ import com.google.common.io.ByteSource; import java.io.IOException; import java.io.OutputStream; import java.util.Optional; -import javax.annotation.Nonnull; -import org.opendaylight.controller.cluster.raft.persisted.Snapshot; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.controller.cluster.raft.persisted.Snapshot.State; /** * Interface for a class that participates in raft actor snapshotting. @@ -35,14 +35,14 @@ public interface RaftActorSnapshotCohort { * serialized data back to a State instance on the follower end. The serialization for snapshot install is * passed off so the cost of serialization is not charged to the raft actor's thread. */ - void createSnapshot(@Nonnull ActorRef actorRef, @Nonnull Optional installSnapshotStream); + void createSnapshot(@NonNull ActorRef actorRef, @NonNull Optional installSnapshotStream); /** * This method is called to apply a snapshot installed by the leader. * * @param snapshotState a snapshot of the state of the actor */ - void applySnapshot(@Nonnull Snapshot.State snapshotState); + void applySnapshot(@NonNull State snapshotState); /** * This method is called to de-serialize snapshot data that was previously serialized via {@link #createSnapshot} @@ -52,6 +52,5 @@ public interface RaftActorSnapshotCohort { * @return the converted snapshot State * @throws IOException if an error occurs accessing the ByteSource or de-serializing */ - @Nonnull - Snapshot.State deserializeSnapshot(@Nonnull ByteSource snapshotBytes) throws IOException; + @NonNull State deserializeSnapshot(@NonNull ByteSource snapshotBytes) throws IOException; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java index 71576f6d21..095e85cbe5 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java @@ -5,13 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft; import akka.japi.Procedure; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; /** * Represents the ReplicatedLog that needs to be kept in sync by the RaftActor. @@ -26,16 +25,14 @@ public interface ReplicatedLog { * @return the ReplicatedLogEntry if found, otherwise null if the adjusted index less than 0 or * greater than the size of the in-memory journal */ - @Nullable - ReplicatedLogEntry get(long index); + @Nullable ReplicatedLogEntry get(long index); /** * Return the last replicated log entry in the log or null of not found. * * @return the last replicated log entry in the log or null of not found. */ - @Nullable - ReplicatedLogEntry last(); + @Nullable ReplicatedLogEntry last(); /** * Return the index of the last entry in the log or -1 if the log is empty. @@ -97,7 +94,7 @@ public interface ReplicatedLog { * delivered after persistence is complete and the associated callback is executed. * @return true if the entry was successfully appended, false otherwise. */ - boolean appendAndPersist(@Nonnull ReplicatedLogEntry replicatedLogEntry, + boolean appendAndPersist(@NonNull ReplicatedLogEntry replicatedLogEntry, @Nullable Procedure callback, boolean doAsync); /** @@ -106,7 +103,7 @@ public interface ReplicatedLog { * @param index the index of the first log entry to get. * @return the List of entries */ - @Nonnull List getFrom(long index); + @NonNull List getFrom(long index); /** * Returns a list of log entries starting from the given index up to the given maximum of entries or @@ -117,7 +114,7 @@ public interface ReplicatedLog { * @param maxDataSize the maximum accumulated size of the log entries to get * @return the List of entries meeting the criteria. */ - @Nonnull List getFrom(long index, int maxEntries, long maxDataSize); + @NonNull List getFrom(long index, int maxEntries, long maxDataSize); /** * Returns the number of entries in the journal. diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImpl.java index 764bce1ddb..45b0b3898e 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImpl.java @@ -7,12 +7,11 @@ */ package org.opendaylight.controller.cluster.raft; +import static java.util.Objects.requireNonNull; + import akka.japi.Procedure; -import com.google.common.base.Preconditions; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.opendaylight.controller.cluster.raft.persisted.DeleteEntries; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; @@ -29,7 +28,7 @@ final class ReplicatedLogImpl extends AbstractReplicatedLogImpl { final List unAppliedEntries, final RaftActorContext context) { super(snapshotIndex, snapshotTerm, unAppliedEntries, context.getId()); - this.context = Preconditions.checkNotNull(context); + this.context = requireNonNull(context); } static ReplicatedLog newInstance(final Snapshot snapshot, final RaftActorContext context) { @@ -93,8 +92,8 @@ final class ReplicatedLogImpl extends AbstractReplicatedLogImpl { } @Override - public boolean appendAndPersist(@Nonnull final ReplicatedLogEntry replicatedLogEntry, - @Nullable final Procedure callback, final boolean doAsync) { + public boolean appendAndPersist(final ReplicatedLogEntry replicatedLogEntry, + final Procedure callback, final boolean doAsync) { context.getLogger().debug("{}: Append log entry and persist {} ", context.getId(), replicatedLogEntry); diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java index dd9445e749..8674ef4f2b 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft; import akka.persistence.SnapshotSelectionCriteria; @@ -16,7 +15,7 @@ import java.io.OutputStream; import java.util.List; import java.util.Optional; import java.util.function.Consumer; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.io.FileBackedOutputStream; import org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot; import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot; @@ -127,8 +126,7 @@ public class SnapshotManager implements SnapshotState { this.snapshotCohort = snapshotCohort; } - @Nonnull - public Snapshot.State convertSnapshot(final ByteSource snapshotBytes) throws IOException { + public Snapshot.@NonNull State convertSnapshot(final ByteSource snapshotBytes) throws IOException { return snapshotCohort.deserializeSnapshot(snapshotBytes); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplySnapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplySnapshot.java index 7fec7e25f9..c9660d9a4a 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplySnapshot.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/ApplySnapshot.java @@ -5,12 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.base.messages; +import static java.util.Objects.requireNonNull; + import akka.dispatch.ControlMessage; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; /** @@ -32,22 +32,20 @@ public class ApplySnapshot implements ControlMessage { private final Snapshot snapshot; private final Callback callback; - public ApplySnapshot(Snapshot snapshot) { + public ApplySnapshot(@NonNull Snapshot snapshot) { this(snapshot, NOOP_CALLBACK); } - public ApplySnapshot(@Nonnull Snapshot snapshot, @Nonnull Callback callback) { - this.snapshot = Preconditions.checkNotNull(snapshot); - this.callback = Preconditions.checkNotNull(callback); + public ApplySnapshot(@NonNull Snapshot snapshot, @NonNull Callback callback) { + this.snapshot = requireNonNull(snapshot); + this.callback = requireNonNull(callback); } - @Nonnull - public Snapshot getSnapshot() { + public @NonNull Snapshot getSnapshot() { return snapshot; } - @Nonnull - public Callback getCallback() { + public @NonNull Callback getCallback() { return callback; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/CaptureSnapshotReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/CaptureSnapshotReply.java index f0e16a092a..552c7df22d 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/CaptureSnapshotReply.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/CaptureSnapshotReply.java @@ -7,30 +7,29 @@ */ package org.opendaylight.controller.cluster.raft.base.messages; +import static java.util.Objects.requireNonNull; + import akka.dispatch.ControlMessage; -import com.google.common.base.Preconditions; import java.io.OutputStream; import java.util.Optional; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; public class CaptureSnapshotReply implements ControlMessage { private final Snapshot.State snapshotState; private final Optional installSnapshotStream; - public CaptureSnapshotReply(@Nonnull final Snapshot.State snapshotState, - @Nonnull final Optional installSnapshotStream) { - this.snapshotState = Preconditions.checkNotNull(snapshotState); - this.installSnapshotStream = Preconditions.checkNotNull(installSnapshotStream); + public CaptureSnapshotReply(final Snapshot.@NonNull State snapshotState, + final @NonNull Optional installSnapshotStream) { + this.snapshotState = requireNonNull(snapshotState); + this.installSnapshotStream = requireNonNull(installSnapshotStream); } - @Nonnull - public Snapshot.State getSnapshotState() { + public Snapshot.@NonNull State getSnapshotState() { return snapshotState; } - @Nonnull - public Optional getInstallSnapshotStream() { + public @NonNull Optional getInstallSnapshotStream() { return installSnapshotStream; } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/FollowerInitialSyncUpStatus.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/FollowerInitialSyncUpStatus.java index 00ef63cf36..e4571c64a8 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/FollowerInitialSyncUpStatus.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/FollowerInitialSyncUpStatus.java @@ -5,11 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.base.messages; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import static java.util.Objects.requireNonNull; + +import org.eclipse.jdt.annotation.NonNull; /** * The FollowerInitialSyncUpStatus is sent by a Follower to inform any RaftActor subclass whether the Follower @@ -21,16 +21,16 @@ public final class FollowerInitialSyncUpStatus { private final boolean initialSyncDone; private final String name; - public FollowerInitialSyncUpStatus(final boolean initialSyncDone, @Nonnull final String name) { + public FollowerInitialSyncUpStatus(final boolean initialSyncDone, final @NonNull String name) { this.initialSyncDone = initialSyncDone; - this.name = Preconditions.checkNotNull(name); + this.name = requireNonNull(name); } public boolean isInitialSyncDone() { return initialSyncDone; } - @Nonnull public String getName() { + public @NonNull String getName() { return name; } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/LeaderTransitioning.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/LeaderTransitioning.java index fd2fb68677..c18b9d4b05 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/LeaderTransitioning.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/LeaderTransitioning.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.cluster.raft.base.messages; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.io.Serializable; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * Message sent from a leader to its followers to indicate leadership transfer is starting. @@ -21,12 +22,11 @@ public final class LeaderTransitioning implements Serializable { private final String leaderId; - public LeaderTransitioning(@Nonnull final String leaderId) { - this.leaderId = Preconditions.checkNotNull(leaderId); + public LeaderTransitioning(final @NonNull String leaderId) { + this.leaderId = requireNonNull(leaderId); } - @Nonnull - public String getLeaderId() { + public @NonNull String getLeaderId() { return leaderId; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendInstallSnapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendInstallSnapshot.java index e8d58f253a..cdb94d44ee 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendInstallSnapshot.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SendInstallSnapshot.java @@ -5,12 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.base.messages; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.io.ByteSource; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; /** @@ -18,20 +18,19 @@ import org.opendaylight.controller.cluster.raft.persisted.Snapshot; * prompt the leader to install the snapshot on its followers as needed. */ public final class SendInstallSnapshot { - private final Snapshot snapshot; - private final ByteSource snapshotBytes; + private final @NonNull Snapshot snapshot; + private final @NonNull ByteSource snapshotBytes; - public SendInstallSnapshot(@Nonnull Snapshot snapshot, @Nonnull ByteSource snapshotBytes) { - this.snapshot = Preconditions.checkNotNull(snapshot); - this.snapshotBytes = Preconditions.checkNotNull(snapshotBytes); + public SendInstallSnapshot(@NonNull Snapshot snapshot, @NonNull ByteSource snapshotBytes) { + this.snapshot = requireNonNull(snapshot); + this.snapshotBytes = requireNonNull(snapshotBytes); } - @Nonnull - public Snapshot getSnapshot() { + public @NonNull Snapshot getSnapshot() { return snapshot; } - public ByteSource getSnapshotBytes() { + public @NonNull ByteSource getSnapshotBytes() { return snapshotBytes; } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java index fbdfd49a3f..fef6cc8b7c 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java @@ -5,16 +5,17 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.behaviors; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.Cancellable; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; -import com.google.common.base.Preconditions; import com.google.common.io.ByteSource; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Collection; @@ -27,7 +28,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Queue; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.io.SharedFileBackedOutputStream; import org.opendaylight.controller.cluster.messaging.MessageSlicer; import org.opendaylight.controller.cluster.messaging.SliceOptions; @@ -101,7 +102,7 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { private int minReplicationCount; protected AbstractLeader(final RaftActorContext context, final RaftState state, - @Nullable final AbstractLeader initializeFromLeader) { + final @Nullable AbstractLeader initializeFromLeader) { super(context, state); appendEntriesMessageSlicer = MessageSlicer.builder().logContext(logName()) @@ -184,7 +185,7 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { } @VisibleForTesting - void setSnapshotHolder(@Nullable final SnapshotHolder snapshotHolder) { + void setSnapshotHolder(final @Nullable SnapshotHolder snapshotHolder) { this.snapshotHolder = Optional.fromNullable(snapshotHolder); } @@ -455,7 +456,7 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { @Override public RaftActorBehavior handleMessage(final ActorRef sender, final Object message) { - Preconditions.checkNotNull(sender, "sender should not be null"); + requireNonNull(sender, "sender should not be null"); if (appendEntriesMessageSlicer.handleMessage(message)) { return this; @@ -511,6 +512,8 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { return this; } + @SuppressFBWarnings(value = "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS", + justification = "JDT nullness with SpotBugs at setSnapshotHolder(null)") private void handleInstallSnapshotReply(final InstallSnapshotReply reply) { log.debug("{}: handleInstallSnapshotReply: {}", logName(), reply); diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Follower.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Follower.java index f6276a65e0..4fa4dbfb57 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Follower.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Follower.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.behaviors; import akka.actor.ActorRef; @@ -25,7 +24,7 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.messaging.MessageAssembler; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; @@ -94,7 +93,7 @@ public class Follower extends AbstractRaftActorBehavior { } @VisibleForTesting - protected final void setLeaderId(@Nullable final String leaderId) { + protected final void setLeaderId(final @Nullable String leaderId) { this.leaderId = leaderId; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeader.java index 9ba39c2fcc..17e4220885 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeader.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster.raft.behaviors; import akka.actor.ActorRef; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java index eb49abc17a..21f823d089 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java @@ -7,15 +7,16 @@ */ package org.opendaylight.controller.cluster.raft.behaviors; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.actor.ActorSelection; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; -import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.raft.FollowerLogInformation; import org.opendaylight.controller.cluster.raft.RaftActorContext; import org.opendaylight.controller.cluster.raft.RaftActorLeadershipTransferCohort; @@ -54,7 +55,7 @@ public class Leader extends AbstractLeader { static final Object ISOLATED_LEADER_CHECK = new Object(); private final Stopwatch isolatedLeaderCheck = Stopwatch.createStarted(); - @Nullable private LeadershipTransferContext leadershipTransferContext; + private @Nullable LeadershipTransferContext leadershipTransferContext; Leader(RaftActorContext context, @Nullable AbstractLeader initializeFromLeader) { super(context, RaftState.Leader, initializeFromLeader); @@ -66,7 +67,7 @@ public class Leader extends AbstractLeader { @Override public RaftActorBehavior handleMessage(ActorRef sender, Object originalMessage) { - Preconditions.checkNotNull(sender, "sender should not be null"); + requireNonNull(sender, "sender should not be null"); if (ISOLATED_LEADER_CHECK.equals(originalMessage)) { if (isLeaderIsolated()) { @@ -121,7 +122,7 @@ public class Leader extends AbstractLeader { * * @param leadershipTransferCohort the cohort participating in the leadership transfer */ - public void transferLeadership(@Nonnull RaftActorLeadershipTransferCohort leadershipTransferCohort) { + public void transferLeadership(@NonNull RaftActorLeadershipTransferCohort leadershipTransferCohort) { log.debug("{}: Attempting to transfer leadership", logName()); leadershipTransferContext = new LeadershipTransferContext(leadershipTransferCohort); diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/RaftActorBehavior.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/RaftActorBehavior.java index 6b51c34e88..ed02706f3e 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/RaftActorBehavior.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/RaftActorBehavior.java @@ -5,11 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.behaviors; import akka.actor.ActorRef; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.raft.RaftState; /** @@ -28,8 +27,7 @@ public interface RaftActorBehavior extends AutoCloseable { * * @return The new behavior or current behavior, or null if the message was not handled. */ - @Nullable - RaftActorBehavior handleMessage(ActorRef sender, Object message); + @Nullable RaftActorBehavior handleMessage(ActorRef sender, Object message); /** * Returns the state associated with this behavior. @@ -43,8 +41,7 @@ public interface RaftActorBehavior extends AutoCloseable { * * @return the id of the leader or null if not known */ - @Nullable - String getLeaderId(); + @Nullable String getLeaderId(); /** * Sets the index of the last log entry that has been replicated to all peers. diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeaderReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeaderReply.java index 90cec9db6c..b4b34437e8 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeaderReply.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/FindLeaderReply.java @@ -5,13 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.client.messages; import com.google.common.annotations.VisibleForTesting; import java.io.Serializable; import java.util.Optional; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; /** * Reply to {@link FindLeader} message, containing the address of the leader actor, as known to the raft actor which @@ -26,7 +25,7 @@ public final class FindLeaderReply implements Serializable { private static final long serialVersionUID = 1L; private final String leaderActor; - public FindLeaderReply(@Nullable final String leaderActor) { + public FindLeaderReply(final @Nullable String leaderActor) { this.leaderActor = leaderActor; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/GetSnapshotReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/GetSnapshotReply.java index b0c36ace2b..36c534654c 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/GetSnapshotReply.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/GetSnapshotReply.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.cluster.raft.client.messages; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; /** @@ -21,21 +22,19 @@ public class GetSnapshotReply { private final String id; private final Snapshot snapshot; - public GetSnapshotReply(@Nonnull String id, @Nonnull Snapshot snapshot) { - this.id = Preconditions.checkNotNull(id); - this.snapshot = Preconditions.checkNotNull(snapshot); + public GetSnapshotReply(@NonNull String id, @NonNull Snapshot snapshot) { + this.id = requireNonNull(id); + this.snapshot = requireNonNull(snapshot); } - @Nonnull - public String getId() { + public @NonNull String getId() { return id; } @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but " + "this is OK since this class is merely a DTO and does not process the byte[] internally. " + "Also it would be inefficient to create a return copy as the byte[] could be large.") - @Nonnull - public Snapshot getSnapshot() { + public @NonNull Snapshot getSnapshot() { return snapshot; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/OnDemandRaftState.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/OnDemandRaftState.java index d9298f9568..7ded55b3ce 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/OnDemandRaftState.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/OnDemandRaftState.java @@ -11,7 +11,7 @@ import com.google.common.collect.ImmutableMap; import java.util.Collections; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * The response to a GetOnDemandRaftState message. @@ -139,8 +139,7 @@ public class OnDemandRaftState { return (B) this; } - @Nonnull - protected abstract OnDemandRaftState state(); + protected abstract @NonNull OnDemandRaftState state(); public B lastLogIndex(long value) { state().lastLogIndex = value; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractServerChangeReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractServerChangeReply.java index 3f0cf43ac9..d37b52cc69 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractServerChangeReply.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractServerChangeReply.java @@ -7,13 +7,14 @@ */ package org.opendaylight.controller.cluster.raft.messages; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; import java.io.Serializable; import java.util.Optional; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; /** * Abstract base class for a server configuration change reply. @@ -26,17 +27,17 @@ public abstract class AbstractServerChangeReply implements Serializable { private final String leaderHint; private final ServerChangeStatus status; - AbstractServerChangeReply(final @Nonnull ServerChangeStatus status, final @Nullable String leaderHint) { - this.status = Preconditions.checkNotNull(status); + AbstractServerChangeReply(final @NonNull ServerChangeStatus status, final @Nullable String leaderHint) { + this.status = requireNonNull(status); this.leaderHint = leaderHint; } @VisibleForTesting - @Nonnull public final Optional getLeaderHint() { + public final @NonNull Optional getLeaderHint() { return Optional.ofNullable(leaderHint); } - @Nonnull public final ServerChangeStatus getStatus() { + public final @NonNull ServerChangeStatus getStatus() { return status; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntries.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntries.java index d77a084148..67c6899231 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntries.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AppendEntries.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.messages; import static java.util.Objects.requireNonNull; @@ -18,8 +17,8 @@ import java.io.ObjectOutput; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.raft.RaftVersions; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry; @@ -58,8 +57,8 @@ public class AppendEntries extends AbstractRaftRPC { private final String leaderAddress; - private AppendEntries(long term, @Nonnull String leaderId, long prevLogIndex, long prevLogTerm, - @Nonnull List entries, long leaderCommit, long replicatedToAllIndex, + private AppendEntries(long term, @NonNull String leaderId, long prevLogIndex, long prevLogTerm, + @NonNull List entries, long leaderCommit, long replicatedToAllIndex, short payloadVersion, short recipientRaftVersion, short leaderRaftVersion, @Nullable String leaderAddress) { super(term); this.leaderId = requireNonNull(leaderId); @@ -74,23 +73,22 @@ public class AppendEntries extends AbstractRaftRPC { this.leaderAddress = leaderAddress; } - public AppendEntries(long term, @Nonnull String leaderId, long prevLogIndex, long prevLogTerm, - @Nonnull List entries, long leaderCommit, long replicatedToAllIndex, + public AppendEntries(long term, @NonNull String leaderId, long prevLogIndex, long prevLogTerm, + @NonNull List entries, long leaderCommit, long replicatedToAllIndex, short payloadVersion, short recipientRaftVersion, @Nullable String leaderAddress) { this(term, leaderId, prevLogIndex, prevLogTerm, entries, leaderCommit, replicatedToAllIndex, payloadVersion, recipientRaftVersion, RaftVersions.CURRENT_VERSION, leaderAddress); } @VisibleForTesting - public AppendEntries(long term, @Nonnull String leaderId, long prevLogIndex, long prevLogTerm, - @Nonnull List entries, long leaderCommit, long replicatedToAllIndex, + public AppendEntries(long term, @NonNull String leaderId, long prevLogIndex, long prevLogTerm, + @NonNull List entries, long leaderCommit, long replicatedToAllIndex, short payloadVersion) { this(term, leaderId, prevLogIndex, prevLogTerm, entries, leaderCommit, replicatedToAllIndex, payloadVersion, RaftVersions.CURRENT_VERSION, null); } - @Nonnull - public String getLeaderId() { + public @NonNull String getLeaderId() { return leaderId; } @@ -102,8 +100,7 @@ public class AppendEntries extends AbstractRaftRPC { return prevLogTerm; } - @Nonnull - public List getEntries() { + public @NonNull List getEntries() { return entries; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ChangeServersVotingStatus.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ChangeServersVotingStatus.java index 3dc36934f4..625d970ddf 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ChangeServersVotingStatus.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ChangeServersVotingStatus.java @@ -7,14 +7,14 @@ */ package org.opendaylight.controller.cluster.raft.messages; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.ImmutableSet; import java.io.Serializable; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.Map; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * Message sent to change the raft voting status for servers. @@ -27,23 +27,21 @@ public class ChangeServersVotingStatus implements Serializable { private final Map serverVotingStatusMap; private final Collection serversVisited; - public ChangeServersVotingStatus(@Nonnull Map serverVotingStatusMap) { - this(serverVotingStatusMap, Collections.emptySet()); + public ChangeServersVotingStatus(@NonNull Map serverVotingStatusMap) { + this(serverVotingStatusMap, ImmutableSet.of()); } - public ChangeServersVotingStatus(@Nonnull Map serverVotingStatusMap, - @Nonnull Collection serversVisited) { - this.serverVotingStatusMap = new HashMap<>(Preconditions.checkNotNull(serverVotingStatusMap)); - this.serversVisited = ImmutableSet.copyOf(Preconditions.checkNotNull(serversVisited)); + public ChangeServersVotingStatus(@NonNull Map serverVotingStatusMap, + @NonNull Collection serversVisited) { + this.serverVotingStatusMap = new HashMap<>(requireNonNull(serverVotingStatusMap)); + this.serversVisited = ImmutableSet.copyOf(requireNonNull(serversVisited)); } - @Nonnull - public Map getServerVotingStatusMap() { + public @NonNull Map getServerVotingStatusMap() { return serverVotingStatusMap; } - @Nonnull - public Collection getServersVisited() { + public @NonNull Collection getServersVisited() { return serversVisited; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RemoveServerReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RemoveServerReply.java index fe643d8af8..8a592292e2 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RemoveServerReply.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RemoveServerReply.java @@ -5,10 +5,9 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft.messages; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; /** * Reply to a RemoveServer message (§4.1). diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/MigratedSerializable.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/MigratedSerializable.java index ee4ac9d883..080759f218 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/MigratedSerializable.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/MigratedSerializable.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster.raft.persisted; import java.io.Serializable; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * Transitional marker interface for use with evolution of serializable classes held in persistence. This interface @@ -30,5 +30,5 @@ public interface MigratedSerializable extends Serializable { * * @return Serialization proxy. */ - @Nonnull Object writeReplace(); + @NonNull Object writeReplace(); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/ServerConfigurationPayload.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/ServerConfigurationPayload.java index e9fc53afbe..055984229b 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/ServerConfigurationPayload.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/ServerConfigurationPayload.java @@ -18,7 +18,7 @@ import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; import org.opendaylight.controller.cluster.raft.protobuff.client.messages.PersistentPayload; import org.slf4j.Logger; @@ -80,12 +80,11 @@ public final class ServerConfigurationPayload extends Payload implements Persist private final List serverConfig; private int serializedSize = -1; - public ServerConfigurationPayload(@Nonnull final List serverConfig) { + public ServerConfigurationPayload(final @NonNull List serverConfig) { this.serverConfig = ImmutableList.copyOf(serverConfig); } - @Nonnull - public List getServerConfig() { + public @NonNull List getServerConfig() { return serverConfig; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/ServerInfo.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/ServerInfo.java index c419f7e0f2..6e1ca82f77 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/ServerInfo.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/ServerInfo.java @@ -7,8 +7,9 @@ */ package org.opendaylight.controller.cluster.raft.persisted; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import static java.util.Objects.requireNonNull; + +import org.eclipse.jdt.annotation.NonNull; /** * Server information. This class is not directly Serializable, as it is serialized directly as part of @@ -20,13 +21,12 @@ public final class ServerInfo { private final String id; private final boolean isVoting; - public ServerInfo(@Nonnull String id, boolean isVoting) { - this.id = Preconditions.checkNotNull(id); + public ServerInfo(@NonNull String id, boolean isVoting) { + this.id = requireNonNull(id); this.isVoting = isVoting; } - @Nonnull - public String getId() { + public @NonNull String getId() { return id; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java index 28cc9b3f81..9c58e6b7ca 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; import org.apache.commons.lang3.SerializationUtils; import org.opendaylight.controller.cluster.DataPersistenceProvider; import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior; @@ -134,7 +133,6 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort, } @Override - @Nonnull protected RaftActorRecoveryCohort getRaftActorRecoveryCohort() { return this; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicationAndSnapshotsWithLaggingFollowerIntegrationTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicationAndSnapshotsWithLaggingFollowerIntegrationTest.java index 7b240d7254..fa974b0ca4 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicationAndSnapshotsWithLaggingFollowerIntegrationTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicationAndSnapshotsWithLaggingFollowerIntegrationTest.java @@ -20,8 +20,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; import org.apache.commons.lang3.SerializationUtils; +import org.eclipse.jdt.annotation.Nullable; import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload; diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ByteState.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ByteState.java index b32b4f4728..039c15c8f4 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ByteState.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ByteState.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.cluster.raft.persisted; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.util.Arrays; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * Snapshot State implementation backed by a byte[]. @@ -19,21 +20,21 @@ import javax.annotation.Nonnull; public final class ByteState implements Snapshot.State { private static final long serialVersionUID = 1L; - private final byte[] bytes; + private final byte @NonNull[] bytes; - private ByteState(@Nonnull final byte[] bytes) { - this.bytes = Preconditions.checkNotNull(bytes); + private ByteState(final byte @NonNull[] bytes) { + this.bytes = requireNonNull(bytes); } - public static ByteState of(@Nonnull final byte[] bytes) { + public static @NonNull ByteState of(final byte @NonNull[] bytes) { return new ByteState(bytes); } - public static ByteState empty() { + public static @NonNull ByteState empty() { return new ByteState(new byte[0]); } - public byte[] getBytes() { + public byte @NonNull[] getBytes() { return bytes; } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataObjectModification.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataObjectModification.java index c43d42c779..5448f79811 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataObjectModification.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataObjectModification.java @@ -5,13 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.binding.api; import com.google.common.collect.Collections2; import java.util.Collection; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.ChoiceIn; @@ -56,14 +55,14 @@ public interface DataObjectModification * * @return type of modified object. */ - @Nonnull Class getDataType(); + @NonNull Class getDataType(); /** * Returns type of modification. * * @return type Type of performed modification. */ - @Nonnull ModificationType getModificationType(); + @NonNull ModificationType getModificationType(); /** * Returns before-state of top level container. Implementations are encouraged, @@ -86,7 +85,7 @@ public interface DataObjectModification * * @return unmodifiable collection of modified direct children. */ - @Nonnull Collection> getModifiedChildren(); + @NonNull Collection> getModifiedChildren(); /** * Returns child list item modification if {@code child} was modified by this modification. This method should be @@ -99,8 +98,8 @@ public interface DataObjectModification * to generated model. */ default & DataObject, C extends ChildOf> - Collection> getModifiedChildren(@Nonnull final Class caseType, - @Nonnull final Class childType) { + Collection> getModifiedChildren(final @NonNull Class caseType, + final @NonNull Class childType) { final Item item = Item.of(caseType, childType); return (Collection>) Collections2.filter(getModifiedChildren(), mod -> item.equals(mod.getIdentifier())); @@ -120,8 +119,8 @@ public interface DataObjectModification * to generated model. */ default @Nullable & DataObject, C extends ChildOf> - DataObjectModification getModifiedChildContainer(@Nonnull final Class caseType, - @Nonnull final Class child) { + DataObjectModification getModifiedChildContainer(final @NonNull Class caseType, + final @NonNull Class child) { return (DataObjectModification) getModifiedChild(Item.of(caseType, child)); } @@ -137,7 +136,7 @@ public interface DataObjectModification * to generated model. */ @Nullable > DataObjectModification getModifiedChildContainer( - @Nonnull Class child); + @NonNull Class child); /** * Returns augmentation child modification if {@code augmentation} was modified by this modification. @@ -151,7 +150,7 @@ public interface DataObjectModification * according to generated model. */ @Nullable & DataObject> DataObjectModification getModifiedAugmentation( - @Nonnull Class augmentation); + @NonNull Class augmentation); /** * Returns child list item modification if {@code child} was modified by this modification. @@ -163,7 +162,7 @@ public interface DataObjectModification * to generated model. */ & ChildOf, K extends Identifier> DataObjectModification - getModifiedChildListItem(@Nonnull Class listItem, @Nonnull K listKey); + getModifiedChildListItem(@NonNull Class listItem, @NonNull K listKey); /** * Returns child list item modification if {@code child} was modified by this modification. @@ -177,7 +176,7 @@ public interface DataObjectModification */ default & DataObject, C extends Identifiable & ChildOf, K extends Identifier> DataObjectModification getModifiedChildListItem( - @Nonnull final Class caseType, @Nonnull final Class listItem, @Nonnull final K listKey) { + final @NonNull Class caseType, final @NonNull Class listItem, final @NonNull K listKey) { return (DataObjectModification) getModifiedChild(IdentifiableItem.of(caseType, listItem, listKey)); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeListener.java index 6d6bae100d..222242e37c 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeListener.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeListener.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.binding.api; import java.util.Collection; import java.util.EventListener; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.binding.DataObject; /** @@ -44,5 +44,5 @@ public interface DataTreeChangeListener extends EventListe * * @param changes Collection of change events, may not be null or empty. */ - void onDataTreeChanged(@Nonnull Collection> changes); + void onDataTreeChanged(@NonNull Collection> changes); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeService.java index 11697bfc85..db44e5059c 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeChangeService.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.md.sal.binding.api; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; @@ -54,6 +54,6 @@ public interface DataTreeChangeService extends BindingService { * your listener using {@link ListenerRegistration#close()} to stop * delivery of change events. */ - @Nonnull > ListenerRegistration - registerDataTreeChangeListener(@Nonnull DataTreeIdentifier treeId, @Nonnull L listener); + > @NonNull ListenerRegistration + registerDataTreeChangeListener(@NonNull DataTreeIdentifier treeId, @NonNull L listener); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeIdentifier.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeIdentifier.java index 79b2a6d526..94e1f8bfcb 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeIdentifier.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeIdentifier.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.md.sal.binding.api; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.io.Serializable; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.concepts.Path; @@ -23,12 +24,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public final class DataTreeIdentifier implements Immutable, Path>, Serializable { private static final long serialVersionUID = 1L; - private final InstanceIdentifier rootIdentifier; - private final LogicalDatastoreType datastoreType; + + private final @NonNull InstanceIdentifier rootIdentifier; + private final @NonNull LogicalDatastoreType datastoreType; public DataTreeIdentifier(final LogicalDatastoreType datastoreType, final InstanceIdentifier rootIdentifier) { - this.datastoreType = Preconditions.checkNotNull(datastoreType); - this.rootIdentifier = Preconditions.checkNotNull(rootIdentifier); + this.datastoreType = requireNonNull(datastoreType); + this.rootIdentifier = requireNonNull(rootIdentifier); } /** @@ -36,7 +38,7 @@ public final class DataTreeIdentifier implements Immutable * * @return Logical data store type. Guaranteed to be non-null. */ - public @Nonnull LogicalDatastoreType getDatastoreType() { + public @NonNull LogicalDatastoreType getDatastoreType() { return datastoreType; } @@ -45,7 +47,7 @@ public final class DataTreeIdentifier implements Immutable * * @return Instance identifier corresponding to the root node. */ - public @Nonnull InstanceIdentifier getRootIdentifier() { + public @NonNull InstanceIdentifier getRootIdentifier() { return rootIdentifier; } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeModification.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeModification.java index 374c185a1e..bd35c63a5a 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeModification.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataTreeModification.java @@ -5,10 +5,9 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.binding.api; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.binding.DataObject; /** @@ -25,13 +24,12 @@ public interface DataTreeModification { * * @return absolute path of the root node */ - @Nonnull DataTreeIdentifier getRootPath(); + @NonNull DataTreeIdentifier getRootPath(); /** * Get the modification root node. * * @return modification root node */ - @Nonnull DataObjectModification getRootNode(); - + @NonNull DataObjectModification getRootNode(); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingDataBroker.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingDataBroker.java index 992654e827..40b8b8cac6 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingDataBroker.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ForwardingDataBroker.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.binding.api; import com.google.common.collect.ForwardingObject; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; @@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject; public abstract class ForwardingDataBroker extends ForwardingObject implements DataBroker { @Override - protected abstract @Nonnull DataBroker delegate(); + protected abstract @NonNull DataBroker delegate(); @Override public ReadOnlyTransaction newReadOnlyTransaction() { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/FunctionalNotificationListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/FunctionalNotificationListenerAdapter.java index 5189e8fb46..712d02517a 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/FunctionalNotificationListenerAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/FunctionalNotificationListenerAdapter.java @@ -7,7 +7,6 @@ */ package org.opendaylight.controller.md.sal.binding.compat; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.binding.impl.LazySerializedDOMNotification; import org.opendaylight.controller.md.sal.dom.api.DOMNotification; import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; @@ -29,7 +28,7 @@ final class FunctionalNotificationListenerAdapter implem } @Override - public void onNotification(@Nonnull final DOMNotification notification) { + public void onNotification(final DOMNotification notification) { delegate.onNotification(type.cast(deserialize(notification))); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java index 9e5b8ccf3d..f749cb2fca 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationListenerAdapter.java @@ -14,7 +14,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.dom.api.DOMNotification; import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; import org.opendaylight.mdsal.binding.dom.adapter.invoke.NotificationListenerInvoker; @@ -39,7 +38,7 @@ class BindingDOMNotificationListenerAdapter implements DOMNotificationListener { } @Override - public void onNotification(@Nonnull final DOMNotification notification) { + public void onNotification(final DOMNotification notification) { final Notification baNotification = deserialize(notification); final QName notificationQName = notification.getType().getLastComponent(); getInvoker(notification.getType()).invokeNotification(delegate, notificationQName, baNotification); diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java index d70d2d6d24..72ee08f38a 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java @@ -7,7 +7,8 @@ */ package org.opendaylight.controller.md.sal.binding.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.util.concurrent.CheckedFuture; @@ -17,7 +18,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ExecutionException; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; @@ -59,14 +59,13 @@ public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation throw new IllegalArgumentException("Failed to create invokers for type " + type, e); } - this.codec = Preconditions.checkNotNull(codec); - this.delegate = Preconditions.checkNotNull(delegate); + this.codec = requireNonNull(codec); + this.delegate = requireNonNull(delegate); inputQname = QName.create(BindingReflections.getQNameModule(type), "input").intern(); } - @Nonnull @Override - public CheckedFuture invokeRpc(@Nonnull final DOMRpcIdentifier rpc, + public CheckedFuture invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode input) { final SchemaPath schemaPath = rpc.getType(); final DataObject bindingInput = input != null ? deserialize(rpc.getType(), input) : null; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java index aa39016fde..d8ba10c8b6 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java @@ -12,7 +12,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; @@ -92,7 +91,6 @@ public class BindingToNormalizedNodeCodec } @Override - @Nonnull public Map.Entry, BindingCodecTreeNode> getSubtreeCodec( final YangInstanceIdentifier domIdentifier) { return super.getSubtreeCodec(domIdentifier); diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java index 9fa43abecf..043501c768 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java @@ -5,15 +5,14 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.binding.impl; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import java.lang.reflect.Method; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext; @@ -57,8 +56,7 @@ abstract class ContextReferenceExtractor { */ abstract @Nullable InstanceIdentifier extract(DataObject obj); - @Nonnull - private static ContextReferenceExtractor create(final Class key) { + private static @NonNull ContextReferenceExtractor create(final Class key) { final Method contextGetter = getContextGetter(key); if (contextGetter == null) { return NULL_EXTRACTOR; @@ -80,8 +78,7 @@ abstract class ContextReferenceExtractor { return NULL_EXTRACTOR; } - @Nullable - private static Method findGetValueMethod(final Class type, final Class returnType) { + private static @Nullable Method findGetValueMethod(final Class type, final Class returnType) { try { final Method method = type.getMethod(GET_VALUE_NAME); if (returnType.equals(method.getReturnType())) { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java index ea3888e14d..d95674699f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java @@ -9,8 +9,8 @@ package org.opendaylight.controller.md.sal.binding.spi; import com.google.common.base.Optional; import com.google.common.cache.CacheLoader; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; public abstract class AdapterLoader extends CacheLoader, Optional> { @@ -29,9 +29,7 @@ public abstract class AdapterLoader extends CacheLoader return Optional.of(builder.build()); } - @Nullable - protected abstract D getDelegate(Class reqDeleg); + protected abstract @Nullable D getDelegate(Class reqDeleg); - @Nonnull - protected abstract AdapterBuilder createBuilder(Class key); + protected abstract @NonNull AdapterBuilder createBuilder(Class key); } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/ActorSystemProvider.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/ActorSystemProvider.java index dcb3b6b714..32e0210378 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/ActorSystemProvider.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/ActorSystemProvider.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.cluster; import akka.actor.ActorSystem; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.ListenerRegistration; /** @@ -23,8 +23,7 @@ public interface ActorSystemProvider { * * @return the ActorSystem. */ - @Nonnull - ActorSystem getActorSystem(); + @NonNull ActorSystem getActorSystem(); /** * Register a listener for ActorSystem lifecycle events. @@ -33,5 +32,5 @@ public interface ActorSystemProvider { * @return a ListenerRegistration instance to be used to unregister */ ListenerRegistration registerActorSystemProviderListener( - @Nonnull ActorSystemProviderListener listener); + @NonNull ActorSystemProviderListener listener); } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputOutput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputOutput.java index 486891dfd5..5ad195a9b7 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputOutput.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputOutput.java @@ -11,7 +11,7 @@ import com.google.common.annotations.Beta; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; @Beta public final class NormalizedNodeInputOutput { @@ -27,7 +27,7 @@ public final class NormalizedNodeInputOutput { * @return a new {@link NormalizedNodeDataInput} instance * @throws IOException if an error occurs reading from the input */ - public static NormalizedNodeDataInput newDataInput(@Nonnull final DataInput input) throws IOException { + public static NormalizedNodeDataInput newDataInput(final @NonNull DataInput input) throws IOException { final byte marker = input.readByte(); if (marker != TokenTypes.SIGNATURE_MARKER) { throw new InvalidNormalizedNodeStreamException(String.format("Invalid signature marker: %d", marker)); @@ -49,7 +49,7 @@ public final class NormalizedNodeInputOutput { * @param input the DataInput to read from * @return a new {@link NormalizedNodeDataInput} instance */ - public static NormalizedNodeDataInput newDataInputWithoutValidation(@Nonnull final DataInput input) { + public static NormalizedNodeDataInput newDataInputWithoutValidation(final @NonNull DataInput input) { return new NormalizedNodeInputStreamReader(input, false); } @@ -59,7 +59,7 @@ public final class NormalizedNodeInputOutput { * @param output the DataOutput to write to * @return a new {@link NormalizedNodeDataOutput} instance */ - public static NormalizedNodeDataOutput newDataOutput(@Nonnull final DataOutput output) { + public static NormalizedNodeDataOutput newDataOutput(final @NonNull DataOutput output) { return new NormalizedNodeOutputStreamWriter(output); } } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/AbstractDataTreeModificationCursor.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/AbstractDataTreeModificationCursor.java index 8c81d60819..ff20c0f631 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/AbstractDataTreeModificationCursor.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/util/AbstractDataTreeModificationCursor.java @@ -7,11 +7,12 @@ */ package org.opendaylight.controller.cluster.datastore.util; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Verify.verifyNotNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; import java.util.Optional; -import javax.annotation.Nonnull; import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; @@ -34,19 +35,19 @@ public abstract class AbstractDataTreeModificationCursor implements DataTreeModi } @Override - public final void enter(@Nonnull final PathArgument child) { + public final void enter(final PathArgument child) { current = current.node(child); } @Override - public final void enter(@Nonnull final PathArgument... path) { + public final void enter(final PathArgument... path) { for (PathArgument arg : path) { enter(arg); } } @Override - public final void enter(@Nonnull final Iterable path) { + public final void enter(final Iterable path) { for (PathArgument arg : path) { enter(arg); } @@ -54,25 +55,25 @@ public abstract class AbstractDataTreeModificationCursor implements DataTreeModi @Override public final void exit() { - Preconditions.checkState(!current.isEmpty()); - current = Verify.verifyNotNull(current.getParent()); + checkState(!current.isEmpty()); + current = verifyNotNull(current.getParent()); } @Override public final void exit(final int depth) { - Preconditions.checkArgument(depth >= 0); + checkArgument(depth >= 0); YangInstanceIdentifier next = current; for (int i = 0; i < depth; ++i) { next = next.getParent(); - Preconditions.checkState(next != null); + checkState(next != null); } current = next; } @Override - public final Optional> readNode(@Nonnull final PathArgument child) { + public final Optional> readNode(final PathArgument child) { throw new UnsupportedOperationException("Not implemented"); } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java index 38249dabd4..353a25156c 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java @@ -22,10 +22,10 @@ import java.io.OutputStream; import java.nio.file.Files; import java.util.Iterator; import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,8 +89,7 @@ public class FileBackedOutputStream extends OutputStream { * @return a ByteSource instance * @throws IOException if close fails */ - @Nonnull - public synchronized ByteSource asByteSource() throws IOException { + public synchronized @NonNull ByteSource asByteSource() throws IOException { close(); if (source == null) { diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStreamFactory.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStreamFactory.java index 75948830be..f2d6647043 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStreamFactory.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStreamFactory.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.cluster.io; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; /** * A factory for creating {@link FileBackedOutputStream} instances. diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageAssembler.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageAssembler.java index 4b7f854608..297186d9f7 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageAssembler.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageAssembler.java @@ -7,9 +7,11 @@ */ package org.opendaylight.controller.cluster.messaging; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalNotification; @@ -19,7 +21,7 @@ import java.io.ObjectInputStream; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory; import org.opendaylight.yangtools.concepts.Identifier; import org.slf4j.Logger; @@ -40,9 +42,9 @@ public final class MessageAssembler implements AutoCloseable { private final String logContext; MessageAssembler(final Builder builder) { - this.fileBackedStreamFactory = Preconditions.checkNotNull(builder.fileBackedStreamFactory, + this.fileBackedStreamFactory = requireNonNull(builder.fileBackedStreamFactory, "FiledBackedStreamFactory cannot be null"); - this.assembledMessageCallback = Preconditions.checkNotNull(builder.assembledMessageCallback, + this.assembledMessageCallback = requireNonNull(builder.assembledMessageCallback, "assembledMessageCallback cannot be null"); this.logContext = builder.logContext; @@ -94,7 +96,7 @@ public final class MessageAssembler implements AutoCloseable { * @param sendTo the reference of the actor to which subsequent message slices should be sent * @return true if the message was handled, false otherwise */ - public boolean handleMessage(final Object message, final @Nonnull ActorRef sendTo) { + public boolean handleMessage(final Object message, final @NonNull ActorRef sendTo) { if (message instanceof MessageSlice) { LOG.debug("{}: handleMessage: {}", logContext, message); onMessageSlice((MessageSlice) message, sendTo); @@ -229,7 +231,7 @@ public final class MessageAssembler implements AutoCloseable { * @return this Builder */ public Builder fileBackedStreamFactory(final FileBackedOutputStreamFactory newFileBackedStreamFactory) { - this.fileBackedStreamFactory = Preconditions.checkNotNull(newFileBackedStreamFactory); + this.fileBackedStreamFactory = requireNonNull(newFileBackedStreamFactory); return this; } @@ -255,7 +257,7 @@ public final class MessageAssembler implements AutoCloseable { * @return this Builder */ public Builder expireStateAfterInactivity(final long duration, final TimeUnit unit) { - Preconditions.checkArgument(duration > 0, "duration must be > 0"); + checkArgument(duration > 0, "duration must be > 0"); this.expireStateAfterInactivityDuration = duration; this.expireStateAfterInactivityUnit = unit; return this; diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSlicer.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSlicer.java index ca2441e438..57a6f9ed4f 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSlicer.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSlicer.java @@ -7,9 +7,11 @@ */ package org.opendaylight.controller.cluster.messaging; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalNotification; @@ -20,7 +22,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Predicate; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.io.FileBackedOutputStream; import org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory; import org.opendaylight.yangtools.concepts.Identifier; @@ -101,7 +103,7 @@ public class MessageSlicer implements AutoCloseable { if (message != null) { LOG.debug("{}: slice: identifier: {}, message: {}", logContext, identifier, message); - Preconditions.checkNotNull(fileBackedStreamFactory, + requireNonNull(fileBackedStreamFactory, "The FiledBackedStreamFactory must be set in order to call this slice method"); // Serialize the message to a FileBackedOutputStream. @@ -204,7 +206,7 @@ public class MessageSlicer implements AutoCloseable { * * @param filter filters by Identifier */ - public void cancelSlicing(@Nonnull final Predicate filter) { + public void cancelSlicing(final @NonNull Predicate filter) { stateCache.asMap().keySet().removeIf( messageSliceIdentifier -> filter.test(messageSliceIdentifier.getClientIdentifier())); } @@ -334,7 +336,7 @@ public class MessageSlicer implements AutoCloseable { * @return this Builder */ public Builder fileBackedStreamFactory(final FileBackedOutputStreamFactory newFileBackedStreamFactory) { - this.fileBackedStreamFactory = Preconditions.checkNotNull(newFileBackedStreamFactory); + this.fileBackedStreamFactory = requireNonNull(newFileBackedStreamFactory); return this; } @@ -345,7 +347,7 @@ public class MessageSlicer implements AutoCloseable { * @return this Builder */ public Builder messageSliceSize(final int newMessageSliceSize) { - Preconditions.checkArgument(newMessageSliceSize > 0, "messageSliceSize must be > 0"); + checkArgument(newMessageSliceSize > 0, "messageSliceSize must be > 0"); this.messageSliceSize = newMessageSliceSize; return this; } @@ -358,7 +360,7 @@ public class MessageSlicer implements AutoCloseable { * @return this Builder */ public Builder maxSlicingTries(final int newMaxSlicingTries) { - Preconditions.checkArgument(newMaxSlicingTries > 0, "newMaxSlicingTries must be > 0"); + checkArgument(newMaxSlicingTries > 0, "newMaxSlicingTries must be > 0"); this.maxSlicingTries = newMaxSlicingTries; return this; } @@ -373,7 +375,7 @@ public class MessageSlicer implements AutoCloseable { * @return this Builder */ public Builder expireStateAfterInactivity(final long duration, final TimeUnit unit) { - Preconditions.checkArgument(duration > 0, "duration must be > 0"); + checkArgument(duration > 0, "duration must be > 0"); this.expireStateAfterInactivityDuration = duration; this.expireStateAfterInactivityUnit = unit; return this; @@ -386,7 +388,7 @@ public class MessageSlicer implements AutoCloseable { * @return this Builder */ public Builder logContext(final String newLogContext) { - this.logContext = Preconditions.checkNotNull(newLogContext); + this.logContext = requireNonNull(newLogContext); return this; } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/LeaderStateChanged.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/LeaderStateChanged.java index 5de794d902..caa1a8debf 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/LeaderStateChanged.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/LeaderStateChanged.java @@ -7,10 +7,10 @@ */ package org.opendaylight.controller.cluster.notifications; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import static java.util.Objects.requireNonNull; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; /** * A local message initiated internally from the RaftActor when some state of a leader has changed. @@ -22,13 +22,13 @@ public class LeaderStateChanged { private final String leaderId; private final short leaderPayloadVersion; - public LeaderStateChanged(@Nonnull String memberId, @Nullable String leaderId, short leaderPayloadVersion) { - this.memberId = Preconditions.checkNotNull(memberId); + public LeaderStateChanged(@NonNull String memberId, @Nullable String leaderId, short leaderPayloadVersion) { + this.memberId = requireNonNull(memberId); this.leaderId = leaderId; this.leaderPayloadVersion = leaderPayloadVersion; } - public @Nonnull String getMemberId() { + public @NonNull String getMemberId() { return memberId; } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java index 1ceba1cd13..76babc15db 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStore.java @@ -44,7 +44,7 @@ import java.util.concurrent.Callable; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.ExecutionContext; @@ -271,12 +271,11 @@ public class LocalSnapshotStore extends SnapshotStore { .filter(criteria::matches).collect(Collectors.toList()); } - private static Stream toStream(@Nullable final SnapshotMetadata md) { + private static Stream toStream(final @Nullable SnapshotMetadata md) { return md != null ? Stream.of(md) : Stream.empty(); } - @Nullable - private static SnapshotMetadata extractMetadata(final File file) { + private static @Nullable SnapshotMetadata extractMetadata(final File file) { String name = file.getName(); int sequenceNumberEndIndex = name.lastIndexOf('-'); int persistenceIdEndIndex = name.lastIndexOf('-', sequenceNumberEndIndex - 1); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/RemoteYangTextSourceProvider.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/RemoteYangTextSourceProvider.java index 3401fdfd9a..03b44b5851 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/RemoteYangTextSourceProvider.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/RemoteYangTextSourceProvider.java @@ -5,12 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.schema.provider; import com.google.common.annotations.Beta; import java.util.Set; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.schema.provider.impl.YangTextSchemaSourceSerializationProxy; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import scala.concurrent.Future; @@ -23,5 +22,5 @@ public interface RemoteYangTextSourceProvider { Future> getProvidedSources(); - Future getYangTextSchemaSource(@Nonnull SourceIdentifier identifier); + Future getYangTextSchemaSource(@NonNull SourceIdentifier identifier); } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImpl.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImpl.java index eeab236ed9..5e88952dda 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImpl.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImpl.java @@ -5,18 +5,17 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.schema.provider.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.io.IOException; import java.util.Set; -import javax.annotation.Nonnull; import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider; import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; @@ -38,7 +37,7 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro public RemoteYangTextSourceProviderImpl(final SchemaRepository repository, final Set providedSources) { - this.repository = Preconditions.checkNotNull(repository); + this.repository = requireNonNull(repository); this.providedSources = providedSources; } @@ -57,7 +56,7 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro Futures.addCallback(future, new FutureCallback() { @Override - public void onSuccess(@Nonnull final YangTextSchemaSource result) { + public void onSuccess(final YangTextSchemaSource result) { try { promise.success(new YangTextSchemaSourceSerializationProxy(result)); } catch (IOException e) { diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFuture.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFuture.java index a847807b59..7c0a7773f1 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFuture.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/MappingCheckedFuture.java @@ -16,7 +16,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Function; -import javax.annotation.Nonnull; /** * An implementation of CheckedFuture that provides similar behavior for the get methods @@ -56,7 +55,7 @@ public final class MappingCheckedFuture extends Abstract @Override @SuppressWarnings("checkstyle:parameterName") - protected X mapException(@Nonnull final Exception e) { + protected X mapException(final Exception e) { return mapper.apply(e); } @@ -79,7 +78,7 @@ public final class MappingCheckedFuture extends Abstract } @Override - public V get(final long timeout, @Nonnull final TimeUnit unit) + public V get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { try { return super.get(timeout, unit); diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java index bc18e91582..70789ccb14 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java @@ -11,7 +11,6 @@ import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import javax.annotation.CheckReturnValue; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture; import org.opendaylight.mdsal.common.api.CommitInfo; @@ -339,7 +338,6 @@ public interface AsyncWriteTransaction

, D> extends AsyncTransa * @deprecated Use {@link #commit()} instead. */ @Deprecated - @CheckReturnValue default CheckedFuture submit() { return MappingCheckedFuture.create(commit().transform(ignored -> null, MoreExecutors.directExecutor()), SUBMIT_EXCEPTION_MAPPER); @@ -374,7 +372,6 @@ public interface AsyncWriteTransaction

, D> extends AsyncTransa * {@link TransactionCommitFailedException} or an exception derived from TransactionCommitFailedException. * @throws IllegalStateException if the transaction is already committed or was canceled. */ - @CheckReturnValue @NonNull FluentFuture commit(); /** diff --git a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/AbstractMXBean.java b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/AbstractMXBean.java index 8b8b0b87a1..0ce05ebd1e 100644 --- a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/AbstractMXBean.java +++ b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/AbstractMXBean.java @@ -5,13 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.common.util.jmx; import com.google.common.annotations.Beta; import java.lang.management.ManagementFactory; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.MBeanRegistrationException; @@ -19,6 +16,8 @@ import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.NotCompliantMBeanException; import javax.management.ObjectName; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,7 +52,7 @@ public abstract class AbstractMXBean { * @param beanType Used as the type property in the bean's ObjectName. * @param beanCategory Used as the Category property in the bean's ObjectName. */ - protected AbstractMXBean(@Nonnull String beanName, @Nonnull String beanType, + protected AbstractMXBean(@NonNull String beanName, @NonNull String beanType, @Nullable String beanCategory) { this.beanName = beanName; this.beanType = beanType; diff --git a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/ThreadExecutorStatsMXBeanImpl.java b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/ThreadExecutorStatsMXBeanImpl.java index 47a0cc84cc..2323e2d541 100644 --- a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/ThreadExecutorStatsMXBeanImpl.java +++ b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/ThreadExecutorStatsMXBeanImpl.java @@ -5,15 +5,15 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.common.util.jmx; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.util.concurrent.CountingRejectedExecutionHandler; import org.opendaylight.yangtools.util.concurrent.TrackingLinkedBlockingQueue; import org.slf4j.Logger; @@ -39,9 +39,9 @@ public class ThreadExecutorStatsMXBeanImpl extends AbstractMXBean * @param beanCategory Used as the Category property in the bean's ObjectName. */ public ThreadExecutorStatsMXBeanImpl(final ThreadPoolExecutor executor, final String beanName, - final String beanType, @Nullable final String beanCategory) { + final String beanType, final @Nullable String beanCategory) { super(beanName, beanType, beanCategory); - this.executor = Preconditions.checkNotNull(executor); + this.executor = requireNonNull(executor); } private static ThreadExecutorStatsMXBeanImpl createInternal(final Executor executor, @@ -67,7 +67,7 @@ public class ThreadExecutorStatsMXBeanImpl extends AbstractMXBean * is a ThreadPoolExecutor, otherwise null. */ public static ThreadExecutorStatsMXBeanImpl create(final Executor executor, final String beanName, - final String beanType, @Nullable final String beanCategory) { + final String beanType, final @Nullable String beanCategory) { ThreadExecutorStatsMXBeanImpl ret = createInternal(executor, beanName, beanType, beanCategory); if (ret != null) { ret.registerMBean(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/CDSShardAccessImpl.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/CDSShardAccessImpl.java index da328566a0..4580bb9888 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/CDSShardAccessImpl.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/CDSShardAccessImpl.java @@ -8,6 +8,9 @@ package org.opendaylight.controller.cluster.sharding; import static akka.actor.ActorRef.noSender; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; import akka.actor.ActorRef; import akka.actor.PoisonPill; @@ -16,11 +19,9 @@ import akka.dispatch.Mapper; import akka.dispatch.OnComplete; import akka.util.Timeout; import com.google.common.base.Optional; -import com.google.common.base.Preconditions; import java.util.Collection; import java.util.concurrent.CompletionStage; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.Nonnull; import org.opendaylight.controller.cluster.datastore.exceptions.LocalShardNotFoundException; import org.opendaylight.controller.cluster.datastore.messages.MakeLeaderLocal; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; @@ -36,7 +37,6 @@ import org.slf4j.LoggerFactory; import scala.compat.java8.FutureConverters; import scala.concurrent.Future; - /** * Default {@link CDSShardAccess} implementation. Listens on leader location * change events and distributes them to registered listeners. Also updates @@ -65,8 +65,8 @@ final class CDSShardAccessImpl implements CDSShardAccess, LeaderLocationListener private volatile boolean closed = false; CDSShardAccessImpl(final DOMDataTreeIdentifier prefix, final ActorContext actorContext) { - this.prefix = Preconditions.checkNotNull(prefix); - this.actorContext = Preconditions.checkNotNull(actorContext); + this.prefix = requireNonNull(prefix); + this.actorContext = requireNonNull(actorContext); this.makeLeaderLocalTimeout = new Timeout(actorContext.getDatastoreContext().getShardLeaderElectionTimeout().duration().$times(2)); @@ -74,26 +74,23 @@ final class CDSShardAccessImpl implements CDSShardAccess, LeaderLocationListener // TODO Maybe we should do this in async final Optional localShardReply = actorContext.findLocalShard(ClusterUtils.getCleanShardName(prefix.getRootIdentifier())); - Preconditions.checkState(localShardReply.isPresent(), + checkState(localShardReply.isPresent(), "Local shard for {} not present. Cannot register RoleChangeListenerActor", prefix); roleChangeListenerActor = actorContext.getActorSystem().actorOf(RoleChangeListenerActor.props(localShardReply.get(), this)); } private void checkNotClosed() { - Preconditions.checkState(!closed, - "CDSDataTreeProducer, that this CDSShardAccess is associated with, is no longer valid"); + checkState(!closed, "CDSDataTreeProducer, that this CDSShardAccess is associated with, is no longer valid"); } @Override - @Nonnull public DOMDataTreeIdentifier getShardIdentifier() { checkNotClosed(); return prefix; } @Override - @Nonnull public LeaderLocation getLeaderLocation() { checkNotClosed(); // TODO before getting first notification from roleChangeListenerActor @@ -102,7 +99,6 @@ final class CDSShardAccessImpl implements CDSShardAccess, LeaderLocationListener } @Override - @Nonnull public CompletionStage makeLeaderLocal() { // TODO when we have running make leader local operation // we should just return the same completion stage @@ -157,13 +153,12 @@ final class CDSShardAccessImpl implements CDSShardAccess, LeaderLocationListener } @Override - @Nonnull public LeaderLocationListenerRegistration - registerLeaderLocationListener(@Nonnull final L listener) { + registerLeaderLocationListener(final L listener) { checkNotClosed(); - Preconditions.checkNotNull(listener); - Preconditions.checkArgument(!listeners.contains(listener), - "Listener {} is already registered with ShardAccess {}", listener, this); + requireNonNull(listener); + checkArgument(!listeners.contains(listener), "Listener %s is already registered with ShardAccess %s", listener, + this); LOG.debug("Registering LeaderLocationListener {}", listener); @@ -184,7 +179,7 @@ final class CDSShardAccessImpl implements CDSShardAccess, LeaderLocationListener @Override @SuppressWarnings("checkstyle:IllegalCatch") - public void onLeaderLocationChanged(@Nonnull final LeaderLocation location) { + public void onLeaderLocationChanged(final LeaderLocation location) { if (closed) { // we are closed already. Do not dispatch any new leader location // change events. diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeListener.java index ce51aa3ab0..53ced96400 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeListener.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeListener.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.api; import java.util.Collection; import java.util.EventListener; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; /** @@ -46,5 +46,5 @@ public interface DOMDataTreeChangeListener extends EventListener { * * @param changes Collection of change events, may not be null or empty. */ - void onDataTreeChanged(@Nonnull Collection changes); + void onDataTreeChanged(@NonNull Collection changes); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeService.java index 46a6fb2cb7..28590fc606 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeChangeService.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.md.sal.dom.api; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.ListenerRegistration; /** @@ -53,6 +53,6 @@ public interface DOMDataTreeChangeService extends DOMDataBrokerExtension { * your listener using {@link ListenerRegistration#close()} to stop * delivery of change events. */ - @Nonnull ListenerRegistration registerDataTreeChangeListener( - @Nonnull DOMDataTreeIdentifier treeId, @Nonnull L listener); + @NonNull ListenerRegistration registerDataTreeChangeListener( + @NonNull DOMDataTreeIdentifier treeId, @NonNull L listener); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeIdentifier.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeIdentifier.java index f9a96baeee..9ed435a627 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeIdentifier.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeIdentifier.java @@ -5,14 +5,14 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.dom.api; +import static java.util.Objects.requireNonNull; + import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; import java.io.Serializable; import java.util.Iterator; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.concepts.Path; @@ -26,13 +26,13 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum public final class DOMDataTreeIdentifier implements Immutable, Path, Serializable, Comparable { private static final long serialVersionUID = 1L; - private final YangInstanceIdentifier rootIdentifier; - private final LogicalDatastoreType datastoreType; + private final @NonNull YangInstanceIdentifier rootIdentifier; + private final @NonNull LogicalDatastoreType datastoreType; public DOMDataTreeIdentifier(final LogicalDatastoreType datastoreType, final YangInstanceIdentifier rootIdentifier) { - this.datastoreType = Preconditions.checkNotNull(datastoreType); - this.rootIdentifier = Preconditions.checkNotNull(rootIdentifier); + this.datastoreType = requireNonNull(datastoreType); + this.rootIdentifier = requireNonNull(rootIdentifier); } /** @@ -59,7 +59,7 @@ public final class DOMDataTreeIdentifier implements Immutable, * * @return Logical data store type. Guaranteed to be non-null. */ - public @Nonnull LogicalDatastoreType getDatastoreType() { + public @NonNull LogicalDatastoreType getDatastoreType() { return datastoreType; } @@ -68,7 +68,7 @@ public final class DOMDataTreeIdentifier implements Immutable, * * @return Instance identifier corresponding to the root node. */ - public @Nonnull YangInstanceIdentifier getRootIdentifier() { + public @NonNull YangInstanceIdentifier getRootIdentifier() { return rootIdentifier; } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMExtensibleService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMExtensibleService.java index e3dadf7414..1f2c4968c4 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMExtensibleService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMExtensibleService.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.api; import com.google.common.annotations.Beta; import java.util.Map; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * Marker interface for services which can support {@link DOMServiceExtension}. @@ -28,5 +28,5 @@ public interface DOMExtensibleService, * * @return A map of supported functionality. */ - @Nonnull Map, E> getSupportedExtensions(); + @NonNull Map, E> getSupportedExtensions(); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationListener.java index 7085588e87..bd5355f8c1 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationListener.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationListener.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.api; import java.util.EventListener; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * Interface implemented by listeners interested in {@link DOMNotification}s. @@ -20,5 +20,5 @@ public interface DOMNotificationListener extends EventListener { * * @param notification Received notification */ - void onNotification(@Nonnull DOMNotification notification); + void onNotification(@NonNull DOMNotification notification); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationPublishService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationPublishService.java index 852dc56075..08cb25b36d 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationPublishService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationPublishService.java @@ -10,8 +10,7 @@ package org.opendaylight.controller.md.sal.dom.api; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * A {@link DOMService} which allows its user to send {@link DOMNotification}s. It @@ -80,7 +79,7 @@ public interface DOMNotificationPublishService extends DOMService { * @throws InterruptedException if interrupted while waiting * @throws NullPointerException if notification is null. */ - @Nonnull ListenableFuture putNotification(@Nonnull DOMNotification notification) throws InterruptedException; + @NonNull ListenableFuture putNotification(@NonNull DOMNotification notification) throws InterruptedException; /** * Attempt to publish a notification. The result of this method is a {@link ListenableFuture} @@ -97,7 +96,7 @@ public interface DOMNotificationPublishService extends DOMService { * the implementation from accepting the notification for delivery. * @throws NullPointerException if notification is null. */ - @Nonnull ListenableFuture offerNotification(@Nonnull DOMNotification notification); + @NonNull ListenableFuture offerNotification(@NonNull DOMNotification notification); /** * Attempt to publish a notification. The result of this method is a {@link ListenableFuture} @@ -108,7 +107,7 @@ public interface DOMNotificationPublishService extends DOMService { * is guaranteed to block more than the specified timeout. * * @param notification Notification to be published. - * @param timeout how long to wait before giving up, in units of unit + * @param timeout how long to wait before giving up, in units of unit, must not be negative * @param unit a TimeUnit determining how to interpret the timeout parameter * @return A listenable future which will report completion when the service * has finished propagating the notification to its immediate registrants, @@ -118,6 +117,6 @@ public interface DOMNotificationPublishService extends DOMService { * @throws NullPointerException if notification or unit is null. * @throws IllegalArgumentException if timeout is negative. */ - @Nonnull ListenableFuture offerNotification(@Nonnull DOMNotification notification, - @Nonnegative long timeout, @Nonnull TimeUnit unit) throws InterruptedException; + @NonNull ListenableFuture offerNotification(@NonNull DOMNotification notification, + long timeout, @NonNull TimeUnit unit) throws InterruptedException; } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationService.java index 37d3a019a6..1e4625bb2c 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMNotificationService.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.api; import java.util.Collection; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -35,7 +35,7 @@ public interface DOMNotificationService extends DOMService { * @throws NullPointerException if either of the arguments is null */ ListenerRegistration registerNotificationListener( - @Nonnull T listener, @Nonnull Collection types); + @NonNull T listener, @NonNull Collection types); /** * Register a {@link DOMNotificationListener} to receive a set of notifications. As with @@ -53,5 +53,5 @@ public interface DOMNotificationService extends DOMService { */ // FIXME: Java 8: provide a default implementation of this method. ListenerRegistration registerNotificationListener( - @Nonnull T listener, SchemaPath... types); + @NonNull T listener, SchemaPath... types); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcAvailabilityListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcAvailabilityListener.java index a62f79db0b..2131cf1634 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcAvailabilityListener.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcAvailabilityListener.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.api; import java.util.Collection; import java.util.EventListener; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * An {@link EventListener} used to track RPC implementations becoming (un)available a {@link DOMRpcService}. Note that @@ -54,14 +54,14 @@ public interface DOMRpcAvailabilityListener extends EventListener { * * @param rpcs RPC types newly available */ - void onRpcAvailable(@Nonnull Collection rpcs); + void onRpcAvailable(@NonNull Collection rpcs); /** * Method invoked whenever an RPC type becomes unavailable. * * @param rpcs RPC types which became unavailable */ - void onRpcUnavailable(@Nonnull Collection rpcs); + void onRpcUnavailable(@NonNull Collection rpcs); /** * Implementation filtering method. This method is useful for forwarding RPC implementations, diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java index 63e646debd..a574564c0a 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java @@ -7,11 +7,12 @@ */ package org.opendaylight.controller.md.sal.dom.api; +import static java.util.Objects.requireNonNull; + import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; import java.util.Objects; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -24,7 +25,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; public abstract class DOMRpcIdentifier { private static final class Global extends DOMRpcIdentifier { - private Global(final @Nonnull SchemaPath type) { + private Global(final @NonNull SchemaPath type) { super(type); } @@ -37,9 +38,9 @@ public abstract class DOMRpcIdentifier { private static final class Local extends DOMRpcIdentifier { private final YangInstanceIdentifier contextReference; - private Local(final @Nonnull SchemaPath type, final @Nonnull YangInstanceIdentifier contextReference) { + private Local(final @NonNull SchemaPath type, final @NonNull YangInstanceIdentifier contextReference) { super(type); - this.contextReference = Preconditions.checkNotNull(contextReference); + this.contextReference = requireNonNull(contextReference); } @Override @@ -51,7 +52,7 @@ public abstract class DOMRpcIdentifier { private final SchemaPath type; private DOMRpcIdentifier(final SchemaPath type) { - this.type = Preconditions.checkNotNull(type); + this.type = requireNonNull(type); } /** @@ -60,7 +61,7 @@ public abstract class DOMRpcIdentifier { * @param type RPC type, SchemaPath of its definition, may not be null * @return A global RPC identifier, guaranteed to be non-null. */ - public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type) { + public static @NonNull DOMRpcIdentifier create(final @NonNull SchemaPath type) { return new Global(type); } @@ -71,7 +72,7 @@ public abstract class DOMRpcIdentifier { * @param contextReference Context reference, null means a global RPC identifier. * @return A global RPC identifier, guaranteed to be non-null. */ - public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type, + public static @NonNull DOMRpcIdentifier create(final @NonNull SchemaPath type, final @Nullable YangInstanceIdentifier contextReference) { if (contextReference == null || contextReference.isEmpty()) { return new Global(type); @@ -92,7 +93,7 @@ public abstract class DOMRpcIdentifier { * * @return RPC type. */ - public final @Nonnull SchemaPath getType() { + public final @NonNull SchemaPath getType() { return type; } @@ -101,7 +102,7 @@ public abstract class DOMRpcIdentifier { * * @return RPC context reference. */ - public abstract @Nonnull YangInstanceIdentifier getContextReference(); + public abstract @NonNull YangInstanceIdentifier getContextReference(); @Override public final int hashCode() { diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementation.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementation.java index 448cbd4cc3..540f50b7cd 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementation.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementation.java @@ -8,8 +8,8 @@ package org.opendaylight.controller.md.sal.dom.api; import com.google.common.util.concurrent.CheckedFuture; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; /** @@ -27,7 +27,7 @@ public interface DOMRpcImplementation { * or report a subclass of {@link DOMRpcException} reporting a transport * error. */ - @Nonnull CheckedFuture invokeRpc(@Nonnull DOMRpcIdentifier rpc, + @NonNull CheckedFuture invokeRpc(@NonNull DOMRpcIdentifier rpc, @Nullable NormalizedNode input); /** diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationNotAvailableException.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationNotAvailableException.java index 2858255faa..a856607ca9 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationNotAvailableException.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcImplementationNotAvailableException.java @@ -7,8 +7,9 @@ */ package org.opendaylight.controller.md.sal.dom.api; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import static java.util.Objects.requireNonNull; + +import org.eclipse.jdt.annotation.NonNull; /** * Exception indicating that no implementation of the requested RPC service is available. @@ -16,13 +17,13 @@ import javax.annotation.Nonnull; public class DOMRpcImplementationNotAvailableException extends DOMRpcException { private static final long serialVersionUID = 1L; - public DOMRpcImplementationNotAvailableException(@Nonnull final String format, final Object... args) { + public DOMRpcImplementationNotAvailableException(final @NonNull String format, final Object... args) { super(String.format(format, args)); } - public DOMRpcImplementationNotAvailableException(@Nonnull final Throwable cause, @Nonnull final String format, + public DOMRpcImplementationNotAvailableException(final @NonNull Throwable cause, final @NonNull String format, final Object... args) { - super(String.format(format, args), Preconditions.checkNotNull(cause)); + super(String.format(format, args), requireNonNull(cause)); } public DOMRpcImplementationNotAvailableException(final String message, final Throwable cause) { diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcProviderService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcProviderService.java index 9454214650..2d0c1368f5 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcProviderService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcProviderService.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.api; import java.util.Set; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * A {@link DOMService} which allows registration of RPC implementations with a conceptual router. The client @@ -43,8 +43,8 @@ public interface DOMRpcProviderService extends DOMService { * @throws NullPointerException if implementation or types is null * @throws IllegalArgumentException if types is empty or contains a null element. */ - @Nonnull DOMRpcImplementationRegistration registerRpcImplementation( - @Nonnull T implementation, @Nonnull DOMRpcIdentifier... rpcs); + @NonNull DOMRpcImplementationRegistration registerRpcImplementation( + @NonNull T implementation, @NonNull DOMRpcIdentifier... rpcs); /** * Register an {@link DOMRpcImplementation} object with this service. @@ -55,6 +55,6 @@ public interface DOMRpcProviderService extends DOMService { * @throws NullPointerException if implementation or types is null * @throws IllegalArgumentException if types is empty or contains a null element. */ - @Nonnull DOMRpcImplementationRegistration registerRpcImplementation( - @Nonnull T implementation, @Nonnull Set rpcs); + @NonNull DOMRpcImplementationRegistration registerRpcImplementation( + @NonNull T implementation, @NonNull Set rpcs); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcService.java index e8826de060..870fe82ba4 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcService.java @@ -8,8 +8,8 @@ package org.opendaylight.controller.md.sal.dom.api; import com.google.common.util.concurrent.CheckedFuture; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -34,7 +34,7 @@ public interface DOMRpcService extends DOMService { * or report a subclass of {@link DOMRpcException} reporting a transport * error. */ - @Nonnull CheckedFuture invokeRpc(@Nonnull SchemaPath type, + @NonNull CheckedFuture invokeRpc(@NonNull SchemaPath type, @Nullable NormalizedNode input); /** @@ -56,5 +56,5 @@ public interface DOMRpcService extends DOMService { * a {@link ListenerRegistration#close()} will cancel it. Returned object * is guaranteed to be non-null. */ - @Nonnull ListenerRegistration registerRpcListener(@Nonnull T listener); + @NonNull ListenerRegistration registerRpcListener(@NonNull T listener); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMDataBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMDataBroker.java index 2695e64c86..28e4d9b753 100755 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMDataBroker.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMDataBroker.java @@ -15,7 +15,6 @@ import java.util.EnumMap; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; @@ -54,11 +53,9 @@ public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransact if (treeChange) { extensions = ImmutableMap., DOMDataBrokerExtension>of( DOMDataTreeChangeService.class, new DOMDataTreeChangeService() { - @Nonnull @Override public ListenerRegistration - registerDataTreeChangeListener( - @Nonnull final DOMDataTreeIdentifier treeId, @Nonnull final L listener) { + registerDataTreeChangeListener(final DOMDataTreeIdentifier treeId, final L listener) { DOMStore publisher = getTxFactories().get(treeId.getDatastoreType()); checkState(publisher != null, "Requested logical data store is not available."); @@ -95,7 +92,6 @@ public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransact return "DOM-" + txNum.getAndIncrement(); } - @Nonnull @Override public Map, DOMDataBrokerExtension> getSupportedExtensions() { return extensions; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongDataBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongDataBroker.java index 1a7587b3c5..de8a754a0b 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongDataBroker.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongDataBroker.java @@ -7,8 +7,9 @@ */ package org.opendaylight.controller.md.sal.dom.broker.impl; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import static java.util.Objects.requireNonNull; + +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; @@ -35,8 +36,8 @@ public final class PingPongDataBroker extends ForwardingDOMDataBroker implements * * @param delegate Backend broker, may not be null. */ - public PingPongDataBroker(@Nonnull final DOMDataBroker delegate) { - this.delegate = Preconditions.checkNotNull(delegate); + public PingPongDataBroker(final @NonNull DOMDataBroker delegate) { + this.delegate = requireNonNull(delegate); } @Override diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransactionChain.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransactionChain.java index adcf8aaf38..af474c5c56 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransactionChain.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransactionChain.java @@ -7,9 +7,11 @@ */ package org.opendaylight.controller.md.sal.dom.broker.impl; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Verify.verify; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; @@ -18,8 +20,8 @@ import java.util.AbstractMap.SimpleImmutableEntry; import java.util.Map.Entry; import java.util.concurrent.CancellationException; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; @@ -97,7 +99,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain { private volatile PingPongTransaction inflightTx; PingPongTransactionChain(final DOMDataBroker broker, final TransactionChainListener listener) { - this.listener = Preconditions.checkNotNull(listener); + this.listener = requireNonNull(listener); this.delegate = broker.createTransactionChain(new TransactionChainListener() { @Override public void onTransactionChainFailed(final TransactionChain chain, @@ -163,7 +165,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain { } private synchronized PingPongTransaction slowAllocateTransaction() { - Preconditions.checkState(shutdownTx == null, "Transaction chain %s has been shut down", this); + checkState(shutdownTx == null, "Transaction chain %s has been shut down", this); if (deadTx != null) { throw new IllegalStateException( @@ -225,7 +227,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain { * @param tx Transaction which needs processing. */ @GuardedBy("this") - private void processTransaction(@Nonnull final PingPongTransaction tx) { + private void processTransaction(final @NonNull PingPongTransaction tx) { if (failed) { LOG.debug("Cancelling transaction {}", tx); tx.getTransaction().cancel(); @@ -273,7 +275,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain { */ private synchronized void processNextTransaction(final PingPongTransaction tx) { final boolean success = INFLIGHT_UPDATER.compareAndSet(this, tx, null); - Preconditions.checkState(success, "Completed transaction %s while %s was submitted", tx, inflightTx); + checkState(success, "Completed transaction %s while %s was submitted", tx, inflightTx); final PingPongTransaction nextTx = READY_UPDATER.getAndSet(this, null); if (nextTx != null) { @@ -299,10 +301,10 @@ public final class PingPongTransactionChain implements DOMTransactionChain { processNextTransaction(tx); } - void readyTransaction(@Nonnull final PingPongTransaction tx) { + void readyTransaction(final @NonNull PingPongTransaction tx) { // First mark the transaction as not locked. final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null); - Preconditions.checkState(lockedMatch, "Attempted to submit transaction %s while we have %s", tx, lockedTx); + checkState(lockedMatch, "Attempted to submit transaction %s while we have %s", tx, lockedTx); LOG.debug("Transaction {} unlocked", tx); /* @@ -310,7 +312,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain { * or a background transaction completion callback. */ final boolean success = READY_UPDATER.compareAndSet(this, null, tx); - Preconditions.checkState(success, "Transaction %s collided on ready state", tx, readyTx); + checkState(success, "Transaction %s collided on ready state", tx, readyTx); LOG.debug("Transaction {} readied", tx); /* @@ -338,7 +340,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain { synchronized void cancelTransaction(final PingPongTransaction tx, final DOMDataReadWriteTransaction frontendTx) { // Attempt to unlock the operation. final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null); - Verify.verify(lockedMatch, "Cancelling transaction %s collided with locked transaction %s", tx, lockedTx); + verify(lockedMatch, "Cancelling transaction %s collided with locked transaction %s", tx, lockedTx); // Cancel the backend transaction, so we do not end up leaking it. final boolean backendCancelled = tx.getTransaction().cancel(); @@ -374,12 +376,11 @@ public final class PingPongTransactionChain implements DOMTransactionChain { @Override public synchronized void close() { final PingPongTransaction notLocked = lockedTx; - Preconditions - .checkState(notLocked == null, "Attempted to close chain with outstanding transaction %s", notLocked); + checkState(notLocked == null, "Attempted to close chain with outstanding transaction %s", notLocked); // This is not reliable, but if we observe it to be null and the process has already completed, // the backend transaction chain will throw the appropriate error. - Preconditions.checkState(shutdownTx == null, "Attempted to close an already-closed chain"); + checkState(shutdownTx == null, "Attempted to close an already-closed chain"); // This may be a reaction to our failure callback, in that case the backend is already shutdown if (deadTx != null) { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/jmx/CommitStatsMXBeanImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/jmx/CommitStatsMXBeanImpl.java index d7d1feef65..975ea6dbcf 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/jmx/CommitStatsMXBeanImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/jmx/CommitStatsMXBeanImpl.java @@ -5,10 +5,9 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.dom.broker.impl.jmx; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean; import org.opendaylight.yangtools.util.DurationStatisticsTracker; @@ -27,8 +26,8 @@ public class CommitStatsMXBeanImpl extends AbstractMXBean implements CommitStats * @param commitStatsTracker the DurationStatsTracker used to obtain the stats. * @param mbeantype mBeanType Used as the type property in the bean's ObjectName. */ - public CommitStatsMXBeanImpl(@Nonnull DurationStatisticsTracker commitStatsTracker, - @Nonnull String mbeantype) { + public CommitStatsMXBeanImpl(@NonNull DurationStatisticsTracker commitStatsTracker, + @NonNull String mbeantype) { super("CommitStats", mbeantype, null); this.commitStatsTracker = commitStatsTracker; } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/LegacyShardedDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/LegacyShardedDOMDataBrokerAdapter.java index 8839b96a2c..86919927fe 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/LegacyShardedDOMDataBrokerAdapter.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/LegacyShardedDOMDataBrokerAdapter.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter; import static com.google.common.base.Preconditions.checkNotNull; @@ -13,7 +12,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Collections; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; @@ -77,7 +75,6 @@ public class LegacyShardedDOMDataBrokerAdapter implements DOMDataBroker { listener); } - @Nonnull @Override public Map, DOMDataBrokerExtension> getSupportedExtensions() { return Collections.emptyMap(); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java index 5ee9c43f31..fd8ed94da2 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java @@ -5,11 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; @@ -24,7 +23,6 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; import java.util.Map; import java.util.Queue; -import javax.annotation.Nonnull; import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; @@ -69,9 +67,9 @@ class ShardedDOMDataBrokerDelegatingReadWriteTransaction implements DOMDataReadW ShardedDOMDataBrokerDelegatingReadWriteTransaction(final Object readWriteTxId, final SchemaContext ctx, final DOMDataReadOnlyTransaction readTxDelegate, final DOMDataWriteTransaction writeTxDelegate) { - this.readTxDelegate = checkNotNull(readTxDelegate); - this.writeTxDelegate = checkNotNull(writeTxDelegate); - this.txIdentifier = checkNotNull(readWriteTxId); + this.readTxDelegate = requireNonNull(readTxDelegate); + this.writeTxDelegate = requireNonNull(writeTxDelegate); + this.txIdentifier = requireNonNull(readWriteTxId); this.initialReadMap = Maps.newEnumMap(LogicalDatastoreType.class); final InMemoryDataTreeFactory treeFactory = new InMemoryDataTreeFactory(); @@ -120,7 +118,7 @@ class ShardedDOMDataBrokerDelegatingReadWriteTransaction implements DOMDataReadW final Queue currentHistory = Lists.newLinkedList(modificationHistoryMap.get(store)); Futures.addCallback(initialReadMap.get(store), new FutureCallback>>() { @Override - public void onSuccess(@Nonnull final Optional> result) { + public void onSuccess(final Optional> result) { final DataTreeModification mod = snapshotMap.get(store).newModification(); if (result.isPresent()) { mod.write(path, result.get()); @@ -219,8 +217,8 @@ class ShardedDOMDataBrokerDelegatingReadWriteTransaction implements DOMDataReadW Modification(final Operation operation, final YangInstanceIdentifier path, final NormalizedNode data) { this.data = data; - this.path = checkNotNull(path); - this.operation = checkNotNull(operation); + this.path = requireNonNull(path); + this.operation = requireNonNull(operation); } Operation getOperation() { diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java index 51f0c04826..57dbf83f8c 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java @@ -26,7 +26,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -434,7 +433,7 @@ public class DOMDataTreeListenerTest { } @Override - public void onDataTreeChanged(@Nonnull final Collection changes) { + public void onDataTreeChanged(final Collection changes) { receivedChanges.add(changes); latch.countDown(); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterTest.java index 36c5f8f4a7..c0f0e0234b 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterTest.java @@ -22,7 +22,7 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMEvent; @@ -160,7 +160,7 @@ public class DOMNotificationRouterTest { receivedNotification.set(notification); } - void verifyReceived(final SchemaPath path, final ContainerNode body, @Nullable final Date eventTime) + void verifyReceived(final SchemaPath path, final ContainerNode body, final @Nullable Date eventTime) throws InterruptedException, ExecutionException, TimeoutException { final DOMNotification actual = receivedNotification.get(5, TimeUnit.SECONDS); assertEquals(path, actual.getType()); @@ -191,7 +191,7 @@ public class DOMNotificationRouterTest { receivedNotification.set(notification); } - void verifyReceived(final SchemaPath path, final ContainerNode body, @Nullable final Instant eventTime) + void verifyReceived(final SchemaPath path, final ContainerNode body, final @Nullable Instant eventTime) throws InterruptedException, ExecutionException, TimeoutException { final org.opendaylight.mdsal.dom.api.DOMNotification actual = receivedNotification.get(5, TimeUnit.SECONDS); diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java index cfad179867..ab92b00150 100644 --- a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java +++ b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java @@ -10,7 +10,6 @@ package org.opendaylight.controller.sal.core.compat; import static java.util.Objects.requireNonNull; import com.google.common.base.Optional; -import com.google.common.base.Preconditions; import com.google.common.collect.ClassToInstanceMap; import com.google.common.collect.ForwardingObject; import com.google.common.collect.ImmutableClassToInstanceMap; @@ -24,7 +23,7 @@ import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture; import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException; @@ -221,20 +220,20 @@ public class LegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMD private final DOMDataTreeWriteTransaction writeDelegate; private final Object identifier; - DOMDataTransactionAdapter(@Nonnull final DOMDataTreeReadTransaction readDelegate) { - this.readDelegate = Preconditions.checkNotNull(readDelegate); + DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadTransaction readDelegate) { + this.readDelegate = requireNonNull(readDelegate); this.identifier = readDelegate.getIdentifier(); this.writeDelegate = null; } - DOMDataTransactionAdapter(@Nonnull final DOMDataTreeWriteTransaction writeDelegate) { - this.writeDelegate = Preconditions.checkNotNull(writeDelegate); + DOMDataTransactionAdapter(final @NonNull DOMDataTreeWriteTransaction writeDelegate) { + this.writeDelegate = requireNonNull(writeDelegate); this.identifier = writeDelegate.getIdentifier(); this.readDelegate = null; } - DOMDataTransactionAdapter(@Nonnull final DOMDataTreeReadWriteTransaction rwDelegate) { - this.readDelegate = Preconditions.checkNotNull(rwDelegate); + DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadWriteTransaction rwDelegate) { + this.readDelegate = requireNonNull(rwDelegate); this.writeDelegate = rwDelegate; this.identifier = readDelegate.getIdentifier(); } diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DefaultDOMRpcResult.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DefaultDOMRpcResult.java index d25df4982a..925a356a09 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DefaultDOMRpcResult.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/DefaultDOMRpcResult.java @@ -7,15 +7,16 @@ */ package org.opendaylight.controller.md.sal.dom.spi; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.Serializable; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Objects; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.yang.common.RpcError; @@ -55,21 +56,21 @@ public final class DefaultDOMRpcResult implements DOMRpcResult, Immutable, Seria } public DefaultDOMRpcResult(final NormalizedNode result) { - this(result, Collections.emptyList()); + this(result, Collections.emptyList()); } public DefaultDOMRpcResult(final NormalizedNode result, - final @Nonnull Collection errors) { + final @NonNull Collection errors) { this.result = result; - this.errors = Preconditions.checkNotNull(errors); + this.errors = requireNonNull(errors); } - public DefaultDOMRpcResult(final @Nonnull Collection errors) { + public DefaultDOMRpcResult(final @NonNull Collection errors) { this(null, errors); } @Override - public @Nonnull Collection getErrors() { + public Collection getErrors() { return errors; } diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java index 15a5836a17..89b8311dd7 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataBroker.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.spi; import com.google.common.collect.ForwardingObject; import java.util.Map; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; @@ -24,7 +24,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; */ public abstract class ForwardingDOMDataBroker extends ForwardingObject implements DOMDataBroker { @Override - protected abstract @Nonnull DOMDataBroker delegate(); + protected abstract @NonNull DOMDataBroker delegate(); @Override public DOMDataReadOnlyTransaction newReadOnlyTransaction() { diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java index 4742099812..8174ab36b2 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadOnlyTransaction.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.md.sal.dom.spi; import com.google.common.base.Optional; import com.google.common.collect.ForwardingObject; import com.google.common.util.concurrent.CheckedFuture; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; @@ -24,7 +24,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public abstract class ForwardingDOMDataReadOnlyTransaction extends ForwardingObject implements DOMDataReadOnlyTransaction { @Override - protected abstract @Nonnull DOMDataReadOnlyTransaction delegate(); + protected abstract @NonNull DOMDataReadOnlyTransaction delegate(); @Override public CheckedFuture>, ReadFailedException> read(final LogicalDatastoreType store, diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java index 671e0f8876..69e7cc2cd2 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataReadWriteTransaction.java @@ -11,7 +11,7 @@ import com.google.common.base.Optional; import com.google.common.collect.ForwardingObject; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FluentFuture; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; @@ -26,7 +26,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public abstract class ForwardingDOMDataReadWriteTransaction extends ForwardingObject implements DOMDataReadWriteTransaction { @Override - protected abstract @Nonnull DOMDataReadWriteTransaction delegate(); + protected abstract @NonNull DOMDataReadWriteTransaction delegate(); @Override public CheckedFuture>, ReadFailedException> read(final LogicalDatastoreType store, diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java index 4ef889fa44..b260937a72 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMDataWriteTransaction.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.spi; import com.google.common.collect.ForwardingObject; import com.google.common.util.concurrent.FluentFuture; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.mdsal.common.api.CommitInfo; @@ -22,7 +22,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; */ public abstract class ForwardingDOMDataWriteTransaction extends ForwardingObject implements DOMDataWriteTransaction { @Override - protected abstract @Nonnull DOMDataWriteTransaction delegate(); + protected abstract @NonNull DOMDataWriteTransaction delegate(); @Override public Object getIdentifier() { diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcImplementation.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcImplementation.java index f7a21aaf71..a0b2075e5b 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcImplementation.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcImplementation.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.spi; import com.google.common.collect.ForwardingObject; import com.google.common.util.concurrent.CheckedFuture; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; @@ -22,7 +22,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; */ public abstract class ForwardingDOMRpcImplementation extends ForwardingObject implements DOMRpcImplementation { @Override - protected abstract @Nonnull DOMRpcImplementation delegate(); + protected abstract @NonNull DOMRpcImplementation delegate(); @Override public CheckedFuture invokeRpc(final DOMRpcIdentifier type, diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcProviderService.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcProviderService.java index 3e8b5a6f1d..8c1ac53596 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcProviderService.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcProviderService.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.spi; import com.google.common.collect.ForwardingObject; import java.util.Set; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; @@ -21,7 +21,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; */ public abstract class ForwardingDOMRpcProviderService extends ForwardingObject implements DOMRpcProviderService { @Override - protected abstract @Nonnull DOMRpcProviderService delegate(); + protected abstract @NonNull DOMRpcProviderService delegate(); @Override public DOMRpcImplementationRegistration registerRpcImplementation( diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcResult.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcResult.java index e322b01352..d5e04e2bf0 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcResult.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcResult.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.spi; import com.google.common.collect.ForwardingObject; import java.util.Collection; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; */ public abstract class ForwardingDOMRpcResult extends ForwardingObject implements DOMRpcResult { @Override - protected abstract @Nonnull DOMRpcResult delegate(); + protected abstract @NonNull DOMRpcResult delegate(); @Override public Collection getErrors() { diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcService.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcService.java index a9e87d05ca..887ae8a78e 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcService.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcService.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.md.sal.dom.spi; import com.google.common.collect.ForwardingObject; import com.google.common.util.concurrent.CheckedFuture; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; @@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; */ public abstract class ForwardingDOMRpcService extends ForwardingObject implements DOMRpcService { @Override - protected abstract @Nonnull DOMRpcService delegate(); + protected abstract @NonNull DOMRpcService delegate(); @Override public CheckedFuture invokeRpc(final SchemaPath type, diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java index e709e6713a..891079a159 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMTransactionChain.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.spi; import com.google.common.collect.ForwardingObject; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; @@ -20,7 +20,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; */ public abstract class ForwardingDOMTransactionChain extends ForwardingObject implements DOMTransactionChain { @Override - protected abstract @Nonnull DOMTransactionChain delegate(); + protected abstract @NonNull DOMTransactionChain delegate(); @Override public void close() { diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTransaction.java index 4131efc65b..20166a46ad 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTransaction.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTransaction.java @@ -7,12 +7,13 @@ */ package org.opendaylight.controller.sal.core.spi.data; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; -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; /** * Abstract DOM Store Transaction. @@ -29,14 +30,14 @@ import javax.annotation.Nullable; @Beta public abstract class AbstractDOMStoreTransaction implements DOMStoreTransaction { private final Throwable debugContext; - private final T identifier; + private final @NonNull T identifier; - protected AbstractDOMStoreTransaction(@Nonnull final T identifier) { + protected AbstractDOMStoreTransaction(final @NonNull T identifier) { this(identifier, false); } - protected AbstractDOMStoreTransaction(@Nonnull final T identifier, final boolean debug) { - this.identifier = Preconditions.checkNotNull(identifier, "Identifier must not be null."); + protected AbstractDOMStoreTransaction(final @NonNull T identifier, final boolean debug) { + this.identifier = requireNonNull(identifier, "Identifier must not be null."); this.debugContext = debug ? new Throwable().fillInStackTrace() : null; } @@ -48,11 +49,9 @@ public abstract class AbstractDOMStoreTransaction implements DOMStoreTransact /** * Return the context in which this transaction was allocated. * - * @return The context in which this transaction was allocated, or null - * if the context was not recorded. + * @return The context in which this transaction was allocated, or null if the context was not recorded. */ - @Nullable - public final Throwable getDebugContext() { + public final @Nullable Throwable getDebugContext() { return debugContext; } @@ -68,7 +67,7 @@ public abstract class AbstractDOMStoreTransaction implements DOMStoreTransact * ToStringHelper instance * @return ToStringHelper instance which was passed in */ - protected ToStringHelper addToStringAttributes(@Nonnull final ToStringHelper toStringHelper) { + protected ToStringHelper addToStringAttributes(final @NonNull ToStringHelper toStringHelper) { return toStringHelper.add("id", identifier); } } diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java index 670cbe8d67..0ee2d79cdf 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.sal.core.spi.data; import java.util.Collection; import java.util.List; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration; import org.opendaylight.mdsal.dom.spi.AbstractRegistrationTree; @@ -39,8 +39,8 @@ public abstract class AbstractDOMStoreTreeChangePublisher * @param path Path of changed candidate node. Guaranteed to match the path specified by the registration * @param node Candidate node */ - protected abstract void notifyListeners(@Nonnull Collection> - registrations, @Nonnull YangInstanceIdentifier path, @Nonnull DataTreeCandidateNode node); + protected abstract void notifyListeners(@NonNull Collection> + registrations, @NonNull YangInstanceIdentifier path, @NonNull DataTreeCandidateNode node); /** * Callback notifying the subclass that the specified registration is being closed and it's user no longer @@ -51,14 +51,14 @@ public abstract class AbstractDOMStoreTreeChangePublisher * * @param registration Registration which is being closed */ - protected abstract void registrationRemoved(@Nonnull AbstractDOMDataTreeChangeListenerRegistration registration); + protected abstract void registrationRemoved(@NonNull AbstractDOMDataTreeChangeListenerRegistration registration); /** * Process a candidate tree with respect to registered listeners. * * @param candidate candidate three which needs to be processed */ - protected final void processCandidateTree(@Nonnull final DataTreeCandidate candidate) { + protected final void processCandidateTree(final @NonNull DataTreeCandidate candidate) { final DataTreeCandidateNode node = candidate.getRootNode(); if (node.getModificationType() == ModificationType.UNMODIFIED) { LOG.debug("Skipping unmodified candidate {}", candidate); diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTreeChangePublisher.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTreeChangePublisher.java index 78bf7fbfd1..6665bd11f0 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTreeChangePublisher.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/DOMStoreTreeChangePublisher.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.sal.core.spi.data; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -55,6 +55,6 @@ public interface DOMStoreTreeChangePublisher { * your listener using {@link ListenerRegistration#close()} to stop * delivery of change events. */ - @Nonnull ListenerRegistration registerTreeChangeListener( - @Nonnull YangInstanceIdentifier treeId, @Nonnull L listener); + @NonNull ListenerRegistration registerTreeChangeListener( + @NonNull YangInstanceIdentifier treeId, @NonNull L listener); } diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java index b5afe6a80b..01f4008d34 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java @@ -15,7 +15,7 @@ import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/statistics/DOMStoreStatsTracker.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/statistics/DOMStoreStatsTracker.java index 44961070a5..4a6019e1fd 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/statistics/DOMStoreStatsTracker.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/statistics/DOMStoreStatsTracker.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.sal.core.spi.data.statistics; import java.util.concurrent.ExecutorService; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager; /** @@ -24,19 +24,19 @@ public interface DOMStoreStatsTracker { * * @param dclExecutor the executor */ - void setDataChangeListenerExecutor(@Nonnull ExecutorService dclExecutor); + void setDataChangeListenerExecutor(@NonNull ExecutorService dclExecutor); /** * Sets the executor used internally by the data store. * * @param dsExecutor the executor */ - void setDataStoreExecutor(@Nonnull ExecutorService dsExecutor); + void setDataStoreExecutor(@NonNull ExecutorService dsExecutor); /** * Sets the QueuedNotificationManager use for DataChangeListener notifications. * * @param manager the manager */ - void setNotificationManager(@Nonnull QueuedNotificationManager manager); + void setNotificationManager(@NonNull QueuedNotificationManager manager); } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java index 7d98e0d392..6571c60425 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import java.util.concurrent.ExecutorService; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.yangtools.util.concurrent.SpecialExecutors; @@ -26,8 +26,7 @@ public final class InMemoryDOMDataStoreFactory { private InMemoryDOMDataStoreFactory() { } - public static InMemoryDOMDataStore create(final String name, - @Nullable final DOMSchemaService schemaService) { + public static InMemoryDOMDataStore create(final String name, final @Nullable DOMSchemaService schemaService) { return create(name, schemaService, null); } @@ -40,9 +39,8 @@ public final class InMemoryDOMDataStoreFactory { * default property values are used. * @return an InMemoryDOMDataStore instance */ - public static InMemoryDOMDataStore create(final String name, - @Nullable final DOMSchemaService schemaService, - @Nullable final InMemoryDOMDataStoreConfigProperties properties) { + public static InMemoryDOMDataStore create(final String name, final @Nullable DOMSchemaService schemaService, + final @Nullable InMemoryDOMDataStoreConfigProperties properties) { return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, false, properties); } @@ -58,8 +56,8 @@ public final class InMemoryDOMDataStoreFactory { * @return an InMemoryDOMDataStore instance */ public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type, - @Nullable final DOMSchemaService schemaService, final boolean debugTransactions, - @Nullable final InMemoryDOMDataStoreConfigProperties properties) { + final @Nullable DOMSchemaService schemaService, final boolean debugTransactions, + final @Nullable InMemoryDOMDataStoreConfigProperties properties) { InMemoryDOMDataStoreConfigProperties actualProperties = properties; if (actualProperties == null) { diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java index 77f1b0e967..e9b559452a 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java @@ -11,7 +11,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Optional; import java.util.concurrent.ExecutorService; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration; import org.opendaylight.controller.sal.core.spi.data.AbstractDOMStoreTreeChangePublisher; @@ -90,7 +90,7 @@ final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChan return reg; } - synchronized void publishChange(@Nonnull final DataTreeCandidate candidate) { + synchronized void publishChange(final @NonNull DataTreeCandidate candidate) { // Runs synchronized with registrationRemoved() processCandidateTree(candidate); } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteDOMRpcFuture.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteDOMRpcFuture.java index eb9486da30..d5e46a9a84 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteDOMRpcFuture.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteDOMRpcFuture.java @@ -7,13 +7,13 @@ */ package org.opendaylight.controller.remote.rpc; +import static java.util.Objects.requireNonNull; + import akka.dispatch.OnComplete; -import com.google.common.base.Preconditions; import com.google.common.util.concurrent.AbstractFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import javax.annotation.Nonnull; import org.opendaylight.controller.remote.rpc.messages.RpcResponse; import org.opendaylight.mdsal.dom.api.DOMRpcException; import org.opendaylight.mdsal.dom.api.DOMRpcResult; @@ -32,7 +32,7 @@ final class RemoteDOMRpcFuture extends AbstractFuture { private final QName rpcName; private RemoteDOMRpcFuture(final QName rpcName) { - this.rpcName = Preconditions.checkNotNull(rpcName, "rpcName"); + this.rpcName = requireNonNull(rpcName, "rpcName"); } public static RemoteDOMRpcFuture create(final QName rpcName) { @@ -58,7 +58,7 @@ final class RemoteDOMRpcFuture extends AbstractFuture { } @Override - public DOMRpcResult get(final long timeout, @Nonnull final TimeUnit unit) + public DOMRpcResult get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { try { return super.get(timeout, unit); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcListener.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcListener.java index 434f480770..20f32cb0da 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcListener.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcListener.java @@ -7,10 +7,11 @@ */ package org.opendaylight.controller.remote.rpc; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; -import com.google.common.base.Preconditions; import java.util.Collection; -import javax.annotation.Nonnull; import org.opendaylight.controller.remote.rpc.registry.RpcRegistry; import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes; import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes; @@ -31,20 +32,20 @@ final class RpcListener implements DOMRpcAvailabilityListener { private final ActorRef rpcRegistry; RpcListener(final ActorRef rpcRegistry) { - this.rpcRegistry = Preconditions.checkNotNull(rpcRegistry); + this.rpcRegistry = requireNonNull(rpcRegistry); } @Override - public void onRpcAvailable(@Nonnull final Collection rpcs) { - Preconditions.checkArgument(rpcs != null, "Input Collection of DOMRpcIdentifier can not be null."); + public void onRpcAvailable(final Collection rpcs) { + checkArgument(rpcs != null, "Input Collection of DOMRpcIdentifier can not be null."); LOG.debug("Adding registration for [{}]", rpcs); rpcRegistry.tell(new AddOrUpdateRoutes(rpcs), ActorRef.noSender()); } @Override - public void onRpcUnavailable(@Nonnull final Collection rpcs) { - Preconditions.checkArgument(rpcs != null, "Input Collection of DOMRpcIdentifier can not be null."); + public void onRpcUnavailable(final Collection rpcs) { + checkArgument(rpcs != null, "Input Collection of DOMRpcIdentifier can not be null."); LOG.debug("Removing registration for [{}]", rpcs); rpcRegistry.tell(new RemoveRoutes(rpcs), ActorRef.noSender()); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java index ec17297df2..dca81dc0b7 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java @@ -7,16 +7,17 @@ */ package org.opendaylight.controller.remote.rpc.messages; +import static java.util.Objects.requireNonNull; + import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils; import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; import org.opendaylight.yangtools.yang.common.QName; @@ -31,22 +32,20 @@ public final class ExecuteRpc implements Serializable { private final NormalizedNode inputNormalizedNode; private final QName rpc; - private ExecuteRpc(@Nullable final NormalizedNode inputNormalizedNode, @Nonnull final QName rpc) { - this.rpc = Preconditions.checkNotNull(rpc, "rpc Qname should not be null"); + private ExecuteRpc(final @Nullable NormalizedNode inputNormalizedNode, final @NonNull QName rpc) { + this.rpc = requireNonNull(rpc, "rpc Qname should not be null"); this.inputNormalizedNode = inputNormalizedNode; } - public static ExecuteRpc from(@Nonnull final DOMRpcIdentifier rpc, @Nullable final NormalizedNode input) { + public static ExecuteRpc from(final @NonNull DOMRpcIdentifier rpc, final @Nullable NormalizedNode input) { return new ExecuteRpc(input, rpc.getType().getLastComponent()); } - @Nullable - public NormalizedNode getInputNormalizedNode() { + public @Nullable NormalizedNode getInputNormalizedNode() { return inputNormalizedNode; } - @Nonnull - public QName getRpc() { + public @NonNull QName getRpc() { return rpc; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java index 421e13ecb5..02d0f1f185 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java @@ -12,7 +12,7 @@ import java.io.Externalizable; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -24,12 +24,11 @@ public class RpcResponse implements Serializable { + "aren't serialized. FindBugs does not recognize this.") private final NormalizedNode resultNormalizedNode; - public RpcResponse(@Nullable final NormalizedNode inputNormalizedNode) { + public RpcResponse(final @Nullable NormalizedNode inputNormalizedNode) { resultNormalizedNode = inputNormalizedNode; } - @Nullable - public NormalizedNode getResultNormalizedNode() { + public @Nullable NormalizedNode getResultNormalizedNode() { return resultNormalizedNode; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/Bucket.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/Bucket.java index faa51b90ad..a97e253d01 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/Bucket.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/Bucket.java @@ -9,12 +9,12 @@ package org.opendaylight.controller.remote.rpc.registry.gossip; import akka.actor.ActorRef; import java.util.Optional; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; public interface Bucket> { long getVersion(); - @Nonnull T getData(); + @NonNull T getData(); default Optional getWatchActor() { return getData().getWatchActor(); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketImpl.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketImpl.java index daf945289c..535d5c7cd6 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketImpl.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketImpl.java @@ -7,8 +7,9 @@ */ package org.opendaylight.controller.remote.rpc.registry.gossip; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; +import static com.google.common.base.Verify.verifyNotNull; +import static java.util.Objects.requireNonNull; + import java.io.Serializable; final class BucketImpl> implements Bucket, Serializable { @@ -21,7 +22,7 @@ final class BucketImpl> implements Bucket, Serializab BucketImpl(final long version, final T data) { this.version = version; - this.data = Preconditions.checkNotNull(data); + this.data = requireNonNull(data); } @Override @@ -40,7 +41,7 @@ final class BucketImpl> implements Bucket, Serializab } private Object readResolve() { - Verify.verifyNotNull(data); + verifyNotNull(data); return this; } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarDataTreeChangeListener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarDataTreeChangeListener.java index a10e22f871..8d9eb77ddc 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarDataTreeChangeListener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarDataTreeChangeListener.java @@ -5,10 +5,8 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; @@ -28,7 +26,7 @@ public class CarDataTreeChangeListener implements DataTreeChangeListener { private static final Logger LOG = LoggerFactory.getLogger(CarDataTreeChangeListener.class); @java.lang.Override - public void onDataTreeChanged(@Nonnull final java.util.Collection> changes) { + public void onDataTreeChanged(final java.util.Collection> changes) { if (LOG.isTraceEnabled()) { for (DataTreeModification change : changes) { ouputChanges(change); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java index 4ff725f3dd..458e2ed818 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java @@ -5,13 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider.impl; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; @@ -56,10 +53,9 @@ public final class GetConstantService implements DOMRpcImplementation { return rpcProviderService.registerRpcImplementation(new GetConstantService(constant), id); } - @Nonnull @Override - public CheckedFuture invokeRpc(@Nonnull final DOMRpcIdentifier rpc, - @Nullable final NormalizedNode input) { + public CheckedFuture invokeRpc(final DOMRpcIdentifier rpc, + final NormalizedNode input) { LOG.debug("get-constant invoked, current value: {}", constant); final LeafNode value = ImmutableLeafNodeBuilder.create() diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsDOMDataTreeLIstener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsDOMDataTreeLIstener.java index 2b80f84a0d..574952e70e 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsDOMDataTreeLIstener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsDOMDataTreeLIstener.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider.impl; import com.google.common.base.Preconditions; @@ -18,7 +17,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nonnull; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMDataTreeListener; import org.opendaylight.mdsal.dom.api.DOMDataTreeListeningException; @@ -38,8 +36,8 @@ public class IdIntsDOMDataTreeLIstener implements DOMDataTreeListener { private ScheduledExecutorService executorService; @Override - public void onDataTreeChanged(@Nonnull final Collection changes, - @Nonnull final Map> subtrees) { + public void onDataTreeChanged(final Collection changes, + final Map> subtrees) { // There should only be one candidate reported Preconditions.checkState(changes.size() == 1); @@ -69,7 +67,7 @@ public class IdIntsDOMDataTreeLIstener implements DOMDataTreeListener { } @Override - public void onDataTreeFailed(@Nonnull Collection causes) { + public void onDataTreeFailed(Collection causes) { } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java index 60d624442b..2727f529b2 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/IdIntsListener.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider.impl; import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ITEM; @@ -22,7 +21,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; @@ -44,7 +42,7 @@ public class IdIntsListener implements ClusteredDOMDataTreeChangeListener { private ScheduledFuture scheduledFuture; @Override - public void onDataTreeChanged(@Nonnull final Collection changes) { + public void onDataTreeChanged(final Collection changes) { // There should only be one candidate reported Preconditions.checkState(changes.size() == 1); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixShardHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixShardHandler.java index 163d46ab9e..be35234ce0 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixShardHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PrefixShardHandler.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider.impl; import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ID; @@ -23,7 +22,6 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.CompletionStage; import java.util.stream.Collectors; -import javax.annotation.Nullable; import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.sharding.DistributedShardFactory; import org.opendaylight.controller.cluster.sharding.DistributedShardFactory.DistributedShardRegistration; @@ -97,7 +95,7 @@ public class PrefixShardHandler { final ListenableFuture ensureFuture = ensureListExists(); Futures.addCallback(ensureFuture, new FutureCallback() { @Override - public void onSuccess(@Nullable final Object result) { + public void onSuccess(final Object result) { LOG.debug("Initial list write successful."); future.set(RpcResultBuilder.success(new CreatePrefixShardOutputBuilder().build()).build()); } @@ -193,7 +191,7 @@ public class PrefixShardHandler { final ListenableFuture future = tx.commit(); Futures.addCallback(future, new FutureCallback() { @Override - public void onSuccess(@Nullable final Object result) { + public void onSuccess(final Object result) { try { LOG.debug("Closing producer for initial list."); producer.close(); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java index ec0afe328e..6f90c8c947 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java @@ -5,13 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider.impl; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; @@ -64,10 +61,9 @@ public final class RoutedGetConstantService implements DOMRpcImplementation { return rpcProviderService.registerRpcImplementation(new RoutedGetConstantService(constant), id); } - @Nonnull @Override - public CheckedFuture invokeRpc(@Nonnull final DOMRpcIdentifier rpc, - @Nullable final NormalizedNode input) { + public CheckedFuture invokeRpc(final DOMRpcIdentifier rpc, + final NormalizedNode input) { LOG.debug("get-contexted-constant invoked, current value: {}", constant); final LeafNode value = ImmutableLeafNodeBuilder.create() diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java index 8f3dc2caad..50060d36c4 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java @@ -5,14 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.clustering.it.provider.impl; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; @@ -73,10 +70,9 @@ public final class SingletonGetConstantService implements DOMRpcImplementation, .registerClusterSingletonService(new SingletonGetConstantService(rpcProviderService, constant)); } - @Nonnull @Override - public CheckedFuture invokeRpc(@Nonnull DOMRpcIdentifier rpc, - @Nullable NormalizedNode input) { + public CheckedFuture invokeRpc(DOMRpcIdentifier rpc, + NormalizedNode input) { LOG.debug("get-singleton-constant invoked, current value: {}", constant); final LeafNode value = ImmutableLeafNodeBuilder.create() -- 2.36.6