Fix modernization issues 77/84577/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 20 Aug 2019 19:06:59 +0000 (21:06 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 23 Sep 2019 03:35:11 +0000 (05:35 +0200)
This fixes issues pointed out by Modernizer, which mostly boil
down to using Objects.requireNonNull() and direct java.util
collections.

Change-Id: Id32530a6722cd101f96c23f6a745f91b2f09e2f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3859df9beca8f13f1ff2b2744ed3470a1715bec3)

190 files changed:
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractInvokableServiceMetadata.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/MandatoryServiceReferenceMetadata.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestBuilder.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccess.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/TransactionDataModification.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/TransactionModification.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/ClientIdentifier.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/Envelope.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FrontendIdentifier.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/LocalHistoryIdentifier.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/MemberName.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RuntimeRequestException.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/BackendInfo.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ConnectionEntry.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/InitialClientActorContext.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/InversibleLockException.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectForwarder.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectingClientConnection.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/RecoveringClientActorBehavior.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/SavingClientActorBehavior.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/TransmitQueue.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/MockedSnapshotStore.java
opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImpl.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/GetSnapshotReplyActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorDelegatingPersistentDataProvider.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/TimedRunnable.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/EmptyExternalizableProxy.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehavior.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/SyncStatusTracker.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RemoveServer.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestLeadership.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ServerRemoved.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/SimpleReplicatedLogEntry.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorContextImplTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/InMemorySnapshotStore.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AbstractNotificationListenerRegistration.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/AggregatedNotificationListenerRegistration.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeListenerAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataTreeChangeServiceAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMTransactionChainAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDataTreeChangeListenerRegistration.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDOMRpcResultFuture.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java
opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/BindingContextUtils.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/Dispatchers.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/AbortSlicing.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSlice.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSliceIdentifier.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSliceReply.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/SliceOptions.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/notifications/RoleChangeNotifier.java
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataValidationFailedException.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractShardedTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBroker.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMStoreThreePhaseCommitCohortAdaptor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandle.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractTransactionCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/BouncingReconnectForwarder.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientTransactionCursor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DirectTransactionCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/GetClientRequest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractFrontendHistory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractShardDataTreeTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ChainedCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ClusterWrapperImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CompositeDataTreeCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DOMDataTreeCandidateTO.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortActorRegistry.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ForwardingDataTreeChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendHistoryMetadataBuilder.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LeaderLocalDelegateFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalFrontendHistory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/OperationLimiter.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContextSupport.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardReadTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/actors/DataTreeNotificationListenerRegistrationActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/actors/ShardSnapshotActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ConfigurationImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/PrefixShardConfiguration.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipListenerRegistration.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnerChangeListener.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardCommitCoordinator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/messages/SelectOwner.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/OnDemandShardStateCache.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardDataTreeListenerInfoMXBeanImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbstractThreePhaseCommitMessage.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ChangeShardMembersVotingStatus.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CloseTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/CreateTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataTreeChanged.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataTreeListenerInfo.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FindPrimary.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/FlipShardMembersVotingStatus.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadyLocalTransactionSerializer.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/RegisterDataTreeNotificationListenerReply.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractDataTreeCandidateNode.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayload.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendClientMetadata.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ModifiedDataTreeCandidateNode.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/AbstractShardManagerCreator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardInformation.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerInfo.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardPeerAddressResolver.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/UnsignedLongRangeSet.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardModificationFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/PrefixedShardConfigUpdateHandler.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/RoleChangeListenerActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardingServiceAddressResolver.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/messages/LookupPrefixShard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/messages/NotifyProducerCreated.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/messages/NotifyProducerRemoved.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/messages/PrefixShardRemovalLookup.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MemberNode.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorUtilsTest.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/CommitCoordinationTask.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerTransactionChainImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/GlobalDOMRpcRoutingTableEntry.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/RoutedDOMRpcRoutingTableEntry.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/LegacyShardedDOMDataBrokerAdapter.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingTransactionChain.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingWriteTransaction.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/rpc/RpcRoutingStrategy.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadTransaction.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedReadWriteTransaction.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedWriteTransaction.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/ActionRegistry.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStoreActor.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/GossipEnvelope.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/Gossiper.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/LocalBucket.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImplTest.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/PublishNotificationsTask.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/YnlListener.java
opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java

index 2b2af15df979cabdbf1452ea40eb247a49684a07..0e52cb6fb23e7dd26fe604c12b7053cf633d4a9d 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.blueprint;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import java.util.ArrayDeque;
@@ -84,8 +85,8 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo
     }
 
     private void restartContainerAndDependentsInternal(final Bundle forBundle) {
-        Preconditions.checkNotNull(blueprintExtenderService);
-        Preconditions.checkNotNull(quiesceParticipant);
+        requireNonNull(blueprintExtenderService);
+        requireNonNull(quiesceParticipant);
 
         // We use a LinkedHashSet to preserve insertion order as we walk the service usage hierarchy.
         Set<Bundle> containerBundlesSet = new LinkedHashSet<>();
@@ -223,7 +224,7 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo
         }
     }
 
-    private ServiceRegistration<?> registerEventHandler(final BundleContext bundleContext,
+    private static ServiceRegistration<?> registerEventHandler(final BundleContext bundleContext,
             final BlueprintListener listener) {
         return bundleContext.registerService(BlueprintListener.class.getName(), listener, new Hashtable<>());
     }
index c47db3a24ec1888c751b9833035ea33e745c83f9..07bfd8fae862f97002281470aafa85a4ef2bb6b2 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.blueprint.ext;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -50,7 +51,7 @@ abstract class AbstractDependentComponentFactoryMetadata implements DependentCom
     private boolean stoppedServiceRecipes;
 
     protected AbstractDependentComponentFactoryMetadata(final String id) {
-        this.id = Preconditions.checkNotNull(id);
+        this.id = requireNonNull(id);
     }
 
     @Override
index 10ec16f1ab9c160ea9f8bc18a44c108967f5769d..873fd00abe3418fa002510de18a6e3940fd0b108 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.blueprint.ext;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableSet;
 import java.util.Collection;
 import java.util.Set;
@@ -36,7 +37,7 @@ abstract class AbstractInvokableServiceMetadata extends AbstractDependentCompone
 
     AbstractInvokableServiceMetadata(final String id, final String interfaceName) {
         super(id);
-        this.interfaceName = Preconditions.checkNotNull(interfaceName);
+        this.interfaceName = requireNonNull(interfaceName);
     }
 
     Class<RpcService> rpcInterface() {
index 8139e1de52285dc76df7cb2daae020ed9e89ebdd..eaa1ce22c5e51c47ca9f3055b6bcb16ea668d1a1 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.blueprint.ext;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -24,7 +25,7 @@ class MandatoryServiceReferenceMetadata implements ServiceReferenceMetadata {
     private final String id;
 
     MandatoryServiceReferenceMetadata(final String id, final String interfaceClass) {
-        this.id = Preconditions.checkNotNull(id);
+        this.id = requireNonNull(id);
         this.interfaceClass = interfaceClass;
     }
 
index 43ad997ea42cdd50ec522fba6072c9fe2222c98e..525fc82c197762d6a735f81fa20b668dc3048188 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.blueprint.ext;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Collections;
 import java.util.function.Consumer;
 import org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe;
@@ -106,15 +108,12 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe {
             return trackedService;
         }
 
-        Preconditions.checkNotNull(localTrackedServiceReference, "trackedServiceReference is null");
-
-        trackedService = getServiceSecurely(localTrackedServiceReference);
+        trackedService = getServiceSecurely(requireNonNull(localTrackedServiceReference,
+            "trackedServiceReference is null"));
 
         LOG.debug("{}: Returning service instance: {}", getName(), trackedService);
 
-        Preconditions.checkNotNull(trackedService, "getService() returned null for %s", localTrackedServiceReference);
-
-        return trackedService;
+        return checkNotNull(trackedService, "getService() returned null for %s", localTrackedServiceReference);
     }
 
     @Override
index 8a04936e195a962b5af174c47e934f0541374678..b0a0cade210f76af53e68e7cbc2dbd6fbc7b269d 100644 (file)
@@ -7,9 +7,11 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
@@ -35,8 +37,8 @@ public final class ModifyTransactionRequestBuilder implements Builder<ModifyTran
     private long sequence;
 
     public ModifyTransactionRequestBuilder(final TransactionIdentifier identifier, final ActorRef replyTo) {
-        this.identifier = Preconditions.checkNotNull(identifier);
-        this.replyTo = Preconditions.checkNotNull(replyTo);
+        this.identifier = requireNonNull(identifier);
+        this.replyTo = requireNonNull(replyTo);
     }
 
     @Override
@@ -45,16 +47,16 @@ public final class ModifyTransactionRequestBuilder implements Builder<ModifyTran
     }
 
     private void checkNotFinished() {
-        Preconditions.checkState(protocol == null, "Batch has already been finished");
+        checkState(protocol == null, "Batch has already been finished");
     }
 
     public void addModification(final TransactionModification modification) {
         checkNotFinished();
-        modifications.add(Preconditions.checkNotNull(modification));
+        modifications.add(requireNonNull(modification));
     }
 
     public void setSequence(final long sequence) {
-        Preconditions.checkState(!haveSequence, "Sequence has already been set");
+        checkState(!haveSequence, "Sequence has already been set");
         this.sequence = sequence;
         haveSequence = true;
     }
@@ -82,7 +84,7 @@ public final class ModifyTransactionRequestBuilder implements Builder<ModifyTran
 
     @Override
     public ModifyTransactionRequest build() {
-        Preconditions.checkState(haveSequence, "Request sequence has not been set");
+        checkState(haveSequence, "Request sequence has not been set");
 
         final ModifyTransactionRequest ret = new ModifyTransactionRequest(identifier, sequence, replyTo, modifications,
             protocol);
index 8fe4b0bb0ab8ffe1152401522c558ee8908de691..5283257061ccf06eca65be0fafaf110abce6cc6b 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
+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.util.Optional;
 import org.opendaylight.controller.cluster.access.ABIVersion;
@@ -32,7 +33,7 @@ public final class ReadTransactionSuccess extends TransactionSuccess<ReadTransac
     public ReadTransactionSuccess(final TransactionIdentifier identifier, final long sequence,
             final Optional<NormalizedNode<?, ?>> data) {
         super(identifier, sequence);
-        this.data = Preconditions.checkNotNull(data);
+        this.data = requireNonNull(data);
     }
 
     public Optional<NormalizedNode<?, ?>> getData() {
index 72520c0aeca0b0c5c5f3f1972767f07b8863384e..cc901d6fee5732d73650f5d7f0a8ed359658f982 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import java.io.IOException;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -25,7 +26,7 @@ public abstract class TransactionDataModification extends TransactionModificatio
 
     TransactionDataModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
         super(path);
-        this.data = Preconditions.checkNotNull(data);
+        this.data = requireNonNull(data);
     }
 
     public final NormalizedNode<?, ?> getData() {
index dcd05c35140eb4d4c4448554bb0aa3dd4c785c4b..e4168d530033c64c5baa85d25b4e805ca51de988 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import java.io.IOException;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
@@ -34,7 +35,7 @@ public abstract class TransactionModification {
     private final YangInstanceIdentifier path;
 
     TransactionModification(final YangInstanceIdentifier path) {
-        this.path = Preconditions.checkNotNull(path);
+        this.path = requireNonNull(path);
     }
 
     public final YangInstanceIdentifier getPath() {
index fe178f26e9d25cc0aa29202ce951b5096fd6a3c1..e97626b7ebcb607d1780795d1c70fd4da41cc411 100644 (file)
@@ -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.MoreObjects;
-import com.google.common.base.Preconditions;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.Externalizable;
@@ -40,7 +41,7 @@ public final class ClientIdentifier implements WritableIdentifier {
         }
 
         Proxy(final FrontendIdentifier frontendId, final long generation) {
-            this.frontendId = Preconditions.checkNotNull(frontendId);
+            this.frontendId = requireNonNull(frontendId);
             this.generation = generation;
         }
 
@@ -66,7 +67,7 @@ public final class ClientIdentifier implements WritableIdentifier {
     private final long generation;
 
     ClientIdentifier(final FrontendIdentifier frontendId, final long generation) {
-        this.frontendId = Preconditions.checkNotNull(frontendId);
+        this.frontendId = requireNonNull(frontendId);
         this.generation = generation;
     }
 
index 02686d9708254acac8373ed32ee0604f4f7ad7fa..8c5f513bbf3807d410774015543b6fd72ebf491d 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import java.io.Serializable;
 import org.opendaylight.yangtools.concepts.Immutable;
 
@@ -20,7 +21,7 @@ public abstract class Envelope<T extends Message<?, ?>> implements Immutable, Se
     private final long sessionId;
 
     Envelope(final T message, final long sessionId, final long txSequence) {
-        this.message = Preconditions.checkNotNull(message);
+        this.message = requireNonNull(message);
         this.sessionId = sessionId;
         this.txSequence = txSequence;
     }
index 60e40e9e161faf74c5f82c7fdd564c1872d916f9..d47f03773bdcb048a1e8488aa9f4fd792b817147 100644 (file)
@@ -7,8 +7,9 @@
  */
 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;
@@ -38,8 +39,8 @@ public final class FrontendIdentifier implements WritableIdentifier {
         }
 
         Proxy(final MemberName memberName, final FrontendType clientType) {
-            this.memberName = Preconditions.checkNotNull(memberName);
-            this.clientType = Preconditions.checkNotNull(clientType);
+            this.memberName = requireNonNull(memberName);
+            this.clientType = requireNonNull(clientType);
         }
 
         @Override
@@ -64,8 +65,8 @@ public final class FrontendIdentifier implements WritableIdentifier {
     private final FrontendType clientType;
 
     FrontendIdentifier(final MemberName memberName, final FrontendType clientType) {
-        this.clientType = Preconditions.checkNotNull(clientType);
-        this.memberName = Preconditions.checkNotNull(memberName);
+        this.clientType = requireNonNull(clientType);
+        this.memberName = requireNonNull(memberName);
     }
 
     public static FrontendIdentifier create(final MemberName memberName, final FrontendType clientType) {
index 7346ed0f0fffd94e3c69fac7e3d1a97c399ef756..f8f890e2c1df0e75969b2c85fb82b8fd2d93f2aa 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.Externalizable;
@@ -50,7 +51,7 @@ public final class LocalHistoryIdentifier implements WritableIdentifier {
         }
 
         Proxy(final ClientIdentifier frontendId, final long historyId, final long cookie) {
-            this.clientId = Preconditions.checkNotNull(frontendId);
+            this.clientId = requireNonNull(frontendId);
             this.historyId = historyId;
             this.cookie = cookie;
         }
@@ -85,7 +86,7 @@ public final class LocalHistoryIdentifier implements WritableIdentifier {
     }
 
     public LocalHistoryIdentifier(final ClientIdentifier frontendId, final long historyId, final long cookie) {
-        this.clientId = Preconditions.checkNotNull(frontendId);
+        this.clientId = requireNonNull(frontendId);
         this.historyId = historyId;
         this.cookie = cookie;
     }
index 09e39e8c582f17a8be1fc72f0e880de137b82972..70df622b9bde76d4685d1cd805e8def05cd6db07 100644 (file)
@@ -7,11 +7,13 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
-import com.google.common.base.Verify;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.DataInput;
 import java.io.DataOutput;
@@ -41,7 +43,7 @@ public final class MemberName implements Comparable<MemberName>, WritableIdentif
         }
 
         Proxy(final byte[] serialized) {
-            this.serialized = Preconditions.checkNotNull(serialized);
+            this.serialized = requireNonNull(serialized);
         }
 
         @Override
@@ -70,16 +72,16 @@ public final class MemberName implements Comparable<MemberName>, WritableIdentif
     private volatile byte[] serialized;
 
     private MemberName(final String name) {
-        this.name = Preconditions.checkNotNull(name);
+        this.name = requireNonNull(name);
     }
 
     MemberName(final String name, final byte[] serialized) {
         this(name);
-        this.serialized = Verify.verifyNotNull(serialized);
+        this.serialized = verifyNotNull(serialized);
     }
 
     public static MemberName forName(final String name) {
-        Preconditions.checkArgument(!Strings.isNullOrEmpty(name));
+        checkArgument(!Strings.isNullOrEmpty(name));
         // TODO: consider caching instances here
         return new MemberName(name);
     }
index a52396fd5d5f6a00ab78085bd457f8aca3a3246d..7fb0ef070112ed34a2e333723f51815044e0764e 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 
 /**
@@ -21,8 +23,8 @@ public final class RuntimeRequestException extends RequestException {
     private static final long serialVersionUID = 1L;
 
     public RuntimeRequestException(final String message, final Throwable cause) {
-        super(message, Preconditions.checkNotNull(cause));
-        Preconditions.checkArgument(!Strings.isNullOrEmpty(message), "Exception message is mandatory");
+        super(message, requireNonNull(cause));
+        checkArgument(!Strings.isNullOrEmpty(message), "Exception message is mandatory");
     }
 
     @Override
index 01aff95532b4bd228afed5fe025531a93fecc1a7..891de52fb5a48ecf9b132f7d55c80ced68b6b047 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 
 /**
@@ -33,10 +35,10 @@ public class BackendInfo {
 
     protected BackendInfo(final ActorRef actor, final String name, final long sessionId, final ABIVersion version,
             final int maxMessages) {
-        this.version = Preconditions.checkNotNull(version);
-        this.actor = Preconditions.checkNotNull(actor);
-        this.name = Preconditions.checkNotNull(name);
-        Preconditions.checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
+        this.version = requireNonNull(version);
+        this.actor = requireNonNull(actor);
+        this.name = requireNonNull(name);
+        checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
         this.maxMessages = maxMessages;
         this.sessionId = sessionId;
     }
index 8d769b273814e735691cd66206de5644549fd433..b47ddee2a3c5707624ca78b11579a0a3e9894473 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+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 java.util.function.Consumer;
 import org.opendaylight.controller.cluster.access.concepts.Request;
 import org.opendaylight.controller.cluster.access.concepts.Response;
@@ -29,8 +30,8 @@ public class ConnectionEntry implements Immutable {
     private final long enqueuedTicks;
 
     ConnectionEntry(final Request<?, ?> request, final Consumer<Response<?, ?>> callback, final long now) {
-        this.request = Preconditions.checkNotNull(request);
-        this.callback = Preconditions.checkNotNull(callback);
+        this.request = requireNonNull(request);
+        this.callback = requireNonNull(callback);
         this.enqueuedTicks = now;
     }
 
index 4449dd2fb961e18908d5d0ecf6154e7824c000c9..b739a0bc59fbbe5e404933766f84f7b1d56b6136 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorSystem;
 import akka.persistence.SnapshotSelectionCriteria;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 
 /**
@@ -22,7 +23,7 @@ final class InitialClientActorContext extends AbstractClientActorContext {
 
     InitialClientActorContext(final AbstractClientActor actor, final String persistenceId) {
         super(actor.self(), persistenceId);
-        this.actor = Preconditions.checkNotNull(actor);
+        this.actor = requireNonNull(actor);
     }
 
     void saveSnapshot(final ClientIdentifier snapshot) {
index 7ec18a265d20b412de826575fbc4c1c7670e4016..a2f2ffd7e87eb15b8bb9bbcf45460346eea7610a 100644 (file)
@@ -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 java.util.concurrent.CountDownLatch;
 
 /**
@@ -24,7 +25,7 @@ public final class InversibleLockException extends RuntimeException {
     private final transient CountDownLatch latch;
 
     InversibleLockException(final CountDownLatch latch) {
-        this.latch = Preconditions.checkNotNull(latch);
+        this.latch = requireNonNull(latch);
     }
 
     public void awaitResolution() {
index 58334f91d79199dd713f7bf8f139800f999c4260..8217b72861ea6f9c58f4af47ea9f229c52f902ee 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
 
 /**
  * Forwarder class responsible for routing requests from the previous connection incarnation back to the originator,
@@ -20,7 +20,7 @@ public abstract class ReconnectForwarder {
     private final AbstractReceivingClientConnection<?> successor;
 
     protected ReconnectForwarder(final AbstractReceivingClientConnection<?> successor) {
-        this.successor = Preconditions.checkNotNull(successor);
+        this.successor = requireNonNull(successor);
     }
 
     protected final void sendToSuccessor(final ConnectionEntry entry) {
index acf876b6ce6eb3f85b9c7a2753f254aae878ddbf..e63e7253bcf9b66731e78dc5c698a9d1ab879215 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.controller.cluster.access.concepts.RequestException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -26,7 +27,7 @@ public final class ReconnectingClientConnection<T extends BackendInfo> extends A
 
     ReconnectingClientConnection(final ConnectedClientConnection<T> oldConnection, final RequestException cause) {
         super(oldConnection);
-        this.cause = Preconditions.checkNotNull(cause);
+        this.cause = requireNonNull(cause);
     }
 
     @Override
@@ -38,7 +39,7 @@ public final class ReconnectingClientConnection<T extends BackendInfo> extends A
     @Override
     @SuppressWarnings("checkstyle:hiddenField")
     ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current, final RequestException cause) {
-        this.cause = Preconditions.checkNotNull(cause);
+        this.cause = requireNonNull(cause);
         LOG.warn("Skipping reconnect of already-reconnecting connection {}", this);
         return current;
     }
index 5e2b455abc4f8f88e685d0aff9cea882d6fbb7f3..795c98d7215cb7d3548d2c8b85ca37dea38958a4 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.persistence.RecoveryCompleted;
 import akka.persistence.SnapshotOffer;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
 import org.slf4j.Logger;
@@ -27,7 +28,7 @@ final class RecoveringClientActorBehavior extends AbstractClientActorBehavior<In
 
     RecoveringClientActorBehavior(final InitialClientActorContext context, final FrontendIdentifier frontendId) {
         super(context);
-        currentFrontend = Preconditions.checkNotNull(frontendId);
+        currentFrontend = requireNonNull(frontendId);
     }
 
     @Override
index 58a10776f4b6723303c42eeae05024c841ad1f44..42823a19ab04400f70472e71e75b974e5f5a6840 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.persistence.DeleteSnapshotsFailure;
 import akka.persistence.DeleteSnapshotsSuccess;
 import akka.persistence.SaveSnapshotFailure;
 import akka.persistence.SaveSnapshotSuccess;
 import akka.persistence.SnapshotSelectionCriteria;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -28,7 +29,7 @@ final class SavingClientActorBehavior extends RecoveredClientActorBehavior<Initi
 
     SavingClientActorBehavior(final InitialClientActorContext context, final ClientIdentifier nextId) {
         super(context);
-        this.myId = Preconditions.checkNotNull(nextId);
+        this.myId = requireNonNull(nextId);
     }
 
     @Override
index e4ee78c5391754c7020b1a385311c077f74c9479..71de580bd3f291d200170078db9ab939187d6da9 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+import static com.google.common.base.Verify.verify;
+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.base.Verify;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
@@ -94,8 +95,8 @@ abstract class TransmitQueue {
         Transmitting(final TransmitQueue oldQueue, final int targetDepth, final BackendInfo backend, final long now,
                 final MessageSlicer messageSlicer) {
             super(oldQueue, targetDepth, now);
-            this.backend = Preconditions.checkNotNull(backend);
-            this.messageSlicer = Preconditions.checkNotNull(messageSlicer);
+            this.backend = requireNonNull(backend);
+            this.messageSlicer = requireNonNull(messageSlicer);
         }
 
         @Override
@@ -347,8 +348,8 @@ abstract class TransmitQueue {
     }
 
     final void setForwarder(final ReconnectForwarder forwarder, final long now) {
-        Verify.verify(successor == null, "Successor %s already set on connection %s", successor, this);
-        successor = Preconditions.checkNotNull(forwarder);
+        verify(successor == null, "Successor %s already set on connection %s", successor, this);
+        successor = requireNonNull(forwarder);
         LOG.debug("Connection {} superseded by {}, splicing queue", this, successor);
 
         /*
index 3e26ae92cdc50ad1f5d0e6b540780e17d6696bc5..e0dd69ed432125c2322a819ae2dc93e39fb00d3b 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.dispatch.OnComplete;
 import akka.pattern.Patterns;
@@ -14,7 +16,6 @@ import akka.persistence.SelectedSnapshot;
 import akka.persistence.SnapshotMetadata;
 import akka.persistence.SnapshotSelectionCriteria;
 import akka.persistence.snapshot.japi.SnapshotStore;
-import com.google.common.base.Preconditions;
 import java.util.Optional;
 import scala.concurrent.Future;
 import scala.concurrent.Promise;
@@ -67,9 +68,7 @@ class MockedSnapshotStore extends SnapshotStore {
     }
 
     private <T> Future<T> askDelegate(final MockedSnapshotStoreMessage message) {
-        Preconditions.checkNotNull(delegate, "Delegate ref wasn't sent");
-        final Future<Object> ask = Patterns.ask(delegate, message, TIMEOUT);
-        return transform(ask);
+        return transform(Patterns.ask(requireNonNull(delegate, "Delegate ref was not sent"), message, TIMEOUT));
     }
 
     private <T> Future<T> transform(final Future<Object> future) {
index dac4f8fee8025afe31778c6908dbdb160047024e..89b8a9c313672b3ece5bd1086e5247344bec9402 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.messagebus.app.impl;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.controller.messagebus.spi.EventSource;
 import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
@@ -25,7 +26,7 @@ class EventSourceRegistrationImpl<T extends EventSource> extends AbstractObjectR
      */
     EventSourceRegistrationImpl(T instance, EventSourceTopology eventSourceTopology) {
         super(instance);
-        this.eventSourceTopology = Preconditions.checkNotNull(eventSourceTopology);
+        this.eventSourceTopology = requireNonNull(eventSourceTopology);
     }
 
     @Override
index a533168bb21d35631f6384dd93fa278f2ae22da8..d1e0b5c286e609259a5837d3c4e1c08667478caf 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.controller.cluster.raft;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.actor.ReceiveTimeout;
 import akka.actor.UntypedAbstractActor;
-import com.google.common.base.Preconditions;
 import java.util.concurrent.TimeoutException;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
@@ -82,11 +83,11 @@ class GetSnapshotReplyActor extends UntypedAbstractActor {
 
         Params(final CaptureSnapshot captureSnapshot, final ElectionTerm electionTerm, final ActorRef replyToActor,
                 final FiniteDuration receiveTimeout, final String id, final ServerConfigurationPayload peerInfo) {
-            this.captureSnapshot = Preconditions.checkNotNull(captureSnapshot);
-            this.electionTerm = Preconditions.checkNotNull(electionTerm);
-            this.replyToActor = Preconditions.checkNotNull(replyToActor);
-            this.receiveTimeout = Preconditions.checkNotNull(receiveTimeout);
-            this.id = Preconditions.checkNotNull(id);
+            this.captureSnapshot = requireNonNull(captureSnapshot);
+            this.electionTerm = requireNonNull(electionTerm);
+            this.replyToActor = requireNonNull(replyToActor);
+            this.receiveTimeout = requireNonNull(receiveTimeout);
+            this.id = requireNonNull(id);
             this.peerInformation = peerInfo;
         }
     }
index dc97336a49d1e1dfdb7067a9aeaed37d2ebc6f67..9195ad3b1b1e60c5673832a0164c26af830b1df5 100755 (executable)
@@ -16,7 +16,7 @@ import akka.actor.ActorSelection;
 import akka.actor.PoisonPill;
 import akka.actor.Status;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -480,7 +480,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor {
         if (getCurrentBehavior() instanceof AbstractLeader) {
             AbstractLeader leader = (AbstractLeader)getCurrentBehavior();
             Collection<String> followerIds = leader.getFollowerIds();
-            List<FollowerInfo> followerInfoList = Lists.newArrayListWithCapacity(followerIds.size());
+            List<FollowerInfo> followerInfoList = new ArrayList<>(followerIds.size());
             for (String id: followerIds) {
                 final FollowerLogInformation info = leader.getFollower(id);
                 followerInfoList.add(new FollowerInfo(id, info.getNextIndex(), info.getMatchIndex(),
index 238b7e77852b34f242c0d500cec206960deedba4..0bd86382607f61b827e14a25dc8f86e15f11b70d 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.raft;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.japi.Procedure;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.DataPersistenceProvider;
 import org.opendaylight.controller.cluster.DelegatingPersistentDataProvider;
 import org.opendaylight.controller.cluster.PersistentDataProvider;
@@ -24,10 +25,10 @@ import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Persis
 class RaftActorDelegatingPersistentDataProvider extends DelegatingPersistentDataProvider {
     private final PersistentDataProvider persistentProvider;
 
-    RaftActorDelegatingPersistentDataProvider(DataPersistenceProvider delegate,
-            PersistentDataProvider persistentProvider) {
+    RaftActorDelegatingPersistentDataProvider(final DataPersistenceProvider delegate,
+            final PersistentDataProvider persistentProvider) {
         super(delegate);
-        this.persistentProvider = Preconditions.checkNotNull(persistentProvider);
+        this.persistentProvider = requireNonNull(persistentProvider);
     }
 
     @Override
@@ -36,7 +37,7 @@ class RaftActorDelegatingPersistentDataProvider extends DelegatingPersistentData
     }
 
     @Override
-    public <T> void persistAsync(T entry, Procedure<T> procedure) {
+    public <T> void persistAsync(final T entry, final Procedure<T> procedure) {
         doPersist(entry, procedure, true);
     }
 
index 6411d858b99c3a6a4bb489c5c3190878f730f29d..7d9a1bbf5bdbbfba4fd8df57bf17a17f8e8b125f 100644 (file)
@@ -55,7 +55,7 @@ public class SnapshotManager implements SnapshotState {
     private CaptureSnapshot captureSnapshot;
     private long lastSequenceNumber = -1;
 
-    private Consumer<Optional<OutputStream>> createSnapshotProcedure;
+    private Consumer<Optional<OutputStream>> createSnapshotProcedure = null;
 
     private ApplySnapshot applySnapshot;
     private RaftActorSnapshotCohort snapshotCohort = NoopRaftActorSnapshotCohort.INSTANCE;
index 95606657562ce865e3664d2973e248a1f069a3ca..f16e5e2b59e1d99d1eb9ab78501c8f00fdff60cb 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.raft;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.Cancellable;
-import com.google.common.base.Preconditions;
 import scala.concurrent.duration.FiniteDuration;
 
 /**
@@ -26,11 +27,10 @@ abstract class TimedRunnable implements Runnable {
     private final Cancellable cancelTimer;
     private boolean canRun = true;
 
-    TimedRunnable(FiniteDuration timeout, RaftActor actor) {
-        Preconditions.checkNotNull(timeout);
-        Preconditions.checkNotNull(actor);
-        cancelTimer = actor.getContext().system().scheduler().scheduleOnce(timeout, actor.self(),
-                (Runnable) this::cancel, actor.getContext().system().dispatcher(), actor.self());
+    TimedRunnable(final FiniteDuration timeout, final RaftActor actor) {
+        cancelTimer = requireNonNull(actor).getContext().system().scheduler()
+                .scheduleOnce(requireNonNull(timeout), actor.self(), (Runnable) this::cancel,
+                    actor.getContext().system().dispatcher(), actor.self());
     }
 
     @Override
index 091237a5ca48bdc94a8d9141edc999f3700dc1a3..67f3ed92aeeccdaaad5c407eb56304577d2fd4d0 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.raft.base.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.Externalizable;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -23,16 +24,16 @@ public abstract class EmptyExternalizableProxy implements Externalizable {
 
     private final Object readResolveTo;
 
-    protected EmptyExternalizableProxy(Object readResolveTo) {
-        this.readResolveTo = Preconditions.checkNotNull(readResolveTo);
+    protected EmptyExternalizableProxy(final Object readResolveTo) {
+        this.readResolveTo = requireNonNull(readResolveTo);
     }
 
     @Override
-    public void writeExternal(ObjectOutput out) {
+    public void writeExternal(final ObjectOutput out) {
     }
 
     @Override
-    public void readExternal(ObjectInput in) {
+    public void readExternal(final ObjectInput in) {
     }
 
     protected Object readResolve() {
index 087c656b1836daaf9c05ac7b91e32eba1057c02c..2b28c372488709646f96c3db5d31a7e9e267ef1e 100644 (file)
@@ -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.behaviors;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.Cancellable;
-import com.google.common.base.Preconditions;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.Random;
 import java.util.concurrent.TimeUnit;
@@ -64,8 +64,8 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior {
     private long replicatedToAllIndex = -1;
 
     AbstractRaftActorBehavior(final RaftActorContext context, final RaftState state) {
-        this.context = Preconditions.checkNotNull(context);
-        this.state = Preconditions.checkNotNull(state);
+        this.context = requireNonNull(context);
+        this.state = requireNonNull(state);
         this.log = context.getLogger();
 
         logName = String.format("%s (%s)", context.getId(), state);
index 20714493e84658d7a8c780cc3a1efd0573962b13..2b700ffc43c1ec80cce36f2ab4293cfaebc09547 100644 (file)
@@ -5,11 +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.behaviors;
 
+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 org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -28,7 +29,7 @@ public class SyncStatusTracker {
         final String leaderId;
 
         LeaderInfo(final String leaderId, final long minimumCommitIndex) {
-            this.leaderId = Preconditions.checkNotNull(leaderId);
+            this.leaderId = requireNonNull(leaderId);
             this.minimumCommitIndex = minimumCommitIndex;
         }
     }
@@ -46,14 +47,14 @@ public class SyncStatusTracker {
     private boolean syncStatus;
 
     public SyncStatusTracker(final ActorRef actor, final String id, final long syncThreshold) {
-        this.actor = Preconditions.checkNotNull(actor, "actor should not be null");
-        this.id = Preconditions.checkNotNull(id, "id should not be null");
-        Preconditions.checkArgument(syncThreshold >= 0, "syncThreshold should be greater than or equal to 0");
+        this.actor = requireNonNull(actor, "actor should not be null");
+        this.id = requireNonNull(id, "id should not be null");
+        checkArgument(syncThreshold >= 0, "syncThreshold should be greater than or equal to 0");
         this.syncThreshold = syncThreshold;
     }
 
     public void update(final String leaderId, final long leaderCommit, final long commitIndex) {
-        Preconditions.checkNotNull(leaderId, "leaderId should not be null");
+        requireNonNull(leaderId, "leaderId should not be null");
 
         if (syncTarget == null || !leaderId.equals(syncTarget.leaderId)) {
             LOG.debug("{}: Last sync leader does not match current leader {}, need to catch up to {}", id,
index 9f4977e83ca4b56f319ba2aad61de90667ee8023..0c74d890d82f2c23783bb825e2dc0e05965bf28a 100644 (file)
@@ -5,10 +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.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.Serializable;
 
 /**
@@ -19,8 +19,8 @@ public class RemoveServer implements Serializable {
 
     private final String serverId;
 
-    public RemoveServer(String serverId) {
-        this.serverId = Preconditions.checkNotNull(serverId);
+    public RemoveServer(final String serverId) {
+        this.serverId = requireNonNull(serverId);
     }
 
     public String getServerId() {
index 5561085539a179939dc1167fc74c8d8c7da58d26..766c5c4338d4cd5aa5cfd00ec03460a6d8ebc64f 100644 (file)
@@ -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.messages;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
 import java.io.Serializable;
 
 /**
@@ -22,8 +22,8 @@ public final class RequestLeadership implements Serializable {
     private final ActorRef replyTo;
 
     public RequestLeadership(final String requestedFollowerId, final ActorRef replyTo) {
-        this.requestedFollowerId = Preconditions.checkNotNull(requestedFollowerId);
-        this.replyTo = Preconditions.checkNotNull(replyTo);
+        this.requestedFollowerId = requireNonNull(requestedFollowerId);
+        this.replyTo = requireNonNull(replyTo);
     }
 
     public String getRequestedFollowerId() {
index 3375137adac63d876463ac46982d3626f2f21137..a7de8ea1a7b5c2e37944ed3ef06d6b3f58d8ba92 100644 (file)
@@ -5,10 +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.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.Serializable;
 
 /**
@@ -20,8 +20,8 @@ public class ServerRemoved implements Serializable {
 
     private final String serverId;
 
-    public ServerRemoved(String serverId) {
-        this.serverId = Preconditions.checkNotNull(serverId);
+    public ServerRemoved(final String serverId) {
+        this.serverId = requireNonNull(serverId);
     }
 
     public String getServerId() {
index 14ce5420d26081c06eed9a442e3dd39287c1c730..4c07e6b812e254ad026e6d49211e4e22b97f5b6b 100644 (file)
@@ -5,10 +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.persisted;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -39,7 +39,7 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria
             this.replicatedLogEntry = replicatedLogEntry;
         }
 
-        static int estimatedSerializedSize(ReplicatedLogEntry replicatedLogEntry) {
+        static int estimatedSerializedSize(final ReplicatedLogEntry replicatedLogEntry) {
             return 8 /* index */ + 8 /* term */ + replicatedLogEntry.getData().size()
                     + 400 /* estimated extra padding for class info */;
         }
@@ -75,10 +75,10 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria
      * @param term the term
      * @param payload the payload
      */
-    public SimpleReplicatedLogEntry(long index, long term, Payload payload) {
+    public SimpleReplicatedLogEntry(final long index, final long term, final Payload payload) {
         this.index = index;
         this.term = term;
-        this.payload = Preconditions.checkNotNull(payload);
+        this.payload = requireNonNull(payload);
     }
 
     @Override
@@ -107,7 +107,7 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria
     }
 
     @Override
-    public void setPersistencePending(boolean pending) {
+    public void setPersistencePending(final boolean pending) {
         persistencePending = pending;
     }
 
@@ -130,7 +130,7 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
index cf09ab59e6bd5f10cb5d7890e84c74493245e4c2..815b8d9d4869c4fbcd4806274cf1ee49c86ac5c1 100644 (file)
@@ -20,7 +20,6 @@ import static org.mockito.Mockito.verify;
 import akka.actor.Props;
 import akka.testkit.TestActorRef;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -85,7 +84,7 @@ public class RaftActorContextImplTest extends AbstractActorTest {
         DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
         RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
                 "test", new ElectionTermImpl(createProvider(), "test", LOG), -1, -1,
-                Maps.newHashMap(ImmutableMap.<String, String>of("peer1", "peerAddress1")), configParams,
+                new HashMap<>(ImmutableMap.of("peer1", "peerAddress1")), configParams,
                 createProvider(), applyState -> { }, LOG,  MoreExecutors.directExecutor());
 
         context.setPeerAddress("peer1", "peerAddress1_1");
@@ -99,7 +98,7 @@ public class RaftActorContextImplTest extends AbstractActorTest {
     public void testUpdatePeerIds() {
         RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
                 "self", new ElectionTermImpl(createProvider(), "test", LOG), -1, -1,
-                Maps.newHashMap(ImmutableMap.<String, String>of("peer1", "peerAddress1")),
+                new HashMap<>(ImmutableMap.of("peer1", "peerAddress1")),
                 new DefaultConfigParamsImpl(), createProvider(), applyState -> { }, LOG,
                 MoreExecutors.directExecutor());
 
index 54ba69ec84025a05496f9b761dc8da407ded1e60..140735b646e92e00f3d795bf02ff94a390becb96 100644 (file)
@@ -23,8 +23,7 @@ import akka.testkit.TestActorRef;
 import akka.testkit.javadsl.TestKit;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.io.ByteSource;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.io.OutputStream;
@@ -32,6 +31,8 @@ import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -203,9 +204,9 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         // Verify new server config was applied in both followers
 
-        assertEquals("Follower peers", Sets.newHashSet(LEADER_ID, NEW_SERVER_ID), followerActorContext.getPeerIds());
+        assertEquals("Follower peers", ImmutableSet.of(LEADER_ID, NEW_SERVER_ID), followerActorContext.getPeerIds());
 
-        assertEquals("New follower peers", Sets.newHashSet(LEADER_ID, FOLLOWER_ID),
+        assertEquals("New follower peers", ImmutableSet.of(LEADER_ID, FOLLOWER_ID),
                 newFollowerActorContext.getPeerIds());
 
         assertEquals("Follower commit index", 3, followerActorContext.getCommitIndex());
@@ -277,7 +278,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         // Verify new server config was applied in the new follower
 
-        assertEquals("New follower peers", Sets.newHashSet(LEADER_ID), newFollowerActorContext.getPeerIds());
+        assertEquals("New follower peers", ImmutableSet.of(LEADER_ID), newFollowerActorContext.getPeerIds());
 
         LOG.info("testAddServerWithNoExistingFollower ending");
     }
@@ -324,7 +325,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         // Verify new server config was applied in the new follower
 
-        assertEquals("New follower peers", Sets.newHashSet(LEADER_ID), newFollowerActorContext.getPeerIds());
+        assertEquals("New follower peers", ImmutableSet.of(LEADER_ID), newFollowerActorContext.getPeerIds());
 
         assertNoneMatching(newFollowerCollectorActor, InstallSnapshot.class, 500);
 
@@ -409,7 +410,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         // Verify ServerConfigurationPayload entry in the new follower
 
         expectMatching(newFollowerCollectorActor, ApplyState.class, 2);
-        assertEquals("New follower peers", Sets.newHashSet(LEADER_ID, NEW_SERVER_ID2),
+        assertEquals("New follower peers", ImmutableSet.of(LEADER_ID, NEW_SERVER_ID2),
                newFollowerActorContext.getPeerIds());
 
         LOG.info("testAddServerWithOperationInProgress ending");
@@ -1283,8 +1284,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, reply.getStatus());
 
-        assertEquals("Server config", Sets.newHashSet(nonVotingServer(node1ID), votingServer(node2ID)),
-                Sets.newHashSet(node1RaftActor.getRaftActorContext().getPeerServerInfo(true).getServerConfig()));
+        assertEquals("Server config", ImmutableSet.of(nonVotingServer(node1ID), votingServer(node2ID)),
+            new HashSet<>(node1RaftActor.getRaftActorContext().getPeerServerInfo(true).getServerConfig()));
         assertEquals("getRaftState", RaftState.Follower, node1RaftActor.getRaftState());
 
         LOG.info("testChangeToVotingWithNoLeaderAndElectionTimeout ending");
@@ -1463,7 +1464,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         ReplicatedLogEntry logEntry = log.get(log.lastIndex());
         assertEquals("Last log entry payload class", ServerConfigurationPayload.class, logEntry.getData().getClass());
         ServerConfigurationPayload payload = (ServerConfigurationPayload)logEntry.getData();
-        assertEquals("Server config", Sets.newHashSet(expected), Sets.newHashSet(payload.getServerConfig()));
+        assertEquals("Server config", ImmutableSet.copyOf(expected), new HashSet<>(payload.getServerConfig()));
     }
 
     private static RaftActorContextImpl newFollowerContext(final String id,
@@ -1590,8 +1591,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
     public static class MockNewFollowerRaftActor extends AbstractMockRaftActor {
         public MockNewFollowerRaftActor(final ConfigParams config, final ActorRef collectorActor) {
-            super(NEW_SERVER_ID, Maps.<String, String>newHashMap(), Optional.of(config), NO_PERSISTENCE,
-                    collectorActor);
+            super(NEW_SERVER_ID, new HashMap<>(), Optional.of(config), NO_PERSISTENCE, collectorActor);
             setPersistence(false);
         }
 
index e9bd04bf86ebb7016193aafe8addfa1d0da4b04c..662a063788fd522412d778eff71000bfcdaa9507 100644 (file)
@@ -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.utils;
 
 import akka.dispatch.Futures;
@@ -13,7 +12,6 @@ import akka.persistence.SelectedSnapshot;
 import akka.persistence.SnapshotMetadata;
 import akka.persistence.SnapshotSelectionCriteria;
 import akka.persistence.snapshot.japi.SnapshotStore;
-import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -59,7 +57,7 @@ public class InMemorySnapshotStore extends SnapshotStore {
 
         List<T> retList;
         synchronized (stored) {
-            retList = Lists.newArrayListWithCapacity(stored.size());
+            retList = new ArrayList<>(stored.size());
             for (StoredSnapshot s: stored) {
                 if (type.isInstance(s.data)) {
                     retList.add((T) s.data);
index 71b6593bb74734cd7d352c9161f02e137e080ce1..4d53384c8e4e80adfa3818de43cfeff41169027f 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.binding.compat;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.controller.sal.binding.api.NotificationListener;
 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.Notification;
@@ -25,7 +26,7 @@ abstract class AbstractNotificationListenerRegistration<T extends Notification>
     protected AbstractNotificationListenerRegistration(final Class<? extends Notification> type,
             final NotificationListener<T> listener) {
         super(listener);
-        this.type = Preconditions.checkNotNull(type);
+        this.type = requireNonNull(type);
     }
 
     @Override
index a0958083536559a50879b08410ca66504d4347c9..3fee8bf2b849371b5c79bfbbc575753516891d0e 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.binding.compat;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.controller.sal.binding.api.NotificationListener;
 import org.opendaylight.yangtools.yang.binding.Notification;
 
@@ -31,7 +32,7 @@ abstract class AggregatedNotificationListenerRegistration<N extends Notification
     protected AggregatedNotificationListenerRegistration(final Class<? extends Notification> type,
             final NotificationListener<N> listener, final A aggregator) {
         super(type, listener);
-        this.aggregator = Preconditions.checkNotNull(aggregator);
+        this.aggregator = requireNonNull(aggregator);
     }
 
     protected A getAggregator() {
index 2466b4917628fdbaa3ecd801269f8737b100c805..dc81ce085ed4671f042fd523cf623df875b6191d 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
@@ -32,11 +34,10 @@ abstract class AbstractForwardedTransaction<T extends AsyncTransaction<YangInsta
     private final BindingToNormalizedNodeCodec codec;
 
     AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
-        this.delegate = Preconditions.checkNotNull(delegateTx, "Delegate must not be null");
-        this.codec = Preconditions.checkNotNull(codec, "Codec must not be null");
+        this.delegate = requireNonNull(delegateTx, "Delegate must not be null");
+        this.codec = requireNonNull(codec, "Codec must not be null");
     }
 
-
     @Override
     public final  Object getIdentifier() {
         return delegate.getIdentifier();
index 13245db8451a86c4ab83a1b64c4e9c98344298b5..8d3b9c06e9011b30fdcb69c29a3438d3f27e2631 100644 (file)
@@ -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 java.util.Collection;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
@@ -24,16 +25,15 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
  */
 @Deprecated
 class BindingDOMDataTreeChangeListenerAdapter<T extends DataObject> implements DOMDataTreeChangeListener {
-
     private final BindingToNormalizedNodeCodec codec;
     private final DataTreeChangeListener<T> listener;
     private final LogicalDatastoreType store;
 
     BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec,
             final DataTreeChangeListener<T> listener, final LogicalDatastoreType store) {
-        this.codec = Preconditions.checkNotNull(codec);
-        this.listener = Preconditions.checkNotNull(listener);
-        this.store = Preconditions.checkNotNull(store);
+        this.codec = requireNonNull(codec);
+        this.listener = requireNonNull(listener);
+        this.store = requireNonNull(store);
     }
 
     @Override
index 5c488da005ed1a4745f353dfbcd39442f3352ae6..0c99a0e2ea5bd87dfcf6ced93fdf13670a24ead1 100644 (file)
@@ -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 org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService;
@@ -18,7 +19,6 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-
 /**
  * Adapter exposing Binding {@link DataTreeChangeService} and wrapping
  * {@link DOMDataTreeChangeService} and is responsible for translation
@@ -37,8 +37,8 @@ final class BindingDOMDataTreeChangeServiceAdapter implements DataTreeChangeServ
 
     private BindingDOMDataTreeChangeServiceAdapter(final BindingToNormalizedNodeCodec codec,
             final DOMDataTreeChangeService dataTreeChangeService) {
-        this.codec = Preconditions.checkNotNull(codec);
-        this.dataTreeChangeService = Preconditions.checkNotNull(dataTreeChangeService);
+        this.codec = requireNonNull(codec);
+        this.dataTreeChangeService = requireNonNull(dataTreeChangeService);
     }
 
     static DataTreeChangeService create(final BindingToNormalizedNodeCodec codec,
index b6210316c09181a9bb19ec42b055c049ef0bfca5..2551f7a4e74bf20d7fe3cb13ad0b565470313001 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.MoreExecutors;
@@ -40,10 +42,10 @@ final class BindingDOMTransactionChainAdapter implements BindingTransactionChain
 
     BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory,
             final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) {
-        Preconditions.checkNotNull(chainFactory, "DOM Transaction chain factory must not be null");
         this.domListener = new DelegateChainListener();
         this.bindingListener = listener;
-        this.delegate = chainFactory.createTransactionChain(domListener);
+        this.delegate = requireNonNull(chainFactory, "DOM Transaction chain factory must not be null")
+                .createTransactionChain(domListener);
         this.codec = codec;
     }
 
@@ -117,12 +119,10 @@ final class BindingDOMTransactionChainAdapter implements BindingTransactionChain
     }
 
     private final class DelegateChainListener implements TransactionChainListener {
-
         @Override
         public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
                 final AsyncTransaction<?, ?> transaction, final Throwable cause) {
-            Preconditions.checkState(delegate.equals(chain),
-                    "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain);
+            checkChain(chain);
             /*
              * Intentionally NOOP, callback for failure, since we
              * are also listening on each transaction future for failure,
@@ -130,17 +130,20 @@ final class BindingDOMTransactionChainAdapter implements BindingTransactionChain
              * of this transaction chain), instead of DOM transaction
              * which is known only to this chain, binding transaction implementation
              * and underlying transaction chain.
-             *
              */
             LOG.debug("Transaction chain {} failed. Failed DOM Transaction {}",this,transaction,cause);
         }
 
         @Override
         public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
-            Preconditions.checkState(delegate.equals(chain),
-                    "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain);
+            checkChain(chain);
             bindingListener.onTransactionChainSuccessful(BindingDOMTransactionChainAdapter.this);
         }
+
+        private void checkChain(final TransactionChain<?, ?> chain) {
+            checkState(delegate.equals(chain), "Illegal state - listener for %s was invoked for incorrect chain %s.",
+                delegate, chain);
+        }
     }
 
 }
index cdc2d35cd56b009797a0d8a36c011fbb617e4a1f..0b5c92d3c14e6f0db41e577d4c6f2c95e839bf6e 100644 (file)
@@ -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 org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -20,7 +21,7 @@ class BindingDataTreeChangeListenerRegistration<L extends DataTreeChangeListener
 
     BindingDataTreeChangeListenerRegistration(final L listener, final ListenerRegistration<?> domReg) {
         super(listener);
-        this.domReg = Preconditions.checkNotNull(domReg);
+        this.domReg = requireNonNull(domReg);
     }
 
     @Override
index 636f0b88b795d12afc9cf9d70650056eec388362..1acdd2467566105e4e05e2a0461c84807317f405 100644 (file)
@@ -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.base.Throwables;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -33,8 +34,8 @@ final class LazyDOMRpcResultFuture implements CheckedFuture<DOMRpcResult, DOMRpc
 
     private LazyDOMRpcResultFuture(final ListenableFuture<RpcResult<?>> delegate,
             final BindingNormalizedNodeSerializer codec) {
-        this.bindingFuture = Preconditions.checkNotNull(delegate, "delegate");
-        this.codec = Preconditions.checkNotNull(codec, "codec");
+        this.bindingFuture = requireNonNull(delegate, "delegate");
+        this.codec = requireNonNull(codec, "codec");
     }
 
     static CheckedFuture<DOMRpcResult, DOMRpcException> create(final BindingNormalizedNodeSerializer codec,
index 94b06e8e2ce5c60ecb38a861fd2d1f1c03389438..af2ad1dc5baea14cbd7dc064ba6aa42fafbff067 100644 (file)
@@ -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.collect.ImmutableMap;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
@@ -56,9 +57,9 @@ class RpcServiceAdapter implements InvocationHandler {
 
     RpcServiceAdapter(final Class<? extends RpcService> type, final BindingToNormalizedNodeCodec codec,
             final DOMRpcService domService) {
-        this.type = Preconditions.checkNotNull(type);
-        this.codec = Preconditions.checkNotNull(codec);
-        this.delegate = Preconditions.checkNotNull(domService);
+        this.type = requireNonNull(type);
+        this.codec = requireNonNull(codec);
+        this.delegate = requireNonNull(domService);
         final ImmutableMap.Builder<Method, RpcInvocationStrategy> rpcBuilder = ImmutableMap.builder();
         for (final Entry<Method, RpcDefinition> rpc : codec.getRpcMethodToSchema(type).entrySet()) {
             rpcBuilder.put(rpc.getKey(), createStrategy(rpc.getKey(), rpc.getValue()));
index 76457910fb9a1ec6e09d68edf9df87750252fb88..eaca3417aaeeadbcbda516a775fe3ab367b6fe6a 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.md.sal.binding.util;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.collect.MutableClassToInstanceMap;
@@ -31,35 +31,34 @@ public final class BindingContextUtils {
     private BindingContextUtils() {
     }
 
-    public static ConsumerContext createConsumerContext(BindingAwareConsumer consumer,
-            ClassToInstanceMap<BindingAwareService> serviceProvider) {
-        checkNotNull(consumer,"Consumer should not be null");
-        checkNotNull(serviceProvider,"Service map should not be null");
-        return new SingleConsumerContextImpl(serviceProvider);
+    public static ConsumerContext createConsumerContext(final BindingAwareConsumer consumer,
+            final ClassToInstanceMap<BindingAwareService> serviceProvider) {
+        requireNonNull(consumer, "Consumer should not be null");
+        return new SingleConsumerContextImpl(requireNonNull(serviceProvider, "Service map should not be null"));
     }
 
-    public static ProviderContext createProviderContext(BindingAwareProvider provider,
-            ClassToInstanceMap<BindingAwareService> serviceProvider) {
-        checkNotNull(provider,"Provider should not be null");
-        checkNotNull(serviceProvider,"Service map should not be null");
-        return new SingleProviderContextImpl(serviceProvider);
+    public static ProviderContext createProviderContext(final BindingAwareProvider provider,
+            final ClassToInstanceMap<BindingAwareService> serviceProvider) {
+        requireNonNull(provider, "Provider should not be null");
+        return new SingleProviderContextImpl(requireNonNull(serviceProvider, "Service map should not be null"));
     }
 
-    public static ConsumerContext createConsumerContextAndInitialize(BindingAwareConsumer consumer,
-            ClassToInstanceMap<BindingAwareService> serviceProvider) {
+    public static ConsumerContext createConsumerContextAndInitialize(final BindingAwareConsumer consumer,
+            final ClassToInstanceMap<BindingAwareService> serviceProvider) {
         ConsumerContext context = createConsumerContext(consumer, serviceProvider);
         consumer.onSessionInitialized(context);
         return context;
     }
 
-    public static ProviderContext createProviderContextAndInitialize(BindingAwareProvider provider,
-            ClassToInstanceMap<BindingAwareService> serviceProvider) {
+    public static ProviderContext createProviderContextAndInitialize(final BindingAwareProvider provider,
+            final ClassToInstanceMap<BindingAwareService> serviceProvider) {
         ProviderContext context = createProviderContext(provider, serviceProvider);
         provider.onSessionInitiated(context);
         return context;
     }
 
-    public static <T extends BindingAwareService> T createContextProxyOrReturnService(Class<T> service, T instance) {
+    public static <T extends BindingAwareService> T createContextProxyOrReturnService(final Class<T> service,
+            final T instance) {
         // FIXME: Create Proxy
         return instance;
     }
@@ -69,27 +68,27 @@ public final class BindingContextUtils {
         private ClassToInstanceMap<BindingAwareService> alreadyRetrievedServices;
         private ClassToInstanceMap<BindingAwareService> serviceProvider;
 
-        SingleConsumerContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
+        SingleConsumerContextImpl(final ClassToInstanceMap<BindingAwareService> serviceProvider) {
             this.alreadyRetrievedServices = MutableClassToInstanceMap.create();
             this.serviceProvider = serviceProvider;
         }
 
         @Override
-        public final <T extends RpcService> T getRpcService(Class<T> module) {
+        public final <T extends RpcService> T getRpcService(final Class<T> module) {
             return getSALService(RpcConsumerRegistry.class).getRpcService(module);
         }
 
         @Override
-        public final <T extends BindingAwareService> T getSALService(Class<T> service) {
-            checkNotNull(service,"Service class should not be null.");
-            T potential = alreadyRetrievedServices.getInstance(service);
+        public final <T extends BindingAwareService> T getSALService(final Class<T> service) {
+            T potential = alreadyRetrievedServices.getInstance(requireNonNull(service,
+                "Service class should not be null."));
             if (potential != null) {
                 return potential;
             }
             return tryToRetrieveSalService(service);
         }
 
-        private synchronized <T extends BindingAwareService> T tryToRetrieveSalService(Class<T> service) {
+        private synchronized <T extends BindingAwareService> T tryToRetrieveSalService(final Class<T> service) {
             final T potential = alreadyRetrievedServices.getInstance(service);
             if (potential != null) {
                 return potential;
@@ -111,26 +110,25 @@ public final class BindingContextUtils {
     }
 
     private static class SingleProviderContextImpl extends SingleConsumerContextImpl implements ProviderContext {
-
-        SingleProviderContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
+        SingleProviderContextImpl(final ClassToInstanceMap<BindingAwareService> serviceProvider) {
             super(serviceProvider);
         }
 
         @Override
         public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
-                registerRouteChangeListener(L listener) {
+                registerRouteChangeListener(final L listener) {
             return getSALService(RpcProviderRegistry.class).registerRouteChangeListener(listener);
         }
 
         @Override
-        public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type,
-                T implementation) throws IllegalStateException {
+        public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type,
+                final T implementation) {
             return getSALService(RpcProviderRegistry.class).addRoutedRpcImplementation(type, implementation);
         }
 
         @Override
-        public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
-                throws IllegalStateException {
+        public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type,
+                final T implementation) {
             return getSALService(RpcProviderRegistry.class).addRpcImplementation(type, implementation);
         }
     }
index aaa9ad6c81a57d917ed2db687be9880740bbf067..62043e24c34d446c9436566fcc6b78ed1dc256cb 100644 (file)
@@ -5,10 +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.common.actor;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import scala.concurrent.ExecutionContext;
 
 public class Dispatchers {
@@ -50,8 +50,7 @@ public class Dispatchers {
     }
 
     public Dispatchers(final akka.dispatch.Dispatchers dispatchers) {
-        Preconditions.checkNotNull(dispatchers, "dispatchers should not be null");
-        this.dispatchers = dispatchers;
+        this.dispatchers = requireNonNull(dispatchers, "dispatchers should not be null");
     }
 
     public ExecutionContext getDispatcher(final DispatcherType dispatcherType) {
index a4e0b70a0216abb66af500c45bcfaff90d5bd869..0bf1a2fe01fbba2d693832a0a1a66d2e8042da02 100644 (file)
@@ -5,12 +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.datastore.node.utils;
 
-import com.google.common.base.Preconditions;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MixinNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -21,30 +19,26 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
  */
 public class NormalizedNodeNavigator {
 
-    private final org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeVisitor visitor;
+    private final NormalizedNodeVisitor visitor;
 
-    public NormalizedNodeNavigator(
-            org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeVisitor visitor) {
-        Preconditions.checkNotNull(visitor, "visitor should not be null");
-        this.visitor = visitor;
+    public NormalizedNodeNavigator(final NormalizedNodeVisitor visitor) {
+        this.visitor = requireNonNull(visitor, "visitor should not be null");
     }
 
-    public void navigate(String parentPath, NormalizedNode<?, ?> normalizedNode) {
+    public void navigate(String parentPath, final NormalizedNode<?, ?> normalizedNode) {
         if (parentPath == null) {
             parentPath = "";
         }
         navigateNormalizedNode(0, parentPath, normalizedNode);
     }
 
-    private void navigateDataContainerNode(int level, final String parentPath,
+    private void navigateDataContainerNode(final int level, final String parentPath,
             final DataContainerNode<?> dataContainerNode) {
         visitor.visitNode(level, parentPath, dataContainerNode);
 
         String newParentPath = parentPath + "/" + dataContainerNode.getIdentifier().toString();
 
-        final Iterable<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> value = dataContainerNode
-                .getValue();
-        for (NormalizedNode<?, ?> node : value) {
+        for (NormalizedNode<?, ?> node : dataContainerNode.getValue()) {
             if (node instanceof MixinNode && node instanceof NormalizedNodeContainer) {
                 navigateNormalizedNodeContainerMixin(level, newParentPath, (NormalizedNodeContainer<?, ?, ?>) node);
             } else {
@@ -54,14 +48,13 @@ public class NormalizedNodeNavigator {
 
     }
 
-    private void navigateNormalizedNodeContainerMixin(int level, final String parentPath,
-            NormalizedNodeContainer<?, ?, ?> node) {
+    private void navigateNormalizedNodeContainerMixin(final int level, final String parentPath,
+            final NormalizedNodeContainer<?, ?, ?> node) {
         visitor.visitNode(level, parentPath, node);
 
         String newParentPath = parentPath + "/" + node.getIdentifier().toString();
 
-        final Iterable<? extends NormalizedNode<?, ?>> value = node.getValue();
-        for (NormalizedNode<?, ?> normalizedNode : value) {
+        for (NormalizedNode<?, ?> normalizedNode : node.getValue()) {
             if (normalizedNode instanceof MixinNode && normalizedNode instanceof NormalizedNodeContainer) {
                 navigateNormalizedNodeContainerMixin(level + 1, newParentPath,
                         (NormalizedNodeContainer<?, ?, ?>) normalizedNode);
@@ -72,7 +65,8 @@ public class NormalizedNodeNavigator {
 
     }
 
-    private void navigateNormalizedNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) {
+    private void navigateNormalizedNode(final int level, final String parentPath,
+            final NormalizedNode<?, ?> normalizedNode) {
         if (normalizedNode instanceof DataContainerNode) {
 
             final DataContainerNode<?> dataContainerNode = (DataContainerNode<?>) normalizedNode;
index 161a450ddc6b7993f49f4f6ff97ecad2ee0b0df2..863fd0c8af94f6cc9ed26a073feb5ca3e7eca94f 100755 (executable)
@@ -7,7 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -47,7 +50,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
     private boolean inSimple;
 
     AbstractNormalizedNodeDataOutput(final DataOutput output) {
-        this.output = Preconditions.checkNotNull(output);
+        this.output = requireNonNull(output);
     }
 
     private void ensureHeaderWritten() throws IOException {
@@ -162,7 +165,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startLeafNode(final NodeIdentifier name) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
         LOG.trace("Starting a new leaf node");
         startNode(name.getNodeType(), NodeTypes.LEAF_NODE);
         inSimple = true;
@@ -170,7 +173,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
         LOG.trace("Starting a new leaf set");
 
         lastLeafSetQName = name.getNodeType();
@@ -179,7 +182,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
         LOG.trace("Starting a new ordered leaf set");
 
         lastLeafSetQName = name.getNodeType();
@@ -202,7 +205,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
 
         LOG.trace("Starting a new container node");
 
@@ -211,7 +214,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startYangModeledAnyXmlNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
 
         LOG.trace("Starting a new yang modeled anyXml node");
 
@@ -220,7 +223,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
         LOG.trace("Starting a new unkeyed list");
 
         startNode(name.getNodeType(), NodeTypes.UNKEYED_LIST);
@@ -228,7 +231,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
         LOG.trace("Starting a new unkeyed list item");
 
         startNode(name.getNodeType(), NodeTypes.UNKEYED_LIST_ITEM);
@@ -236,7 +239,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
         LOG.trace("Starting a new map node");
 
         startNode(name.getNodeType(), NodeTypes.MAP_NODE);
@@ -245,7 +248,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
     @Override
     public void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint)
             throws IOException {
-        Preconditions.checkNotNull(identifier, "Node identifier should not be null");
+        requireNonNull(identifier, "Node identifier should not be null");
         LOG.trace("Starting a new map entry node");
         startNode(identifier.getNodeType(), NodeTypes.MAP_ENTRY_NODE);
 
@@ -254,7 +257,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
         LOG.trace("Starting a new ordered map node");
 
         startNode(name.getNodeType(), NodeTypes.ORDERED_MAP_NODE);
@@ -262,7 +265,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startChoiceNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
         LOG.trace("Starting a new choice node");
 
         startNode(name.getNodeType(), NodeTypes.CHOICE_NODE);
@@ -270,7 +273,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startAugmentationNode(final AugmentationIdentifier identifier) throws IOException {
-        Preconditions.checkNotNull(identifier, "Node identifier should not be null");
+        requireNonNull(identifier, "Node identifier should not be null");
         LOG.trace("Starting a new augmentation node");
 
         output.writeByte(NodeTypes.AUGMENTATION_NODE);
@@ -279,7 +282,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
 
     @Override
     public void startAnyxmlNode(final NodeIdentifier name) throws IOException {
-        Preconditions.checkNotNull(name, "Node identifier should not be null");
+        requireNonNull(name, "Node identifier should not be null");
         LOG.trace("Starting any xml node");
         startNode(name.getNodeType(), NodeTypes.ANY_XML_NODE);
         inSimple = true;
@@ -324,8 +327,8 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
     }
 
     private void startNode(final QName qname, final byte nodeType) throws IOException {
-        Preconditions.checkNotNull(qname, "QName of node identifier should not be null.");
-        Preconditions.checkState(!inSimple, "Attempted to start a child in a simple node");
+        requireNonNull(qname, "QName of node identifier should not be null.");
+        checkState(!inSimple, "Attempted to start a child in a simple node");
 
         ensureHeaderWritten();
 
@@ -338,9 +341,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut
     private void writeObjSet(final Set<?> set) throws IOException {
         output.writeInt(set.size());
         for (Object o : set) {
-            Preconditions.checkArgument(o instanceof String, "Expected value type to be String but was %s (%s)",
-                o.getClass(), o);
-
+            checkArgument(o instanceof String, "Expected value type to be String but was %s (%s)", o.getClass(), o);
             writeString((String) o);
         }
     }
index b136ed7086d399b028a2a77252b2dce5be4544c7..9df2fd4d3276765634ec859a9e3fbfcdf724b0b2 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.messaging;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -26,7 +27,7 @@ class AbortSlicing implements Serializable {
     private final Identifier identifier;
 
     AbortSlicing(final Identifier identifier) {
-        this.identifier = Preconditions.checkNotNull(identifier);
+        this.identifier = requireNonNull(identifier);
     }
 
     Identifier getIdentifier() {
@@ -53,17 +54,17 @@ class AbortSlicing implements Serializable {
         public Proxy() {
         }
 
-        Proxy(AbortSlicing abortSlicing) {
+        Proxy(final AbortSlicing abortSlicing) {
             this.abortSlicing = abortSlicing;
         }
 
         @Override
-        public void writeExternal(ObjectOutput out) throws IOException {
+        public void writeExternal(final ObjectOutput out) throws IOException {
             out.writeObject(abortSlicing.identifier);
         }
 
         @Override
-        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
             abortSlicing = new AbortSlicing((Identifier) in.readObject());
         }
 
index ae711df74a88ceb5e9cfe20fdf4428c7d8efa70d..50e0460836c8a7b409fa2c21b265fb6944737a6e 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.controller.cluster.messaging;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.serialization.JavaSerializer;
 import akka.serialization.Serialization;
-import com.google.common.base.Preconditions;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.Externalizable;
 import java.io.IOException;
@@ -34,14 +35,14 @@ public class MessageSlice implements Serializable {
     private final int lastSliceHashCode;
     private final ActorRef replyTo;
 
-    MessageSlice(Identifier identifier, byte[] data, int sliceIndex, int totalSlices, int lastSliceHashCode,
-            final ActorRef replyTo) {
-        this.identifier = Preconditions.checkNotNull(identifier);
-        this.data = Preconditions.checkNotNull(data);
+    MessageSlice(final Identifier identifier, final byte[] data, final int sliceIndex, final int totalSlices,
+            final int lastSliceHashCode, final ActorRef replyTo) {
+        this.identifier = requireNonNull(identifier);
+        this.data = requireNonNull(data);
         this.sliceIndex = sliceIndex;
         this.totalSlices = totalSlices;
         this.lastSliceHashCode = lastSliceHashCode;
-        this.replyTo = Preconditions.checkNotNull(replyTo);
+        this.replyTo = requireNonNull(replyTo);
     }
 
     public Identifier getIdentifier() {
@@ -93,12 +94,12 @@ public class MessageSlice implements Serializable {
         public Proxy() {
         }
 
-        Proxy(MessageSlice messageSlice) {
+        Proxy(final MessageSlice messageSlice) {
             this.messageSlice = messageSlice;
         }
 
         @Override
-        public void writeExternal(ObjectOutput out) throws IOException {
+        public void writeExternal(final ObjectOutput out) throws IOException {
             out.writeObject(messageSlice.identifier);
             out.writeInt(messageSlice.sliceIndex);
             out.writeInt(messageSlice.totalSlices);
@@ -108,7 +109,7 @@ public class MessageSlice implements Serializable {
         }
 
         @Override
-        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
             Identifier identifier = (Identifier) in.readObject();
             int sliceIndex = in.readInt();
             int totalSlices = in.readInt();
index f81cbb00a11085b95fd8228d7b09e7c48825f92b..0cc36689bb9b470b728732d2eb1f0efef446338a 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.messaging;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -34,7 +35,7 @@ final class MessageSliceIdentifier implements Identifier {
     }
 
     private MessageSliceIdentifier(final Identifier clientIdentifier, final long slicerId, final long messageId) {
-        this.clientIdentifier = Preconditions.checkNotNull(clientIdentifier);
+        this.clientIdentifier = requireNonNull(clientIdentifier);
         this.messageId = messageId;
         this.slicerId = slicerId;
     }
@@ -58,7 +59,7 @@ final class MessageSliceIdentifier implements Identifier {
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
@@ -93,18 +94,18 @@ final class MessageSliceIdentifier implements Identifier {
         public Proxy() {
         }
 
-        Proxy(MessageSliceIdentifier messageSliceId) {
+        Proxy(final MessageSliceIdentifier messageSliceId) {
             this.messageSliceId = messageSliceId;
         }
 
         @Override
-        public void writeExternal(ObjectOutput out) throws IOException {
+        public void writeExternal(final ObjectOutput out) throws IOException {
             out.writeObject(messageSliceId.clientIdentifier);
             WritableObjects.writeLongs(out, messageSliceId.slicerId, messageSliceId.messageId);
         }
 
         @Override
-        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
             final Identifier clientIdentifier = (Identifier) in.readObject();
             final byte header = WritableObjects.readLongHeader(in);
             final long slicerId =  WritableObjects.readFirstLong(in, header);
index bfcfdede850bdd3a273e72d7c8865e164b3a5040..e820c4ba3f881c57a821cfd706ecd5fd12504b66 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.controller.cluster.messaging;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.serialization.JavaSerializer;
 import akka.serialization.Serialization;
-import com.google.common.base.Preconditions;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -34,9 +35,9 @@ public final class MessageSliceReply implements Serializable {
 
     private MessageSliceReply(final Identifier identifier, final int sliceIndex, final MessageSliceException failure,
             final ActorRef sendTo) {
-        this.identifier = Preconditions.checkNotNull(identifier);
+        this.identifier = requireNonNull(identifier);
         this.sliceIndex = sliceIndex;
-        this.sendTo = Preconditions.checkNotNull(sendTo);
+        this.sendTo = requireNonNull(sendTo);
         this.failure = failure;
     }
 
index 6bae647cb7a43a1ef000961b48333104f7f6857a..9ba69fb65580fdf4da1960960dbdb9031baa4669 100644 (file)
@@ -7,9 +7,11 @@
  */
 package org.opendaylight.controller.cluster.messaging;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
-import com.google.common.base.Preconditions;
 import java.io.Serializable;
 import java.util.function.Consumer;
 import org.opendaylight.controller.cluster.io.FileBackedOutputStream;
@@ -174,23 +176,23 @@ public final class SliceOptions {
         public SliceOptions build() {
             sealed = true;
 
-            Preconditions.checkNotNull(identifier, "identifier must be set");
-            Preconditions.checkNotNull(replyTo, "replyTo must be set");
-            Preconditions.checkNotNull(onFailureCallback, "onFailureCallback must be set");
-            Preconditions.checkState(fileBackedStream == null || message == null,
+            requireNonNull(identifier, "identifier must be set");
+            requireNonNull(replyTo, "replyTo must be set");
+            requireNonNull(onFailureCallback, "onFailureCallback must be set");
+            checkState(fileBackedStream == null || message == null,
                     "Only one of message and fileBackedStream can be set");
-            Preconditions.checkState(!(fileBackedStream == null && message == null),
+            checkState(!(fileBackedStream == null && message == null),
                     "One of message and fileBackedStream must be set");
-            Preconditions.checkState(sendToRef == null || sendToSelection == null,
+            checkState(sendToRef == null || sendToSelection == null,
                     "Only one of sendToRef and sendToSelection can be set");
-            Preconditions.checkState(!(sendToRef == null && sendToSelection == null),
+            checkState(!(sendToRef == null && sendToSelection == null),
                     "One of sendToRef and sendToSelection must be set");
 
             return new SliceOptions(this);
         }
 
         protected void checkSealed() {
-            Preconditions.checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
+            checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
         }
     }
 }
index 89f9dd12e050aab2e99da50cf1e945a2fccf4ab5..bb4ad65f161f11bb57e5d263cdc17b41a2e0bc57 100644 (file)
@@ -5,14 +5,13 @@
  * 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.notifications;
 
 import akka.actor.ActorPath;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.serialization.Serialization;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
 import java.util.Map;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 
@@ -26,11 +25,11 @@ import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 public class RoleChangeNotifier extends AbstractUntypedActor implements AutoCloseable {
 
     private final String memberId;
-    private final Map<ActorPath, ActorRef> registeredListeners = Maps.newHashMap();
+    private final Map<ActorPath, ActorRef> registeredListeners = new HashMap<>();
     private RoleChangeNotification latestRoleChangeNotification = null;
     private LeaderStateChanged latestLeaderStateChanged;
 
-    public RoleChangeNotifier(String memberId) {
+    public RoleChangeNotifier(final String memberId) {
         this.memberId = memberId;
     }
 
@@ -46,7 +45,7 @@ public class RoleChangeNotifier extends AbstractUntypedActor implements AutoClos
     }
 
     @Override
-    protected void handleReceive(Object message) {
+    protected void handleReceive(final Object message) {
         if (message instanceof RegisterRoleChangeListener) {
             // register listeners for this shard
 
index bc393dde4fd8561829007d30b0794a105c98eb22..38ef5d8ff45f1380dceaec5f6c6a71e27a00dd5c 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.common.api.data;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.opendaylight.yangtools.concepts.Path;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
@@ -41,12 +42,12 @@ public class DataValidationFailedException extends TransactionCommitFailedExcept
                                                              final String message, final Throwable cause) {
         super(message, cause, RpcResultBuilder.newError(ErrorType.APPLICATION, "invalid-value", message, null,
                                                         path != null ? path.toString() : null, cause));
-        this.pathType = Preconditions.checkNotNull(pathType, "path type must not be null");
-        this.path = Preconditions.checkNotNull(path,"path must not be null.");
+        this.pathType = requireNonNull(pathType, "path type must not be null");
+        this.path = requireNonNull(path,"path must not be null.");
     }
 
-    public  <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,
-                                                              final String message) {
+    public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,
+                                                             final String message) {
         this(pathType, path, message, null);
     }
 
index 1d661eb32a57bc7333126020e9729d1eb520d383..2e66571cea712bb50804a9f4b72b5415203e33f5 100644 (file)
@@ -5,11 +5,13 @@
  * 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.databroker;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.Futures;
 import java.util.ArrayList;
@@ -67,7 +69,7 @@ public abstract class AbstractDOMBrokerWriteTransaction<T extends DOMStoreWriteT
             final Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories,
             final AbstractDOMTransactionFactory<?> commitImpl) {
         super(identifier, storeTxFactories);
-        this.commitImpl = Preconditions.checkNotNull(commitImpl, "commitImpl must not be null.");
+        this.commitImpl = requireNonNull(commitImpl, "commitImpl must not be null.");
     }
 
     @Override
@@ -80,10 +82,9 @@ public abstract class AbstractDOMBrokerWriteTransaction<T extends DOMStoreWriteT
 
     private static void checkInstanceIdentifierReferencesData(final YangInstanceIdentifier path,
             final NormalizedNode<?, ?> data) {
-        Preconditions.checkArgument(data != null, "Attempted to store null data at %s", path);
+        checkArgument(data != null, "Attempted to store null data at %s", path);
         final PathArgument lastArg = path.getLastPathArgument();
-        Preconditions.checkArgument(
-                lastArg == data.getIdentifier() || lastArg != null && lastArg.equals(data.getIdentifier()),
+        checkArgument(lastArg == data.getIdentifier() || lastArg != null && lastArg.equals(data.getIdentifier()),
                 "Instance identifier references %s but data identifier is %s", lastArg, data);
     }
 
@@ -147,7 +148,7 @@ public abstract class AbstractDOMBrokerWriteTransaction<T extends DOMStoreWriteT
     }
 
     private void checkRunning(final AbstractDOMTransactionFactory<?> impl) {
-        Preconditions.checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
+        checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
     }
 
     @Override
index ea6948f85984fae1224ebd3dd2c8e7a5925222ad..9ee43f20bb585031911ca0209bebbe083f2fce5a 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction;
 
@@ -22,7 +23,7 @@ abstract class AbstractShardedTransaction implements DOMStoreTransaction {
     private final ClientTransaction tx;
 
     AbstractShardedTransaction(final ClientTransaction tx) {
-        this.tx = Preconditions.checkNotNull(tx);
+        this.tx = requireNonNull(tx);
     }
 
     @Override
index 1199fbf7bca4a4c5f60485690b4e82eb37ca062f..cdcae3ddff461b8b74a271046093535db0b7b9cf 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
 import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER;
 import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER;
 import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.AbstractFuture;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
@@ -68,8 +69,8 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     public ConcurrentDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores,
             final Executor listenableFutureExecutor, final DurationStatisticsTracker commitStatsTracker) {
         super(datastores);
-        this.clientFutureCallbackExecutor = Preconditions.checkNotNull(listenableFutureExecutor);
-        this.commitStatsTracker = Preconditions.checkNotNull(commitStatsTracker);
+        this.clientFutureCallbackExecutor = requireNonNull(listenableFutureExecutor);
+        this.commitStatsTracker = requireNonNull(commitStatsTracker);
     }
 
     public DurationStatisticsTracker getCommitStatsTracker() {
@@ -77,11 +78,11 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     }
 
     @Override
-    protected FluentFuture<? extends CommitInfo> commit(
-            final DOMDataTreeWriteTransaction transaction, final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
+    protected FluentFuture<? extends CommitInfo> commit(final DOMDataTreeWriteTransaction transaction,
+            final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
 
-        Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
-        Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
+        checkArgument(transaction != null, "Transaction must not be null.");
+        checkArgument(cohorts != null, "Cohorts must not be null.");
         LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
 
         if (cohorts.isEmpty()) {
@@ -262,7 +263,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
         private final Executor listenerExecutor;
 
         AsyncNotifyingSettableFuture(final Executor listenerExecutor) {
-            this.listenerExecutor = Preconditions.checkNotNull(listenerExecutor);
+            this.listenerExecutor = requireNonNull(listenerExecutor);
         }
 
         @Override
@@ -303,8 +304,8 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
             private final Executor executor;
 
             DelegatingRunnable(final Runnable delegate, final Executor executor) {
-                this.delegate = Preconditions.checkNotNull(delegate);
-                this.executor = Preconditions.checkNotNull(executor);
+                this.delegate = requireNonNull(delegate);
+                this.executor = requireNonNull(executor);
             }
 
             @Override
index 1f1ea7fd9274f823a80005d998436b10eb65a977..537aa46a82a3a6611dbc1f165e39d5093c12c898 100644 (file)
@@ -8,7 +8,9 @@
 
 package org.opendaylight.controller.cluster.databroker;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.MoreExecutors;
@@ -65,12 +67,12 @@ final class DOMBrokerTransactionChain extends AbstractDOMTransactionFactory<DOMS
             final AbstractDOMBroker broker, final DOMTransactionChainListener listener) {
         super(chains);
         this.chainId = chainId;
-        this.broker = Preconditions.checkNotNull(broker);
-        this.listener = Preconditions.checkNotNull(listener);
+        this.broker = requireNonNull(broker);
+        this.listener = requireNonNull(listener);
     }
 
     private void checkNotFailed() {
-        Preconditions.checkState(state != State.FAILED, "Transaction chain has failed");
+        checkState(state != State.FAILED, "Transaction chain has failed");
     }
 
     @Override
index 5111a32fd3cc1f866c3e4899bc98ca9f00f3f703..4f19381edd78afb3356a3a935e08d102181719d1 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ForwardingObject;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
@@ -23,7 +24,7 @@ final class DOMStoreThreePhaseCommitCohortAdaptor extends ForwardingObject imple
 
     DOMStoreThreePhaseCommitCohortAdaptor(
         final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort delegate) {
-        this.delegate = Preconditions.checkNotNull(delegate);
+        this.delegate = requireNonNull(delegate);
     }
 
     @Override
index 80fbf037647d7a3065765079cd31abc16063c4c4..1246c2f7c740a3a6fa4a9183cf6320d989934cbd 100644 (file)
@@ -7,9 +7,11 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -49,8 +51,8 @@ public abstract class AbstractClientHandle<T extends AbstractProxyTransaction> e
 
     // Hidden to prevent outside instantiation
     AbstractClientHandle(final AbstractClientHistory parent, final TransactionIdentifier transactionId) {
-        this.transactionId = Preconditions.checkNotNull(transactionId);
-        this.parent = Preconditions.checkNotNull(parent);
+        this.transactionId = requireNonNull(transactionId);
+        this.parent = requireNonNull(parent);
     }
 
     @Override
@@ -114,7 +116,7 @@ public abstract class AbstractClientHandle<T extends AbstractProxyTransaction> e
 
     private State<T> getState() {
         final State<T> local = state;
-        Preconditions.checkState(local != null, "Transaction %s is closed", transactionId);
+        checkState(local != null, "Transaction %s is closed", transactionId);
         return local;
     }
 
index 789309cf8a3d6d1b328e6a0f6bfc50b2ac07ddd9..b2f66d5d31b1952c639c6cc3b24d34bcd5d0b1be 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
@@ -28,8 +29,8 @@ abstract class AbstractTransactionCommitCohort implements DOMStoreThreePhaseComm
     private final TransactionIdentifier txId;
 
     AbstractTransactionCommitCohort(final AbstractClientHistory parent, final TransactionIdentifier txId) {
-        this.parent = Preconditions.checkNotNull(parent);
-        this.txId = Preconditions.checkNotNull(txId);
+        this.parent = requireNonNull(parent);
+        this.txId = requireNonNull(txId);
     }
 
     final void complete() {
index 26e346e77cb4e0a0a19b6c66b5f5903d141a4803..52bf1d930fd71b9cca62a3a4669c4c7760e155eb 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Maps;
 import java.util.Collection;
@@ -46,7 +47,7 @@ final class BouncingReconnectForwarder extends ReconnectForwarder {
     private BouncingReconnectForwarder(final ConnectedClientConnection<?> successor,
             final Map<LocalHistoryIdentifier, ProxyReconnectCohort> cohorts) {
         super(successor);
-        this.cohorts = Preconditions.checkNotNull(cohorts);
+        this.cohorts = requireNonNull(cohorts);
     }
 
     static ReconnectForwarder forCohorts(final ConnectedClientConnection<?> successor,
index 41d2cb8cd1bba38c28b3da89ac2d8dad680e758e..933d4bb47b131eee8047bbed212ef221534d771e 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Arrays;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -24,7 +26,7 @@ final class ClientTransactionCursor implements DOMDataTreeWriteCursor {
     private final ClientTransaction parent;
 
     ClientTransactionCursor(final ClientTransaction parent) {
-        this.parent = Preconditions.checkNotNull(parent);
+        this.parent = requireNonNull(parent);
     }
 
     @Override
@@ -45,7 +47,7 @@ final class ClientTransactionCursor implements DOMDataTreeWriteCursor {
     @Override
     public void exit() {
         final YangInstanceIdentifier currentParent = current.getParent();
-        Preconditions.checkState(currentParent != null);
+        checkState(currentParent != null);
         current = currentParent;
     }
 
index 1d5d4a70dedac1c10122ad991ac3c3ae3f9f1507..9b21b98682bf71a7e807985dba4f0f5c7e586832 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
@@ -23,7 +24,7 @@ final class DirectTransactionCommitCohort extends AbstractTransactionCommitCohor
     DirectTransactionCommitCohort(final AbstractClientHistory parent, final TransactionIdentifier txId,
         final AbstractProxyTransaction proxy) {
         super(parent, txId);
-        this.proxy = Preconditions.checkNotNull(proxy);
+        this.proxy = requireNonNull(proxy);
     }
 
     @Override
index db9142474720fea4b37d8cc55a85e686afc5a14f..7d9d74d8ea5ede282c50d7d149072b12e59cd99a 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
 
 /**
  * Request the ClientIdentifier from a particular actor. Response is an instance of {@link DataStoreClient}.
@@ -19,7 +20,7 @@ final class GetClientRequest {
     private final ActorRef replyTo;
 
     GetClientRequest(final ActorRef replyTo) {
-        this.replyTo = Preconditions.checkNotNull(replyTo);
+        this.replyTo = requireNonNull(replyTo);
     }
 
     ActorRef getReplyTo() {
index 143cc8bf60d14c58f432b399f3fb487aca492e27..6edbf6ca0de5bfe371b9460c956057bc1c5928a4 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.controller.cluster.databroker.actors.dds;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FluentFuture;
 import java.util.Optional;
 import java.util.function.Consumer;
@@ -109,7 +108,7 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
             final Optional<NormalizedNode<?, ?>> result = readOnlyView().readNode(path);
             if (callback != null) {
                 // XXX: FB does not see that callback is final, on stack and has be check for non-null.
-                final Consumer<Response<?, ?>> fbIsStupid = Preconditions.checkNotNull(callback);
+                final Consumer<Response<?, ?>> fbIsStupid = requireNonNull(callback);
                 executeInActor(() -> fbIsStupid.accept(new ReadTransactionSuccess(request.getTarget(),
                     request.getSequence(), result)));
             }
@@ -119,7 +118,7 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
             final boolean result = readOnlyView().readNode(path).isPresent();
             if (callback != null) {
                 // XXX: FB does not see that callback is final, on stack and has be check for non-null.
-                final Consumer<Response<?, ?>> fbIsStupid = Preconditions.checkNotNull(callback);
+                final Consumer<Response<?, ?>> fbIsStupid = requireNonNull(callback);
                 executeInActor(() -> fbIsStupid.accept(new ExistsTransactionSuccess(request.getTarget(),
                     request.getSequence(), result)));
             }
index e136d50e02fc0c60f1eb3c0a44f824aed0b77615..01fc35c395656896ba59e668134429875cc13508 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Range;
 import com.google.common.collect.RangeSet;
@@ -60,10 +61,10 @@ abstract class AbstractFrontendHistory implements Identifiable<LocalHistoryIdent
 
     AbstractFrontendHistory(final String persistenceId, final ShardDataTree tree,
         final Map<UnsignedLong, Boolean> closedTransactions, final RangeSet<UnsignedLong> purgedTransactions) {
-        this.persistenceId = Preconditions.checkNotNull(persistenceId);
-        this.tree = Preconditions.checkNotNull(tree);
-        this.closedTransactions = Preconditions.checkNotNull(closedTransactions);
-        this.purgedTransactions = Preconditions.checkNotNull(purgedTransactions);
+        this.persistenceId = requireNonNull(persistenceId);
+        this.tree = requireNonNull(tree);
+        this.closedTransactions = requireNonNull(closedTransactions);
+        this.purgedTransactions = requireNonNull(purgedTransactions);
     }
 
     final String persistenceId() {
index 9412d47b510bfe82063c295a90f1c2e5f1d52f2d..bec1a38f2453790d6a80e786e1be7d3dfa6c560b 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.persisted.AbortTransactionPayload;
 import org.opendaylight.yangtools.concepts.Identifiable;
@@ -29,9 +31,9 @@ abstract class AbstractShardDataTreeTransaction<T extends DataTreeSnapshot>
 
     AbstractShardDataTreeTransaction(final ShardDataTreeTransactionParent parent, final TransactionIdentifier id,
         final T snapshot) {
-        this.parent = Preconditions.checkNotNull(parent);
-        this.snapshot = Preconditions.checkNotNull(snapshot);
-        this.id = Preconditions.checkNotNull(id);
+        this.parent = requireNonNull(parent);
+        this.snapshot = requireNonNull(snapshot);
+        this.id = requireNonNull(id);
     }
 
     @Override
@@ -66,7 +68,7 @@ abstract class AbstractShardDataTreeTransaction<T extends DataTreeSnapshot>
     }
 
     final void abort(final Runnable callback) {
-        Preconditions.checkState(close(), "Transaction is already closed");
+        checkState(close(), "Transaction is already closed");
         parent.abortTransaction(this, callback);
     }
 
index 2cb4dee3749ce7195851a44ad543ca2b345f901b..1f87fd4259e1ae0e90bade6c153672eedf4ed6b4 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.FutureCallback;
 import java.util.Optional;
@@ -27,9 +28,9 @@ final class ChainedCommitCohort extends ShardDataTreeCohort {
 
     ChainedCommitCohort(final ShardDataTreeTransactionChain chain, final ReadWriteShardDataTreeTransaction transaction,
             final ShardDataTreeCohort delegate) {
-        this.transaction = Preconditions.checkNotNull(transaction);
-        this.delegate = Preconditions.checkNotNull(delegate);
-        this.chain = Preconditions.checkNotNull(chain);
+        this.transaction = requireNonNull(transaction);
+        this.delegate = requireNonNull(delegate);
+        this.chain = requireNonNull(chain);
     }
 
     @Override
index 38d23f6884ca949e121579da0fb669391ffc058e..be162d9304ee205d5fde8afee03f72d822d81296 100644 (file)
@@ -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.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.Address;
 import akka.cluster.Cluster;
 import akka.cluster.ClusterEvent;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 
 public class ClusterWrapperImpl implements ClusterWrapper {
@@ -21,12 +22,10 @@ public class ClusterWrapperImpl implements ClusterWrapper {
     private final MemberName currentMemberName;
     private final Address selfAddress;
 
-    public ClusterWrapperImpl(ActorSystem actorSystem) {
-        Preconditions.checkNotNull(actorSystem, "actorSystem should not be null");
+    public ClusterWrapperImpl(final ActorSystem actorSystem) {
+        cluster = Cluster.get(requireNonNull(actorSystem, "actorSystem should not be null"));
 
-        cluster = Cluster.get(actorSystem);
-
-        Preconditions.checkState(cluster.getSelfRoles().size() > 0,
+        checkState(cluster.getSelfRoles().size() > 0,
             "No akka roles were specified.\n"
             + "One way to specify the member name is to pass a property on the command line like so\n"
             + "   -Dakka.cluster.roles.0=member-3\n"
@@ -37,10 +36,8 @@ public class ClusterWrapperImpl implements ClusterWrapper {
     }
 
     @Override
-    public void subscribeToMemberEvents(ActorRef actorRef) {
-        Preconditions.checkNotNull(actorRef, "actorRef should not be null");
-
-        cluster.subscribe(actorRef, ClusterEvent.initialStateAsEvents(),
+    public void subscribeToMemberEvents(final ActorRef actorRef) {
+        cluster.subscribe(requireNonNull(actorRef, "actorRef should not be null"), ClusterEvent.initialStateAsEvents(),
             ClusterEvent.MemberEvent.class,
             ClusterEvent.UnreachableMember.class,
             ClusterEvent.ReachableMember.class);
index 80ba952abb926fff45d9864bf521d59925aea911..6c0c13b3abfd6dec5ca89b1014f095e4e87c468a 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
 import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.FutureCallback;
 import java.util.List;
@@ -35,13 +37,13 @@ final class CohortEntry {
 
     private CohortEntry(final ReadWriteShardDataTreeTransaction transaction, final short clientVersion) {
         this.cohort = null;
-        this.transaction = Preconditions.checkNotNull(transaction);
+        this.transaction = requireNonNull(transaction);
         this.transactionId = transaction.getIdentifier();
         this.clientVersion = clientVersion;
     }
 
     private CohortEntry(final ShardDataTreeCohort cohort, final short clientVersion) {
-        this.cohort = Preconditions.checkNotNull(cohort);
+        this.cohort = requireNonNull(cohort);
         this.transactionId = cohort.getIdentifier();
         this.transaction = null;
         this.clientVersion = clientVersion;
@@ -120,7 +122,7 @@ final class CohortEntry {
     }
 
     void ready(final Optional<SortedSet<String>> participatingShardNames, final CohortDecorator cohortDecorator) {
-        Preconditions.checkState(cohort == null, "cohort was already set");
+        checkState(cohort == null, "cohort was already set");
 
         cohort = transaction.ready(participatingShardNames);
 
index 5e1add10a213fa4e1056ad7e7de026f0a534ff54..9a238e9d50f5a64d0f3187f2bcf25322f73f8978 100644 (file)
@@ -5,9 +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.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.Status;
 import akka.actor.Status.Failure;
@@ -17,7 +19,6 @@ import akka.dispatch.OnComplete;
 import akka.dispatch.Recover;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.AbstractMap.SimpleImmutableEntry;
@@ -109,11 +110,11 @@ class CompositeDataTreeCohort {
 
     CompositeDataTreeCohort(final DataTreeCohortActorRegistry registry, final TransactionIdentifier transactionID,
         final SchemaContext schema, final Executor callbackExecutor, final Timeout timeout) {
-        this.registry = Preconditions.checkNotNull(registry);
-        this.txId = Preconditions.checkNotNull(transactionID);
-        this.schema = Preconditions.checkNotNull(schema);
-        this.callbackExecutor = Preconditions.checkNotNull(callbackExecutor);
-        this.timeout = Preconditions.checkNotNull(timeout);
+        this.registry = requireNonNull(registry);
+        this.txId = requireNonNull(transactionID);
+        this.schema = requireNonNull(schema);
+        this.callbackExecutor = requireNonNull(callbackExecutor);
+        this.timeout = requireNonNull(timeout);
     }
 
     void reset() {
@@ -282,7 +283,7 @@ class CompositeDataTreeCohort {
     }
 
     void changeStateFrom(final State expected, final State followup) {
-        Preconditions.checkState(state == expected);
+        checkState(state == expected);
         state = followup;
     }
 }
index 7e79c3e88a9f852cde80fae1fe731165ee11048a..a8a0124fcd35f71d6c8e549ff0ee6a004979f5bc 100644 (file)
@@ -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.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
@@ -19,9 +19,9 @@ final class DOMDataTreeCandidateTO implements DOMDataTreeCandidate {
     private final DOMDataTreeIdentifier rootPath;
     private final DataTreeCandidateNode rootNode;
 
-    private DOMDataTreeCandidateTO(DOMDataTreeIdentifier rootPath, DataTreeCandidateNode rootNode) {
-        this.rootPath = Preconditions.checkNotNull(rootPath);
-        this.rootNode = Preconditions.checkNotNull(rootNode);
+    private DOMDataTreeCandidateTO(final DOMDataTreeIdentifier rootPath, final DataTreeCandidateNode rootNode) {
+        this.rootPath = requireNonNull(rootPath);
+        this.rootNode = requireNonNull(rootNode);
     }
 
     @Override
@@ -34,7 +34,7 @@ final class DOMDataTreeCandidateTO implements DOMDataTreeCandidate {
         return rootNode;
     }
 
-    static DOMDataTreeCandidate create(DOMDataTreeIdentifier path, DataTreeCandidateNode node) {
+    static DOMDataTreeCandidate create(final DOMDataTreeIdentifier path, final DataTreeCandidateNode node) {
         return new DOMDataTreeCandidateTO(path, node);
     }
 
index c72de945b15154c67c4c1002cd736a72d56aabaa..8df53b276ad79cd3c37f2ad1338f4693559c2740 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.Props;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChangedReply;
@@ -32,8 +33,8 @@ final class DataTreeChangeListenerActor extends AbstractUntypedActor {
 
     private DataTreeChangeListenerActor(final DOMDataTreeChangeListener listener,
             final YangInstanceIdentifier registeredPath) {
-        this.listener = Preconditions.checkNotNull(listener);
-        this.registeredPath = Preconditions.checkNotNull(registeredPath);
+        this.listener = requireNonNull(listener);
+        this.registeredPath = requireNonNull(registeredPath);
     }
 
     @Override
index 2859671ac6bd886f0212c0b8153e193b18ff831e..3ff6a9f0e61ba90e7e17a9f2a6b0bf34a7a3a818 100644 (file)
@@ -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.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
 import akka.actor.Status;
 import akka.util.Timeout;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Multimap;
 import java.util.ArrayList;
@@ -97,11 +97,10 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree<ActorRef> {
     }
 
     abstract static class CohortRegistryCommand {
-
         private final ActorRef cohort;
 
         CohortRegistryCommand(final ActorRef cohort) {
-            this.cohort = Preconditions.checkNotNull(cohort);
+            this.cohort = requireNonNull(cohort);
         }
 
         ActorRef getCohort() {
@@ -110,40 +109,34 @@ class DataTreeCohortActorRegistry extends AbstractRegistrationTree<ActorRef> {
     }
 
     static class RegisterCohort extends CohortRegistryCommand {
-
         private final DOMDataTreeIdentifier path;
 
         RegisterCohort(final DOMDataTreeIdentifier path, final ActorRef cohort) {
             super(cohort);
             this.path = path;
-
         }
 
         public DOMDataTreeIdentifier getPath() {
             return path;
         }
-
     }
 
     static class RemoveCohort extends CohortRegistryCommand {
-
         RemoveCohort(final ActorRef cohort) {
             super(cohort);
         }
-
     }
 
     private static class CanCommitMessageBuilder {
-
+        private final Multimap<ActorRef, DOMDataTreeCandidate> actorToCandidates = ArrayListMultimap.create();
         private final TransactionIdentifier txId;
         private final DataTreeCandidate candidate;
         private final SchemaContext schema;
-        private final Multimap<ActorRef, DOMDataTreeCandidate> actorToCandidates = ArrayListMultimap.create();
 
         CanCommitMessageBuilder(final TransactionIdentifier txId, final DataTreeCandidate candidate,
                 final SchemaContext schema) {
-            this.txId = Preconditions.checkNotNull(txId);
-            this.candidate = Preconditions.checkNotNull(candidate);
+            this.txId = requireNonNull(txId);
+            this.candidate = requireNonNull(candidate);
             this.schema = schema;
         }
 
index 1a46e3d4525f10f4bc616153e1f74733eeb81192..7d3d1b10892d6443858282d95c7df30de94eb780 100644 (file)
@@ -7,9 +7,11 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import akka.util.Timeout;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
@@ -280,8 +282,7 @@ public class DatastoreContext implements ClientActorConfig {
     }
 
     private void setSnapshotDataThresholdPercentage(final int shardSnapshotDataThresholdPercentage) {
-        Preconditions.checkArgument(shardSnapshotDataThresholdPercentage >= 0
-                && shardSnapshotDataThresholdPercentage <= 100);
+        checkArgument(shardSnapshotDataThresholdPercentage >= 0 && shardSnapshotDataThresholdPercentage <= 100);
         raftConfig.setSnapshotDataThresholdPercentage(shardSnapshotDataThresholdPercentage);
     }
 
@@ -491,7 +492,7 @@ public class DatastoreContext implements ClientActorConfig {
         }
 
         public Builder logicalStoreType(final LogicalDatastoreType logicalStoreType) {
-            datastoreContext.logicalStoreType = Preconditions.checkNotNull(logicalStoreType);
+            datastoreContext.logicalStoreType = requireNonNull(logicalStoreType);
 
             // Retain compatible naming
             switch (logicalStoreType) {
@@ -514,7 +515,7 @@ public class DatastoreContext implements ClientActorConfig {
         }
 
         public Builder dataStoreName(final String dataStoreName) {
-            datastoreContext.dataStoreName = Preconditions.checkNotNull(dataStoreName);
+            datastoreContext.dataStoreName = requireNonNull(dataStoreName);
             datastoreContext.dataStoreMXBeanType = "Distributed" + WordUtils.capitalize(dataStoreName) + "Datastore";
             return this;
         }
index db9acaebcdd3e39316d0cc67abd456f68fc922ea..995401c82c681d9e184c22ee3b45277963da0ed0 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -41,7 +42,7 @@ public final class DatastoreSnapshotRestore {
     }
 
     private DatastoreSnapshotRestore(final String restoreDirectoryPath) {
-        this.restoreDirectoryPath = Preconditions.checkNotNull(restoreDirectoryPath);
+        this.restoreDirectoryPath = requireNonNull(restoreDirectoryPath);
     }
 
     // synchronize this method so that, in case of concurrent access to getAndRemove(),
index 9f9d169d1ac2227ce9263b1cf4196497d4d3307f..afb5773f43ff55549af747a71e87be844c0f3c30 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.VisibleForTesting;
-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;
@@ -38,9 +39,9 @@ class DebugThreePhaseCommitCohort extends AbstractThreePhaseCommitCohort<Object>
 
     DebugThreePhaseCommitCohort(final TransactionIdentifier transactionId,
             final AbstractThreePhaseCommitCohort<?> delegate, final Throwable debugContext) {
-        this.delegate = Preconditions.checkNotNull(delegate);
-        this.debugContext = Preconditions.checkNotNull(debugContext);
-        this.transactionId = Preconditions.checkNotNull(transactionId);
+        this.delegate = requireNonNull(delegate);
+        this.debugContext = requireNonNull(debugContext);
+        this.transactionId = requireNonNull(transactionId);
     }
 
     private <V> ListenableFuture<V> addFutureCallback(final ListenableFuture<V> future) {
index 41427608e4e7507113113707c12b15ab39838ff3..73b56239a0a1bc3577d748f92f92772796b9196b 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
-import com.google.common.base.Preconditions;
 import java.util.Collection;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
 import org.opendaylight.controller.cluster.datastore.messages.OnInitialData;
@@ -29,11 +30,11 @@ final class ForwardingDataTreeChangeListener implements DOMDataTreeChangeListene
     private final ActorSelection actor;
 
     ForwardingDataTreeChangeListener(final ActorSelection actor) {
-        this.actor = Preconditions.checkNotNull(actor, "actor should not be null");
+        this.actor = requireNonNull(actor, "actor should not be null");
     }
 
     @Override
-    public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
+    public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
         LOG.debug("Sending DataTreeChanged to {}", actor);
         actor.tell(new DataTreeChanged(changes), ActorRef.noSender());
     }
index db0fcf57909b9902090e68c8db92d3e7b6d67bd1..eedabddf801a85baeca6738a828610b154c5e4f6 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.Range;
 import com.google.common.collect.RangeSet;
 import com.google.common.collect.TreeRangeSet;
@@ -32,7 +34,7 @@ final class FrontendHistoryMetadataBuilder implements Builder<FrontendHistoryMet
     private boolean closed;
 
     FrontendHistoryMetadataBuilder(final LocalHistoryIdentifier identifier) {
-        this.identifier = Preconditions.checkNotNull(identifier);
+        this.identifier = requireNonNull(identifier);
         this.purgedTransactions = TreeRangeSet.create();
         this.closedTransactions = new HashMap<>(2);
     }
@@ -56,7 +58,7 @@ final class FrontendHistoryMetadataBuilder implements Builder<FrontendHistoryMet
     }
 
     void onHistoryClosed() {
-        Preconditions.checkState(identifier.getHistoryId() != 0);
+        checkState(identifier.getHistoryId() != 0);
         closed = true;
     }
 
index efb0fdc04beb351845e6a4465298a705f5ba8156..0bf23e776c563c8e42fe4bb8e3cae79f71a784d5 100644 (file)
@@ -8,8 +8,8 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Maps;
 import java.util.HashMap;
@@ -38,7 +38,7 @@ final class FrontendMetadata extends ShardDataTreeMetadata<FrontendShardDataTree
     private final String shardName;
 
     FrontendMetadata(final String shardName) {
-        this.shardName = Preconditions.checkNotNull(shardName);
+        this.shardName = requireNonNull(shardName);
     }
 
     @Override
index 6bfd280340f935d636e2a29068b905fecf382969..de46d9d2ae4e90b766bace83bd5b19d80ea3e2c5 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import java.util.ArrayDeque;
 import java.util.Optional;
@@ -51,8 +52,8 @@ abstract class FrontendTransaction implements Identifiable<TransactionIdentifier
     private RequestException previousFailure;
 
     FrontendTransaction(final AbstractFrontendHistory history, final TransactionIdentifier id) {
-        this.history = Preconditions.checkNotNull(history);
-        this.id = Preconditions.checkNotNull(id);
+        this.history = requireNonNull(history);
+        this.id = requireNonNull(id);
     }
 
     @Override
index b6fb127714f07b8529de25bc1760dd7c16532f91..af57577c4d37bc08eb5ebd7df92bdd2df2663b31 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorPath;
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.Props;
-import com.google.common.base.Preconditions;
 
 /**
  * Base class for factories instantiating delegates which are local to the
@@ -24,7 +25,7 @@ abstract class LeaderLocalDelegateFactory<M> {
     private final Shard shard;
 
     protected LeaderLocalDelegateFactory(final Shard shard) {
-        this.shard = Preconditions.checkNotNull(shard);
+        this.shard = requireNonNull(shard);
     }
 
     protected final ActorRef getSelf() {
@@ -47,11 +48,11 @@ abstract class LeaderLocalDelegateFactory<M> {
         return shard.getContext().actorOf(props);
     }
 
-    protected final ActorSelection selectActor(ActorRef ref) {
+    protected final ActorSelection selectActor(final ActorRef ref) {
         return shard.getContext().system().actorSelection(ref.path());
     }
 
-    protected final ActorSelection selectActor(ActorPath path) {
+    protected final ActorSelection selectActor(final ActorPath path) {
         return shard.getContext().system().actorSelection(path);
     }
 
index 17e861a3e7252a9c269801bc00a2ebe9ec31d66b..b7239032b59fb0eaabf85e1b582297dffe09cb3f 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.RangeSet;
 import com.google.common.collect.TreeRangeSet;
@@ -20,7 +21,6 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 
-
 /**
  * Chained transaction specialization of {@link AbstractFrontendHistory}. It prevents concurrent open transactions.
  *
@@ -33,7 +33,7 @@ final class LocalFrontendHistory extends AbstractFrontendHistory {
             final ShardDataTreeTransactionChain chain, final Map<UnsignedLong, Boolean> closedTransactions,
             final RangeSet<UnsignedLong> purgedTransactions) {
         super(persistenceId, tree, closedTransactions, purgedTransactions);
-        this.chain = Preconditions.checkNotNull(chain);
+        this.chain = requireNonNull(chain);
     }
 
     static LocalFrontendHistory create(final String persistenceId, final ShardDataTree tree,
index da6d6d14fe9a2c5a574914df0e36d463b0345a09..fdba29c7f7f7ef0d5b02816161b357fb876ca9fa 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorSelection;
-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.MoreExecutors;
@@ -38,7 +39,7 @@ abstract class LocalTransactionContext extends AbstractTransactionContext {
     LocalTransactionContext(final DOMStoreTransaction txDelegate, final TransactionIdentifier identifier,
             final LocalTransactionReadySupport readySupport) {
         super(identifier);
-        this.txDelegate = Preconditions.checkNotNull(txDelegate);
+        this.txDelegate = requireNonNull(txDelegate);
         this.readySupport = readySupport;
     }
 
index e1fee6d62b485393f3f98f9c3f9ffcfe64f34db9..3f0c98c47ff218bc105be34a8b9d2cab10ab8a88 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
@@ -26,12 +28,12 @@ public class OperationLimiter  {
     private final int maxPermits;
 
     OperationLimiter(final TransactionIdentifier identifier, final int maxPermits, final long acquireTimeoutSeconds) {
-        this.identifier = Preconditions.checkNotNull(identifier);
+        this.identifier = requireNonNull(identifier);
 
-        Preconditions.checkArgument(acquireTimeoutSeconds >= 0);
+        checkArgument(acquireTimeoutSeconds >= 0);
         this.acquireTimeout = TimeUnit.SECONDS.toNanos(acquireTimeoutSeconds);
 
-        Preconditions.checkArgument(maxPermits >= 0);
+        checkArgument(maxPermits >= 0);
         this.maxPermits = maxPermits;
         this.semaphore = new Semaphore(maxPermits);
     }
@@ -60,7 +62,7 @@ public class OperationLimiter  {
         release(1);
     }
 
-    void release(int permits) {
+    void release(final int permits) {
         this.semaphore.release(permits);
     }
 
index a93d46f051bdbf29c25599bea444fcd2fde93b57..7be72393a2caff1918cd1f8e75bc392feab5290a 100644 (file)
@@ -8,11 +8,12 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorSelection;
 import akka.dispatch.OnComplete;
 import akka.pattern.AskTimeoutException;
 import akka.util.Timeout;
-import com.google.common.base.Preconditions;
 import java.util.concurrent.TimeUnit;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
@@ -61,7 +62,7 @@ final class RemoteTransactionContextSupport {
 
     RemoteTransactionContextSupport(final TransactionContextWrapper transactionContextWrapper,
             final TransactionProxy parent, final String shardName) {
-        this.parent = Preconditions.checkNotNull(parent);
+        this.parent = requireNonNull(parent);
         this.shardName = shardName;
         this.transactionContextWrapper = transactionContextWrapper;
 
index a7b89e18003844e96ed3e097381786dda4714b99..f634aecc6285fbbe925f89044df2c326ced9ea10 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
 
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
@@ -19,7 +21,6 @@ import akka.actor.Status.Failure;
 import akka.serialization.JavaSerializer;
 import akka.serialization.Serialization;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Ticker;
 import com.google.common.base.Verify;
 import com.google.common.collect.ImmutableList;
@@ -1101,7 +1102,7 @@ public class Shard extends RaftActor {
         }
 
         protected void checkSealed() {
-            Preconditions.checkState(!sealed, "Builder isalready sealed - further modifications are not allowed");
+            checkState(!sealed, "Builder isalready sealed - further modifications are not allowed");
         }
 
         @SuppressWarnings("unchecked")
@@ -1129,7 +1130,7 @@ public class Shard extends RaftActor {
 
         public T schemaContextProvider(final SchemaContextProvider newSchemaContextProvider) {
             checkSealed();
-            this.schemaContextProvider = Preconditions.checkNotNull(newSchemaContextProvider);
+            this.schemaContextProvider = requireNonNull(newSchemaContextProvider);
             return self();
         }
 
@@ -1182,10 +1183,10 @@ public class Shard extends RaftActor {
         }
 
         protected void verify() {
-            Preconditions.checkNotNull(id, "id should not be null");
-            Preconditions.checkNotNull(peerAddresses, "peerAddresses should not be null");
-            Preconditions.checkNotNull(datastoreContext, "dataStoreContext should not be null");
-            Preconditions.checkNotNull(schemaContextProvider, "schemaContextProvider should not be null");
+            requireNonNull(id, "id should not be null");
+            requireNonNull(peerAddresses, "peerAddresses should not be null");
+            requireNonNull(datastoreContext, "dataStoreContext should not be null");
+            requireNonNull(schemaContextProvider, "schemaContextProvider should not be null");
         }
 
         public Props props() {
index ad99fce9468951111b7fdf66c2a5c11d5478a90c..d9520c5d5c6596ab8c9a9a7a626d3b1ebe657c71 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.Status.Failure;
 import akka.serialization.Serialization;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.FutureCallback;
 import java.util.ArrayDeque;
@@ -70,7 +71,7 @@ final class ShardCommitCoordinator {
     ShardCommitCoordinator(final ShardDataTree dataTree, final Logger log, final String name) {
         this.log = log;
         this.name = name;
-        this.dataTree = Preconditions.checkNotNull(dataTree);
+        this.dataTree = requireNonNull(dataTree);
     }
 
     int getCohortCacheSize() {
index 6e4ee7d9e13f7dd4899c24833f65538eb255a42f..221ff9c253c1f4c0033eb40a894984f56795a8fe 100644 (file)
@@ -7,13 +7,16 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Verify.verify;
+import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.util.Timeout;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Stopwatch;
-import com.google.common.base.Verify;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
@@ -99,7 +102,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
         long lastAccess;
 
         CommitEntry(final SimpleShardDataTreeCohort cohort, final long now) {
-            this.cohort = Preconditions.checkNotNull(cohort);
+            this.cohort = requireNonNull(cohort);
             lastAccess = now;
         }
 
@@ -155,12 +158,12 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
             final ShardDataTreeChangeListenerPublisher treeChangeListenerPublisher,
             final String logContext,
             final ShardDataTreeMetadata<?>... metadata) {
-        this.dataTree = Preconditions.checkNotNull(dataTree);
+        this.dataTree = requireNonNull(dataTree);
         updateSchemaContext(schemaContext);
 
-        this.shard = Preconditions.checkNotNull(shard);
-        this.treeChangeListenerPublisher = Preconditions.checkNotNull(treeChangeListenerPublisher);
-        this.logContext = Preconditions.checkNotNull(logContext);
+        this.shard = requireNonNull(shard);
+        this.treeChangeListenerPublisher = requireNonNull(treeChangeListenerPublisher);
+        this.logContext = requireNonNull(logContext);
         this.metadata = ImmutableList.copyOf(metadata);
         tip = dataTree;
     }
@@ -206,7 +209,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
 
     void updateSchemaContext(final SchemaContext newSchemaContext) {
         dataTree.setSchemaContext(newSchemaContext);
-        this.schemaContext = Preconditions.checkNotNull(newSchemaContext);
+        this.schemaContext = requireNonNull(newSchemaContext);
         this.dataSchemaContext = DataSchemaContextTree.from(newSchemaContext);
     }
 
@@ -411,7 +414,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
                         ((CommitTransactionPayload) payload).getCandidate();
                 applyReplicatedCandidate(e.getKey(), e.getValue());
             } else {
-                Verify.verify(identifier instanceof TransactionIdentifier);
+                verify(identifier instanceof TransactionIdentifier);
                 payloadReplicationComplete((TransactionIdentifier) identifier);
             }
         } else if (payload instanceof AbortTransactionPayload) {
@@ -527,8 +530,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
             final boolean closed) {
         final ShardDataTreeTransactionChain ret = new ShardDataTreeTransactionChain(historyId, this);
         final ShardDataTreeTransactionChain existing = transactionChains.putIfAbsent(historyId, ret);
-        Preconditions.checkState(existing == null, "Attempted to recreate chain %s, but %s already exists", historyId,
-                existing);
+        checkState(existing == null, "Attempted to recreate chain %s, but %s already exists", historyId, existing);
         return ret;
     }
 
@@ -930,10 +932,10 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
     @SuppressWarnings("checkstyle:IllegalCatch")
     void startPreCommit(final SimpleShardDataTreeCohort cohort) {
         final CommitEntry entry = pendingTransactions.peek();
-        Preconditions.checkState(entry != null, "Attempted to pre-commit of %s when no transactions pending", cohort);
+        checkState(entry != null, "Attempted to pre-commit of %s when no transactions pending", cohort);
 
         final SimpleShardDataTreeCohort current = entry.cohort;
-        Verify.verify(cohort.equals(current), "Attempted to pre-commit %s while %s is pending", cohort, current);
+        verify(cohort.equals(current), "Attempted to pre-commit %s while %s is pending", cohort, current);
 
         final TransactionIdentifier currentId = current.getIdentifier();
         LOG.debug("{}: Preparing transaction {}", logContext, currentId);
@@ -951,7 +953,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
             @Override
             public void onSuccess(final Void noop) {
                 // Set the tip of the data tree.
-                tip = Verify.verifyNotNull(candidate);
+                tip = verifyNotNull(candidate);
 
                 entry.lastAccess = readTime();
 
@@ -1013,7 +1015,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
 
     void startCommit(final SimpleShardDataTreeCohort cohort, final DataTreeCandidate candidate) {
         final CommitEntry entry = pendingCommits.peek();
-        Preconditions.checkState(entry != null, "Attempted to start commit of %s when no transactions pending", cohort);
+        checkState(entry != null, "Attempted to start commit of %s when no transactions pending", cohort);
 
         final SimpleShardDataTreeCohort current = entry.cohort;
         if (!cohort.equals(current)) {
@@ -1253,7 +1255,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     private void rebaseTransactions(final Iterator<CommitEntry> iter, final @NonNull DataTreeTip newTip) {
-        tip = Preconditions.checkNotNull(newTip);
+        tip = requireNonNull(newTip);
         while (iter.hasNext()) {
             final SimpleShardDataTreeCohort cohort = iter.next().cohort;
             if (cohort.getState() == State.CAN_COMMIT_COMPLETE) {
index 9406eab6b98ebd03f13898bb5b123850fe334343..7917ae0177f6a9f737cd59b04d314e67b841c95e 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import java.util.Optional;
 import java.util.SortedSet;
 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
@@ -34,13 +36,13 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent
     private boolean closed;
 
     ShardDataTreeTransactionChain(final LocalHistoryIdentifier localHistoryIdentifier, final ShardDataTree dataTree) {
-        this.chainId = Preconditions.checkNotNull(localHistoryIdentifier);
-        this.dataTree = Preconditions.checkNotNull(dataTree);
+        this.chainId = requireNonNull(localHistoryIdentifier);
+        this.dataTree = requireNonNull(dataTree);
     }
 
     private DataTreeSnapshot getSnapshot() {
-        Preconditions.checkState(!closed, "TransactionChain %s has been closed", this);
-        Preconditions.checkState(openTransaction == null, "Transaction %s is open", openTransaction);
+        checkState(!closed, "TransactionChain %s has been closed", this);
+        checkState(openTransaction == null, "Transaction %s is open", openTransaction);
 
         if (previousTx == null) {
             LOG.debug("Opening an unchained snapshot in {}", chainId);
@@ -74,8 +76,8 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent
     @Override
     void abortFromTransactionActor(final AbstractShardDataTreeTransaction<?> transaction) {
         if (transaction instanceof ReadWriteShardDataTreeTransaction) {
-            Preconditions.checkState(openTransaction != null,
-                    "Attempted to abort transaction %s while none is outstanding", transaction);
+            checkState(openTransaction != null, "Attempted to abort transaction %s while none is outstanding",
+                    transaction);
             LOG.debug("Aborted open transaction {}", transaction);
             openTransaction = null;
         }
@@ -90,8 +92,8 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent
     @Override
     ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction,
             final Optional<SortedSet<String>> participatingShardNames) {
-        Preconditions.checkState(openTransaction != null,
-                "Attempted to finish transaction %s while none is outstanding", transaction);
+        checkState(openTransaction != null, "Attempted to finish transaction %s while none is outstanding",
+                transaction);
 
         // dataTree is finalizing ready the transaction, we just record it for the next
         // transaction in chain
index fc3bfda1eb5582b06cf02f41c155fad5ab31681a..3b0105bf6728fd2d4b2626caf768490b56fe15a1 100644 (file)
@@ -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.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
 import org.opendaylight.controller.cluster.datastore.messages.DataExists;
 import org.opendaylight.controller.cluster.datastore.messages.ReadData;
@@ -22,14 +22,14 @@ import org.opendaylight.controller.cluster.datastore.messages.ReadData;
 public class ShardReadTransaction extends ShardTransaction {
     private final AbstractShardDataTreeTransaction<?> transaction;
 
-    public ShardReadTransaction(AbstractShardDataTreeTransaction<?> transaction, ActorRef shardActor,
-            ShardStats shardStats) {
+    public ShardReadTransaction(final AbstractShardDataTreeTransaction<?> transaction, final ActorRef shardActor,
+            final ShardStats shardStats) {
         super(shardActor, shardStats, transaction.getIdentifier());
-        this.transaction = Preconditions.checkNotNull(transaction);
+        this.transaction = requireNonNull(transaction);
     }
 
     @Override
-    public void handleReceive(Object message) {
+    public void handleReceive(final Object message) {
         if (ReadData.isSerializedType(message)) {
             readData(transaction, ReadData.fromSerializable(message));
         } else if (DataExists.isSerializedType(message)) {
index 7ece110d0143c4e1261ba511a9f73f0dbb8b3905..aeaad4880614445d4d708353c8644c1233a4e83d 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import java.io.File;
 import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot;
 import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
@@ -44,7 +46,7 @@ abstract class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
 
         WithSnapshot(final ShardDataTree store, final String shardName, final Logger log, final Snapshot snapshot) {
             super(store, shardName, log);
-            this.restoreFromSnapshot = Preconditions.checkNotNull(snapshot);
+            this.restoreFromSnapshot = requireNonNull(snapshot);
         }
 
         @Override
@@ -60,9 +62,9 @@ abstract class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
     private boolean open;
 
     ShardRecoveryCoordinator(final ShardDataTree store, final String shardName, final Logger log) {
-        this.store = Preconditions.checkNotNull(store);
-        this.shardName = Preconditions.checkNotNull(shardName);
-        this.log = Preconditions.checkNotNull(log);
+        this.store = requireNonNull(store);
+        this.shardName = requireNonNull(shardName);
+        this.log = requireNonNull(log);
     }
 
     static ShardRecoveryCoordinator create(final ShardDataTree store, final String shardName, final Logger log) {
@@ -83,7 +85,7 @@ abstract class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
     @Override
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void appendRecoveredLogEntry(final Payload payload) {
-        Preconditions.checkState(open, "call startLogRecovery before calling appendRecoveredLogEntry");
+        checkState(open, "call startLogRecovery before calling appendRecoveredLogEntry");
 
         try {
             store.applyRecoveryPayload(payload);
@@ -99,7 +101,7 @@ abstract class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
      */
     @Override
     public void applyCurrentLogRecoveryBatch() {
-        Preconditions.checkState(open, "call startLogRecovery before calling applyCurrentLogRecoveryBatch");
+        checkState(open, "call startLogRecovery before calling applyCurrentLogRecoveryBatch");
         open = false;
     }
 
index e936d4389b8b33f78e958bafc1437aef1940f229..126e28d9c8c6157794f3b7a12282fb5488d5e2dd 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorContext;
 import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
 import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.ObjectInputStream;
@@ -43,8 +44,8 @@ final class ShardSnapshotCohort implements RaftActorSnapshotCohort {
 
     private ShardSnapshotCohort(final LocalHistoryIdentifier applyHistoryId, final ActorRef snapshotActor,
             final ShardDataTree store, final Logger log, final String logId) {
-        this.snapshotActor = Preconditions.checkNotNull(snapshotActor);
-        this.store = Preconditions.checkNotNull(store);
+        this.snapshotActor = requireNonNull(snapshotActor);
+        this.store = requireNonNull(store);
         this.log = log;
         this.logId = logId;
     }
index 87dd5e3e2638fff856352b2f012523ad83631c82..97426402bc08e7dca32328d852675a03ad08d7f9 100644 (file)
@@ -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.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.actor.ReceiveTimeout;
 import akka.japi.Creator;
-import com.google.common.base.Preconditions;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActorWithMetering;
@@ -41,7 +41,7 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering
         super("shard-tx");
         this.shardActor = shardActor;
         this.shardStats = shardStats;
-        this.transactionId = Preconditions.checkNotNull(transactionId);
+        this.transactionId = requireNonNull(transactionId);
     }
 
     public static Props props(final TransactionType type, final AbstractShardDataTreeTransaction<?> transaction,
@@ -130,7 +130,7 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering
 
         ShardTransactionCreator(final TransactionType type, final AbstractShardDataTreeTransaction<?> transaction,
                 final ActorRef shardActor, final DatastoreContext datastoreContext, final ShardStats shardStats) {
-            this.transaction = Preconditions.checkNotNull(transaction);
+            this.transaction = requireNonNull(transaction);
             this.shardActor = shardActor;
             this.shardStats = shardStats;
             this.datastoreContext = datastoreContext;
index 9505894b4b1cad73fd0d264ee8b7ba641f26ae66..a96be9fcb1476098792ad2ed1a8f156a30f4e6c7 100644 (file)
@@ -13,7 +13,6 @@ import static java.util.Objects.requireNonNull;
 import akka.actor.ActorSelection;
 import akka.dispatch.OnComplete;
 import com.google.common.base.Supplier;
-import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -213,7 +212,7 @@ public class ThreePhaseCommitCohortProxy extends AbstractThreePhaseCommitCohort<
     }
 
     private Future<Iterable<Object>> invokeCohorts(final MessageSupplier messageSupplier) {
-        List<Future<Object>> futureList = Lists.newArrayListWithCapacity(cohorts.size());
+        List<Future<Object>> futureList = new ArrayList<>(cohorts.size());
         for (CohortInfo cohort : cohorts) {
             Object message = messageSupplier.newMessage(transactionId, cohort.getActorVersion());
 
index c3b81d7e15730c338669757e22338ef816938ee1..7c36adb70e6f65cdd559f68ff524b56461bc14ff 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorSelection;
 import akka.dispatch.Futures;
 import akka.dispatch.OnComplete;
-import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -61,7 +63,7 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory<Loca
 
         Pending(final TransactionIdentifier transaction, final Future<?> previousFuture) {
             this.previousFuture = previousFuture;
-            this.transaction = Preconditions.checkNotNull(transaction);
+            this.transaction = requireNonNull(transaction);
         }
 
         @Override
@@ -292,11 +294,11 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory<Loca
     protected <T> void onTransactionReady(final TransactionIdentifier transaction,
             final Collection<Future<T>> cohortFutures) {
         final State localState = currentState;
-        Preconditions.checkState(localState instanceof Allocated, "Readying transaction %s while state is %s",
-                transaction, localState);
+        checkState(localState instanceof Allocated, "Readying transaction %s while state is %s", transaction,
+            localState);
         final TransactionIdentifier currentTx = ((Allocated)localState).getIdentifier();
-        Preconditions.checkState(transaction.equals(currentTx), "Readying transaction %s while %s is allocated",
-                transaction, currentTx);
+        checkState(transaction.equals(currentTx), "Readying transaction %s while %s is allocated", transaction,
+            currentTx);
 
         // Transaction ready and we are not waiting for futures -- go to idle
         if (cohortFutures.isEmpty()) {
@@ -322,7 +324,7 @@ final class TransactionChainProxy extends AbstractTransactionContextFactory<Loca
     }
 
     @Override
-    protected void onTransactionContextCreated(TransactionIdentifier transactionId) {
+    protected void onTransactionContextCreated(final TransactionIdentifier transactionId) {
         Promise<Object> promise = priorReadOnlyTxPromises.remove(transactionId);
         if (promise != null) {
             promise.success(null);
index 83863de00dd7dbfeebe96235a874da057bfd4a52..155bb1fd3e303cfe8aa929fb44322bad90e2e949 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorSelection;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Supplier;
 import com.google.common.collect.Iterables;
 import com.google.common.util.concurrent.FluentFuture;
@@ -71,7 +73,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
         super(txContextFactory.nextIdentifier(), txContextFactory.getActorUtils().getDatastoreContext()
                 .isTransactionDebugContextEnabled());
         this.txContextFactory = txContextFactory;
-        this.type = Preconditions.checkNotNull(type);
+        this.type = requireNonNull(type);
 
         LOG.debug("New {} Tx - {}", type, getIdentifier());
     }
@@ -82,8 +84,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
     }
 
     private <T> FluentFuture<T> executeRead(final String shardName, final AbstractRead<T> readCmd) {
-        Preconditions.checkState(type != TransactionType.WRITE_ONLY,
-                "Reads from write-only transactions are not allowed");
+        checkState(type != TransactionType.WRITE_ONLY, "Reads from write-only transactions are not allowed");
 
         LOG.trace("Tx {} {} {}", getIdentifier(), readCmd.getClass().getSimpleName(), readCmd.getPath());
 
@@ -101,9 +102,8 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
 
     @Override
     public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
-        Preconditions.checkState(type != TransactionType.WRITE_ONLY,
-                "Reads from write-only transactions are not allowed");
-        Preconditions.checkNotNull(path, "path should not be null");
+        checkState(type != TransactionType.WRITE_ONLY, "Reads from write-only transactions are not allowed");
+        requireNonNull(path, "path should not be null");
 
         LOG.trace("Tx {} read {}", getIdentifier(), path);
         return path.isEmpty() ? readAllData() :  singleShardRead(shardNameFromIdentifier(path), path);
@@ -170,10 +170,8 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
     }
 
     private void checkModificationState() {
-        Preconditions.checkState(type != TransactionType.READ_ONLY,
-                "Modification operation on read-only transaction is not allowed");
-        Preconditions.checkState(state == TransactionState.OPEN,
-                "Transaction is sealed - further modifications are not allowed");
+        checkState(type != TransactionType.READ_ONLY, "Modification operation on read-only transaction is not allowed");
+        checkState(state == TransactionState.OPEN, "Transaction is sealed - further modifications are not allowed");
     }
 
     private boolean seal(final TransactionState newState) {
@@ -188,7 +186,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
     @Override
     public final void close() {
         if (!seal(TransactionState.CLOSED)) {
-            Preconditions.checkState(state == TransactionState.CLOSED, "Transaction %s is ready, it cannot be closed",
+            checkState(state == TransactionState.CLOSED, "Transaction %s is ready, it cannot be closed",
                 getIdentifier());
             // Idempotent no-op as per AutoCloseable recommendation
             return;
@@ -209,10 +207,10 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
 
     @Override
     public final AbstractThreePhaseCommitCohort<?> ready() {
-        Preconditions.checkState(type != TransactionType.READ_ONLY, "Read-only transactions cannot be readied");
+        checkState(type != TransactionType.READ_ONLY, "Read-only transactions cannot be readied");
 
         final boolean success = seal(TransactionState.READY);
-        Preconditions.checkState(success, "Transaction %s is %s, it cannot be readied", getIdentifier(), state);
+        checkState(success, "Transaction %s is %s, it cannot be readied", getIdentifier(), state);
 
         LOG.debug("Tx {} Readying {} components for commit", getIdentifier(), txContextWrappers.size());
 
index 38c7620b63dd7dd4d86dcd83f599d6cf86236484..7d9118dfbe03bc1e2bb87f4513010c2152202524 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.controller.cluster.datastore.actors;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.Cancellable;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import java.util.concurrent.TimeUnit;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotificationListenerRegistration;
@@ -34,7 +35,7 @@ public final class DataTreeNotificationListenerRegistrationActor extends Abstrac
     private Cancellable killSchedule;
 
     @Override
-    protected void handleReceive(Object message) {
+    protected void handleReceive(final Object message) {
         if (message instanceof CloseDataTreeNotificationListenerRegistration) {
             closeListenerRegistration();
             if (isValidSender(getSender())) {
@@ -75,8 +76,8 @@ public final class DataTreeNotificationListenerRegistrationActor extends Abstrac
         private final Runnable onClose;
 
         public SetRegistration(final ListenerRegistration<?> registration, final Runnable onClose) {
-            this.registration = Preconditions.checkNotNull(registration);
-            this.onClose = Preconditions.checkNotNull(onClose);
+            this.registration = requireNonNull(registration);
+            this.onClose = requireNonNull(onClose);
         }
     }
 }
index 14cf4cd1a3ec2d58552a3a86377f9da3127b04ac..bdc2ec48d7ba12bbe373f25f8db096c7e8926ef1 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore.actors;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.Props;
-import com.google.common.base.Preconditions;
 import java.io.IOException;
 import java.io.ObjectOutputStream;
 import java.io.OutputStream;
@@ -34,9 +35,9 @@ public final class ShardSnapshotActor extends AbstractUntypedActorWithMetering {
 
         SerializeSnapshot(final ShardDataTreeSnapshot snapshot, final Optional<OutputStream> installSnapshotStream,
                 final ActorRef replyTo) {
-            this.snapshot = Preconditions.checkNotNull(snapshot);
-            this.installSnapshotStream = Preconditions.checkNotNull(installSnapshotStream);
-            this.replyTo = Preconditions.checkNotNull(replyTo);
+            this.snapshot = requireNonNull(snapshot);
+            this.installSnapshotStream = requireNonNull(installSnapshotStream);
+            this.replyTo = requireNonNull(replyTo);
         }
 
         ShardDataTreeSnapshot getSnapshot() {
index 7588b6d77cb53332eba19ee8d1b7e8ff8399e6bf..4da39ef1549142369f88cbb8723da79c9ff42222 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.config;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import java.util.AbstractMap.SimpleEntry;
@@ -56,7 +57,7 @@ public class ConfigurationImpl implements Configuration {
         this.namespaceToModuleName = createNamespaceToModuleName(moduleConfigMap.values());
     }
 
-    private static Set<String> createAllShardNames(Iterable<ModuleConfig> moduleConfigs) {
+    private static Set<String> createAllShardNames(final Iterable<ModuleConfig> moduleConfigs) {
         final ImmutableSet.Builder<String> builder = ImmutableSet.builder();
         for (ModuleConfig moduleConfig : moduleConfigs) {
             builder.addAll(moduleConfig.getShardNames());
@@ -65,7 +66,7 @@ public class ConfigurationImpl implements Configuration {
         return builder.build();
     }
 
-    private static Map<String, String> createNamespaceToModuleName(Iterable<ModuleConfig> moduleConfigs) {
+    private static Map<String, String> createNamespaceToModuleName(final Iterable<ModuleConfig> moduleConfigs) {
         final ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
         for (ModuleConfig moduleConfig : moduleConfigs) {
             if (moduleConfig.getNamespace() != null) {
@@ -78,7 +79,7 @@ public class ConfigurationImpl implements Configuration {
 
     @Override
     public Collection<String> getMemberShardNames(final MemberName memberName) {
-        Preconditions.checkNotNull(memberName, "memberName should not be null");
+        requireNonNull(memberName, "memberName should not be null");
 
         List<String> shards = new ArrayList<>();
         for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
@@ -94,14 +95,14 @@ public class ConfigurationImpl implements Configuration {
 
     @Override
     public String getModuleNameFromNameSpace(final String nameSpace) {
-        Preconditions.checkNotNull(nameSpace, "nameSpace should not be null");
+        requireNonNull(nameSpace, "nameSpace should not be null");
 
         return namespaceToModuleName.get(nameSpace);
     }
 
     @Override
-    public ShardStrategy getStrategyForModule(String moduleName) {
-        Preconditions.checkNotNull(moduleName, "moduleName should not be null");
+    public ShardStrategy getStrategyForModule(final String moduleName) {
+        requireNonNull(moduleName, "moduleName should not be null");
 
         ModuleConfig moduleConfig = moduleConfigMap.get(moduleName);
         return moduleConfig != null ? moduleConfig.getShardStrategy() : null;
@@ -109,7 +110,7 @@ public class ConfigurationImpl implements Configuration {
 
     @Override
     public String getShardNameForModule(final String moduleName) {
-        Preconditions.checkNotNull(moduleName, "moduleName should not be null");
+        requireNonNull(moduleName, "moduleName should not be null");
 
         ModuleConfig moduleConfig = moduleConfigMap.get(moduleName);
         Collection<ShardConfig> shardConfigs = moduleConfig != null ? moduleConfig.getShardConfigs() :
@@ -119,11 +120,10 @@ public class ConfigurationImpl implements Configuration {
 
     @Override
     public String getShardNameForPrefix(final DOMDataTreeIdentifier prefix) {
-        Preconditions.checkNotNull(prefix, "prefix should not be null");
+        requireNonNull(prefix, "prefix should not be null");
 
-        Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> bestMatchEntry =
-                new SimpleEntry<>(
-                        new DOMDataTreeIdentifier(prefix.getDatastoreType(), YangInstanceIdentifier.EMPTY), null);
+        Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> bestMatchEntry = new SimpleEntry<>(
+                new DOMDataTreeIdentifier(prefix.getDatastoreType(), YangInstanceIdentifier.EMPTY), null);
 
         for (Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> entry : prefixConfigMap.entrySet()) {
             if (entry.getKey().contains(prefix) && entry.getKey().getRootIdentifier().getPathArguments().size()
@@ -157,7 +157,7 @@ public class ConfigurationImpl implements Configuration {
     }
 
     private static void checkNotNullShardName(final String shardName) {
-        Preconditions.checkNotNull(shardName, "shardName should not be null");
+        requireNonNull(shardName, "shardName should not be null");
     }
 
     @Override
@@ -176,8 +176,8 @@ public class ConfigurationImpl implements Configuration {
     }
 
     @Override
-    public synchronized void addModuleShardConfiguration(ModuleShardConfiguration config) {
-        Preconditions.checkNotNull(config, "ModuleShardConfiguration should not be null");
+    public synchronized void addModuleShardConfiguration(final ModuleShardConfiguration config) {
+        requireNonNull(config, "ModuleShardConfiguration should not be null");
 
         ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName())
                 .nameSpace(config.getNamespace().toASCIIString())
@@ -193,17 +193,14 @@ public class ConfigurationImpl implements Configuration {
 
     @Override
     public void addPrefixShardConfiguration(final PrefixShardConfiguration config) {
-        Preconditions.checkNotNull(config, "PrefixShardConfiguration cannot be null");
-        addPrefixConfig(config);
+        addPrefixConfig(requireNonNull(config, "PrefixShardConfiguration cannot be null"));
         allShardNames = ImmutableSet.<String>builder().addAll(allShardNames)
                 .add(ClusterUtils.getCleanShardName(config.getPrefix().getRootIdentifier())).build();
     }
 
     @Override
     public void removePrefixShardConfiguration(final DOMDataTreeIdentifier prefix) {
-        Preconditions.checkNotNull(prefix, "Prefix cannot be null");
-
-        removePrefixConfig(prefix);
+        removePrefixConfig(requireNonNull(prefix, "Prefix cannot be null"));
 
         final HashSet<String> temp = new HashSet<>(allShardNames);
         temp.remove(ClusterUtils.getCleanShardName(prefix.getRootIdentifier()));
@@ -228,20 +225,20 @@ public class ConfigurationImpl implements Configuration {
         prefixConfigMap = ImmutableMap.copyOf(newPrefixConfigMap);
     }
 
-    private ShardStrategy createShardStrategy(String moduleName, String shardStrategyName) {
+    private ShardStrategy createShardStrategy(final String moduleName, final String shardStrategyName) {
         return ShardStrategyFactory.newShardStrategyInstance(moduleName, shardStrategyName, this);
     }
 
     @Override
-    public boolean isShardConfigured(String shardName) {
+    public boolean isShardConfigured(final String shardName) {
         checkNotNullShardName(shardName);
         return allShardNames.contains(shardName);
     }
 
     @Override
-    public void addMemberReplicaForShard(String shardName, MemberName newMemberName) {
+    public void addMemberReplicaForShard(final String shardName, final MemberName newMemberName) {
         checkNotNullShardName(shardName);
-        Preconditions.checkNotNull(newMemberName, "MemberName should not be null");
+        requireNonNull(newMemberName, "MemberName should not be null");
 
         for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
             ShardConfig shardConfig = moduleConfig.getShardConfig(shardName);
@@ -255,9 +252,9 @@ public class ConfigurationImpl implements Configuration {
     }
 
     @Override
-    public void removeMemberReplicaForShard(String shardName, MemberName newMemberName) {
+    public void removeMemberReplicaForShard(final String shardName, final MemberName newMemberName) {
         checkNotNullShardName(shardName);
-        Preconditions.checkNotNull(newMemberName, "MemberName should not be null");
+        requireNonNull(newMemberName, "MemberName should not be null");
 
         for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
             ShardConfig shardConfig = moduleConfig.getShardConfig(shardName);
@@ -272,11 +269,10 @@ public class ConfigurationImpl implements Configuration {
 
     @Override
     public ShardStrategy getStrategyForPrefix(final DOMDataTreeIdentifier prefix) {
-        Preconditions.checkNotNull(prefix, "Prefix cannot be null");
+        requireNonNull(prefix, "Prefix cannot be null");
         // FIXME using prefix tables like in mdsal will be better
-        Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> bestMatchEntry =
-                new SimpleEntry<>(
-                        new DOMDataTreeIdentifier(prefix.getDatastoreType(), YangInstanceIdentifier.EMPTY), null);
+        Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> bestMatchEntry = new SimpleEntry<>(
+                new DOMDataTreeIdentifier(prefix.getDatastoreType(), YangInstanceIdentifier.EMPTY), null);
 
         for (Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> entry : prefixConfigMap.entrySet()) {
             if (entry.getKey().contains(prefix) && entry.getKey().getRootIdentifier().getPathArguments().size()
index c387fe4ba247ae22ec9bb4350ebba945c7169c5d..dc6db2c6beeca669de540c1e2fa91ab4ac88844c 100644 (file)
@@ -5,10 +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.datastore.config;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableSet;
 import java.io.Externalizable;
 import java.io.IOException;
@@ -79,8 +79,8 @@ public class PrefixShardConfiguration implements Serializable {
     public PrefixShardConfiguration(final DOMDataTreeIdentifier prefix,
                                     final String shardStrategyName,
                                     final Collection<MemberName> shardMemberNames) {
-        this.prefix = Preconditions.checkNotNull(prefix);
-        this.shardStrategyName = Preconditions.checkNotNull(shardStrategyName);
+        this.prefix = requireNonNull(prefix);
+        this.shardStrategyName = requireNonNull(shardStrategyName);
         this.shardMemberNames = ImmutableSet.copyOf(shardMemberNames);
     }
 
index 149551b8c89bc912b569e669fade1a255422327e..7d1184aab93e3468a98ade225255f94d4b870940 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
@@ -26,8 +27,8 @@ class DistributedEntityOwnershipListenerRegistration extends AbstractObjectRegis
     DistributedEntityOwnershipListenerRegistration(final DOMEntityOwnershipListener listener, final String entityType,
             final DistributedEntityOwnershipService service) {
         super(listener);
-        this.entityType = Preconditions.checkNotNull(entityType, "entityType cannot be null");
-        this.service = Preconditions.checkNotNull(service, "DOMEntityOwnershipListener cannot be null");
+        this.entityType = requireNonNull(entityType, "entityType cannot be null");
+        this.service = requireNonNull(service, "DOMEntityOwnershipListener cannot be null");
     }
 
     @Override
index 02017453197e95f0467b96920fafc62820b4bc0f..38dbae3865fca68afa2cec03424157027c6c4ac9 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
+import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.createEntity;
 
-import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
-import com.google.common.base.Verify;
 import java.util.Collection;
 import java.util.Objects;
 import java.util.Optional;
@@ -36,8 +36,8 @@ class EntityOwnerChangeListener extends AbstractEntityOwnerChangeListener {
     private final EntityOwnershipChangePublisher publisher;
 
     EntityOwnerChangeListener(final MemberName localMemberName, final EntityOwnershipChangePublisher publisher) {
-        this.localMemberName = Verify.verifyNotNull(localMemberName.getName());
-        this.publisher = Preconditions.checkNotNull(publisher);
+        this.localMemberName = verifyNotNull(localMemberName.getName());
+        this.publisher = requireNonNull(publisher);
     }
 
     @Override
index 42779b06edad91297622edc5b58744795ea49cd1..0a1bb923996f6bbd87bbc2f5cfafa24e3f185d2b 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.Props;
 import akka.japi.Creator;
-import com.google.common.base.Preconditions;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
@@ -59,7 +60,7 @@ final class EntityOwnershipListenerActor extends AbstractUntypedActor {
         private final DOMEntityOwnershipListener listener;
 
         EntityOwnershipListenerCreator(final DOMEntityOwnershipListener listener) {
-            this.listener = Preconditions.checkNotNull(listener);
+            this.listener = requireNonNull(listener);
         }
 
         @Override
index 6e1d1a855a5ff0c99ec2df73ab2847fa398b0412..cd97b0bcdd01504b2dad32b11ba6a1d94743d5bc 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
+import static java.util.Objects.requireNonNull;
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NAME_NODE_ID;
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NODE_ID;
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_ID_NODE_ID;
@@ -30,7 +31,6 @@ import akka.cluster.ClusterEvent.CurrentClusterState;
 import akka.cluster.Member;
 import akka.cluster.MemberStatus;
 import akka.pattern.Patterns;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -705,8 +705,8 @@ class EntityOwnershipShard extends Shard {
         @Override
         protected void verify() {
             super.verify();
-            Preconditions.checkNotNull(localMemberName, "localMemberName should not be null");
-            Preconditions.checkNotNull(ownerSelectionStrategyConfig, "ownerSelectionStrategyConfig should not be null");
+            requireNonNull(localMemberName, "localMemberName should not be null");
+            requireNonNull(ownerSelectionStrategyConfig, "ownerSelectionStrategyConfig should not be null");
         }
     }
 }
index a343d7373f21ba1d748bba2ac879cf9737751780..eaca661619fad6c63d2a5339c997bd7fc26a171f 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
+import static java.util.Objects.requireNonNull;
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_OWNER_QNAME;
 
 import akka.actor.ActorRef;
 import akka.actor.Cancellable;
 import akka.actor.Status.Failure;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -56,13 +56,13 @@ class EntityOwnershipShardCommitCoordinator {
     private Cancellable retryCommitSchedule;
     private long transactionIDCounter = 0;
 
-    EntityOwnershipShardCommitCoordinator(MemberName localMemberName, Logger log) {
-        this.log = Preconditions.checkNotNull(log);
+    EntityOwnershipShardCommitCoordinator(final MemberName localMemberName, final Logger log) {
+        this.log = requireNonNull(log);
         historyId = new LocalHistoryIdentifier(
                 ClientIdentifier.create(FrontendIdentifier.create(localMemberName, FRONTEND_TYPE), 0), 0);
     }
 
-    boolean handleMessage(Object message, EntityOwnershipShard shard) {
+    boolean handleMessage(final Object message, final EntityOwnershipShard shard) {
         boolean handled = true;
         if (CommitTransactionReply.isSerializedType(message)) {
             // Successful reply from a local commit.
@@ -79,7 +79,7 @@ class EntityOwnershipShardCommitCoordinator {
         return handled;
     }
 
-    private void retryInflightCommit(EntityOwnershipShard shard) {
+    private void retryInflightCommit(final EntityOwnershipShard shard) {
         // Shouldn't be null happen but verify anyway
         if (inflightCommit == null) {
             return;
@@ -94,7 +94,7 @@ class EntityOwnershipShardCommitCoordinator {
         }
     }
 
-    void inflightCommitFailure(Throwable cause, EntityOwnershipShard shard) {
+    void inflightCommitFailure(final Throwable cause, final EntityOwnershipShard shard) {
         // This should've originated from a failed inflight commit but verify anyway
         if (inflightCommit == null) {
             return;
@@ -111,7 +111,7 @@ class EntityOwnershipShardCommitCoordinator {
         scheduleInflightCommitRetry(shard);
     }
 
-    private void scheduleInflightCommitRetry(EntityOwnershipShard shard) {
+    private void scheduleInflightCommitRetry(final EntityOwnershipShard shard) {
         FiniteDuration duration = shard.getDatastoreContext().getShardRaftConfig().getElectionTimeOutInterval();
 
         log.debug("Scheduling retry for BatchedModifications commit {} in {}",
@@ -121,7 +121,7 @@ class EntityOwnershipShardCommitCoordinator {
                 COMMIT_RETRY_MESSAGE, shard.getContext().dispatcher(), ActorRef.noSender());
     }
 
-    void inflightCommitSucceeded(EntityOwnershipShard shard) {
+    void inflightCommitSucceeded(final EntityOwnershipShard shard) {
         // Shouldn't be null but verify anyway
         if (inflightCommit == null) {
             return;
@@ -137,7 +137,7 @@ class EntityOwnershipShardCommitCoordinator {
         commitNextBatch(shard);
     }
 
-    void commitNextBatch(EntityOwnershipShard shard) {
+    void commitNextBatch(final EntityOwnershipShard shard) {
         if (inflightCommit != null || pendingModifications.isEmpty() || !shard.hasLeader()) {
             return;
         }
@@ -159,11 +159,11 @@ class EntityOwnershipShardCommitCoordinator {
         shard.tryCommitModifications(inflightCommit);
     }
 
-    void commitModification(Modification modification, EntityOwnershipShard shard) {
+    void commitModification(final Modification modification, final EntityOwnershipShard shard) {
         commitModifications(ImmutableList.of(modification), shard);
     }
 
-    void commitModifications(List<Modification> modifications, EntityOwnershipShard shard) {
+    void commitModifications(final List<Modification> modifications, final EntityOwnershipShard shard) {
         if (modifications.isEmpty()) {
             return;
         }
@@ -183,7 +183,7 @@ class EntityOwnershipShardCommitCoordinator {
         }
     }
 
-    void onStateChanged(EntityOwnershipShard shard, boolean isLeader) {
+    void onStateChanged(final EntityOwnershipShard shard, final boolean isLeader) {
         shard.possiblyRemoveAllInitialCandidates(shard.getLeader());
 
         possiblyPrunePendingCommits(shard, isLeader);
@@ -204,7 +204,7 @@ class EntityOwnershipShardCommitCoordinator {
         }
     }
 
-    private void possiblyPrunePendingCommits(EntityOwnershipShard shard, boolean isLeader) {
+    private void possiblyPrunePendingCommits(final EntityOwnershipShard shard, final boolean isLeader) {
         // If we were the leader and transitioned to follower, we'll try to forward pending commits to the new leader.
         // However certain commits, e.g. entity owner changes, should only be committed by a valid leader as the
         // criteria used to determine the commit may be stale. Since we're no longer a valid leader, we should not
@@ -226,7 +226,7 @@ class EntityOwnershipShardCommitCoordinator {
         }
     }
 
-    private @Nullable BatchedModifications pruneModifications(BatchedModifications toPrune) {
+    private @Nullable BatchedModifications pruneModifications(final BatchedModifications toPrune) {
         BatchedModifications prunedModifications = new BatchedModifications(toPrune.getTransactionId(),
                 toPrune.getVersion());
         prunedModifications.setDoCommitOnReady(toPrune.isDoCommitOnReady());
@@ -243,7 +243,7 @@ class EntityOwnershipShardCommitCoordinator {
         return !prunedModifications.getModifications().isEmpty() ? prunedModifications : null;
     }
 
-    private boolean canForwardModificationToNewLeader(Modification mod) {
+    private boolean canForwardModificationToNewLeader(final Modification mod) {
         // If this is a WRITE of entity owner we don't want to forward it to a new leader since the criteria used
         // to determine the new owner might be stale.
         if (mod instanceof WriteModification) {
index 8cd4f7853dd62fe9c0058f331817cb907aa352c8..cdb8c925eed7ba1831c88ca4d0fdc5f84eba8bdb 100644 (file)
@@ -5,10 +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.datastore.entityownership.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Collection;
 import org.opendaylight.controller.cluster.datastore.entityownership.selectionstrategy.EntityOwnerSelectionStrategy;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -21,13 +21,12 @@ public class SelectOwner {
     private final Collection<String> allCandidates;
     private final EntityOwnerSelectionStrategy ownerSelectionStrategy;
 
-    public SelectOwner(YangInstanceIdentifier entityPath, Collection<String> allCandidates,
-                       EntityOwnerSelectionStrategy ownerSelectionStrategy) {
-
-        this.entityPath = Preconditions.checkNotNull(entityPath, "entityPath should not be null");
-        this.allCandidates = Preconditions.checkNotNull(allCandidates, "allCandidates should not be null");
-        this.ownerSelectionStrategy = Preconditions.checkNotNull(ownerSelectionStrategy,
-                "ownerSelectionStrategy should not be null");
+    public SelectOwner(final YangInstanceIdentifier entityPath, final Collection<String> allCandidates,
+                       final EntityOwnerSelectionStrategy ownerSelectionStrategy) {
+        this.entityPath = requireNonNull(entityPath, "entityPath should not be null");
+        this.allCandidates = requireNonNull(allCandidates, "allCandidates should not be null");
+        this.ownerSelectionStrategy = requireNonNull(ownerSelectionStrategy,
+            "ownerSelectionStrategy should not be null");
     }
 
     public YangInstanceIdentifier getEntityPath() {
index 956fa36d102e0af0437d8a35286a2bb3f2ace891..7c206adc5859cc5117894ee72eb6e5bb1f62db9a 100644 (file)
@@ -5,10 +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.datastore.identifiers;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
@@ -24,9 +25,9 @@ public class ShardIdentifier {
     private final String fullName;
 
     ShardIdentifier(final String shardName, final MemberName memberName, final String type) {
-        this.shardName = Preconditions.checkNotNull(shardName, "shardName should not be null");
-        this.memberName = Preconditions.checkNotNull(memberName, "memberName should not be null");
-        this.type = Preconditions.checkNotNull(type, "type should not be null");
+        this.shardName = requireNonNull(shardName, "shardName should not be null");
+        this.memberName = requireNonNull(memberName, "memberName should not be null");
+        this.type = requireNonNull(type, "type should not be null");
 
         fullName = memberName.getName() + "-shard-" + shardName + "-" + type;
     }
@@ -37,7 +38,7 @@ public class ShardIdentifier {
 
     public static ShardIdentifier fromShardIdString(final String shardIdString) {
         final Matcher matcher = PATTERN.matcher(shardIdString);
-        Preconditions.checkArgument(matcher.matches(), "Invalid shard id \"%s\"", shardIdString);
+        checkArgument(matcher.matches(), "Invalid shard id \"%s\"", shardIdString);
 
         return new ShardIdentifier(matcher.group(2), MemberName.forName(matcher.group(1)), matcher.group(3));
     }
index ba00d0b7a5acee32b0c4db1e9b58e764e8d4bfa7..a830c799c87dba55f2235037412702a322af3069 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Stopwatch;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
@@ -33,7 +34,7 @@ class OnDemandShardStateCache {
     private volatile String stateRetrievalTime;
 
     OnDemandShardStateCache(final String shardName, final ActorRef shardActor) {
-        this.shardName = Preconditions.checkNotNull(shardName);
+        this.shardName = requireNonNull(shardName);
         this.shardActor = shardActor;
     }
 
index 282330d7a31d4fbfc5f71bd87144e2d4e28dc6f0..0dadd69e2f525b25ca94c846e5c0cf8600104779 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.dispatch.Futures;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -39,7 +40,7 @@ public class ShardDataTreeListenerInfoMXBeanImpl extends AbstractMXBean implemen
     public ShardDataTreeListenerInfoMXBeanImpl(final String shardName, final String mxBeanType,
             final ActorRef shardActor) {
         super(shardName, mxBeanType, JMX_CATEGORY);
-        stateCache = new OnDemandShardStateCache(shardName, Preconditions.checkNotNull(shardActor));
+        stateCache = new OnDemandShardStateCache(shardName, requireNonNull(shardActor));
     }
 
     @Override
index ba6b64f4c8ffffc3711a570e6e06ce8d60725895..3b45e642cadddfe36c853d3376ad1909133f86e5 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -28,7 +29,7 @@ public abstract class AbstractThreePhaseCommitMessage extends VersionedExternali
 
     protected AbstractThreePhaseCommitMessage(final TransactionIdentifier transactionId, final short version) {
         super(version);
-        this.transactionId = Preconditions.checkNotNull(transactionId);
+        this.transactionId = requireNonNull(transactionId);
     }
 
     public TransactionIdentifier getTransactionId() {
@@ -36,13 +37,13 @@ public abstract class AbstractThreePhaseCommitMessage extends VersionedExternali
     }
 
     @Override
-    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
         super.readExternal(in);
         transactionId = TransactionIdentifier.readFrom(in);
     }
 
     @Override
-    public void writeExternal(ObjectOutput out) throws IOException {
+    public void writeExternal(final ObjectOutput out) throws IOException {
         super.writeExternal(out);
         transactionId.writeTo(out);
     }
index 0846f7b1c92d35bf6129f6276110dbbf1ab9f75d..92d186a99f66c67966f5fe28548f0051dc89af9d 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableMap;
 import java.util.Map;
 
@@ -20,8 +21,8 @@ public class ChangeShardMembersVotingStatus {
     private final String shardName;
     private final Map<String, Boolean> meberVotingStatusMap;
 
-    public ChangeShardMembersVotingStatus(String shardName, Map<String, Boolean> meberVotingStatusMap) {
-        this.shardName = Preconditions.checkNotNull(shardName);
+    public ChangeShardMembersVotingStatus(final String shardName, final Map<String, Boolean> meberVotingStatusMap) {
+        this.shardName = requireNonNull(shardName);
         this.meberVotingStatusMap = ImmutableMap.copyOf(meberVotingStatusMap);
     }
 
index 2fe96cbe67eddf945dbb41e5bca1eae6aad554b1..1e96286eb984bc84e3fb0d7e63f4edb65847d718 100644 (file)
@@ -5,10 +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.datastore.messages;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -26,7 +27,7 @@ public class CloseTransactionChain extends VersionedExternalizableMessage
 
     public CloseTransactionChain(final LocalHistoryIdentifier transactionChainId, final short version) {
         super(version);
-        this.transactionChainId = Preconditions.checkNotNull(transactionChainId);
+        this.transactionChainId = requireNonNull(transactionChainId);
     }
 
     @Override
@@ -35,23 +36,23 @@ public class CloseTransactionChain extends VersionedExternalizableMessage
     }
 
     @Override
-    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
         super.readExternal(in);
         transactionChainId = LocalHistoryIdentifier.readFrom(in);
     }
 
     @Override
-    public void writeExternal(ObjectOutput out) throws IOException {
+    public void writeExternal(final ObjectOutput out) throws IOException {
         super.writeExternal(out);
         transactionChainId.writeTo(out);
     }
 
     public static CloseTransactionChain fromSerializable(final Object serializable) {
-        Preconditions.checkArgument(serializable instanceof CloseTransactionChain);
+        checkArgument(serializable instanceof CloseTransactionChain);
         return (CloseTransactionChain)serializable;
     }
 
-    public static boolean isSerializedType(Object message) {
+    public static boolean isSerializedType(final Object message) {
         return message instanceof CloseTransactionChain;
     }
 }
index 52e8824343fe1cafcf9398e58a340787ce2ea1e2..3283a55f438a77644fe35ad403436a2bfdac58f2 100644 (file)
@@ -5,10 +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.datastore.messages;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -23,9 +24,10 @@ public class CreateTransaction extends VersionedExternalizableMessage {
     public CreateTransaction() {
     }
 
-    public CreateTransaction(TransactionIdentifier transactionId, int transactionType, short version) {
+    public CreateTransaction(final TransactionIdentifier transactionId, final int transactionType,
+            final short version) {
         super(version);
-        this.transactionId = Preconditions.checkNotNull(transactionId);
+        this.transactionId = requireNonNull(transactionId);
         this.transactionType = transactionType;
     }
 
@@ -38,14 +40,14 @@ public class CreateTransaction extends VersionedExternalizableMessage {
     }
 
     @Override
-    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
         super.readExternal(in);
         transactionId = TransactionIdentifier.readFrom(in);
         transactionType = in.readInt();
     }
 
     @Override
-    public void writeExternal(ObjectOutput out) throws IOException {
+    public void writeExternal(final ObjectOutput out) throws IOException {
         super.writeExternal(out);
         transactionId.writeTo(out);
         out.writeInt(transactionType);
@@ -56,12 +58,12 @@ public class CreateTransaction extends VersionedExternalizableMessage {
         return "CreateTransaction [transactionId=" + transactionId + ", transactionType=" + transactionType + "]";
     }
 
-    public static CreateTransaction fromSerializable(Object message) {
-        Preconditions.checkArgument(message instanceof CreateTransaction);
+    public static CreateTransaction fromSerializable(final Object message) {
+        checkArgument(message instanceof CreateTransaction);
         return (CreateTransaction)message;
     }
 
-    public static boolean isSerializedType(Object message) {
+    public static boolean isSerializedType(final Object message) {
         return message instanceof CreateTransaction;
     }
 }
index ff2c89c8ddf72d6bcc2ebb280e639791ec6a0c3e..03ae771ca1a0f0ad43c2b9ccf52e062c095aa234 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Collection;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 
@@ -21,7 +22,7 @@ public final class DataTreeChanged {
     private final Collection<DataTreeCandidate> changes;
 
     public DataTreeChanged(final Collection<DataTreeCandidate> changes) {
-        this.changes = Preconditions.checkNotNull(changes);
+        this.changes = requireNonNull(changes);
     }
 
     /**
index 90db2794d32509755b4f5bf171cca72c1f06a911..62505d922475381021b70e4db0e22290012a90e4 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.beans.ConstructorProperties;
 
 /**
@@ -24,8 +25,8 @@ public class DataTreeListenerInfo {
     @ConstructorProperties({"listener","registeredPath", "isEnabled", "notificationCount"})
     public DataTreeListenerInfo(final String listener, final String registeredPath, final boolean isEnabled,
             final long notificationCount) {
-        this.listener = Preconditions.checkNotNull(listener);
-        this.registeredPath = Preconditions.checkNotNull(registeredPath);
+        this.listener = requireNonNull(listener);
+        this.registeredPath = requireNonNull(registeredPath);
         this.isEnabled = isEnabled;
         this.notificationCount = notificationCount;
     }
index 9eba5c66928297a7d54ff38a097fe45a12f11bac..52709dd705828d2080dbd588052f7a973279b4c9 100644 (file)
@@ -5,10 +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.datastore.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.io.Serializable;
 
 /**
@@ -20,11 +20,8 @@ public class FindPrimary implements Serializable {
     private final String shardName;
     private final boolean waitUntilReady;
 
-    public FindPrimary(String shardName, boolean waitUntilReady) {
-
-        Preconditions.checkNotNull(shardName, "shardName should not be null");
-
-        this.shardName = shardName;
+    public FindPrimary(final String shardName, final boolean waitUntilReady) {
+        this.shardName = requireNonNull(shardName, "shardName should not be null");
         this.waitUntilReady = waitUntilReady;
     }
 
index 24859a4d16998de4c8dbf92cf75cf5f59ed9bd84..a4c8d2e1be7c543e6aa635c7bc130a9fe961d05a 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
 
 /**
  * A local message sent to the ShardManager to flip the raft voting states for members of a shard.
@@ -17,8 +17,8 @@ import com.google.common.base.Preconditions;
 public class FlipShardMembersVotingStatus {
     private final String shardName;
 
-    public FlipShardMembersVotingStatus(String shardName) {
-        this.shardName = Preconditions.checkNotNull(shardName);
+    public FlipShardMembersVotingStatus(final String shardName) {
+        this.shardName = requireNonNull(shardName);
     }
 
     public String getShardName() {
index 53731fa49170ffd22aa39512deebd825f7e12c08..c44f9105c0c093e16005b13e888d37bf64a5b861 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.controller.cluster.datastore.messages;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ExtendedActorSystem;
 import akka.serialization.JSerializer;
 import akka.util.ClassLoaderObjectInputStream;
-import com.google.common.base.Preconditions;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import org.apache.commons.lang3.SerializationUtils;
@@ -27,7 +29,7 @@ public final class ReadyLocalTransactionSerializer extends JSerializer {
     private final ExtendedActorSystem system;
 
     public ReadyLocalTransactionSerializer(final ExtendedActorSystem system) {
-        this.system = Preconditions.checkNotNull(system);
+        this.system = requireNonNull(system);
     }
 
     @Override
@@ -42,7 +44,7 @@ public final class ReadyLocalTransactionSerializer extends JSerializer {
 
     @Override
     public byte[] toBinary(final Object obj) {
-        Preconditions.checkArgument(obj instanceof ReadyLocalTransaction, "Unsupported object type %s", obj.getClass());
+        checkArgument(obj instanceof ReadyLocalTransaction, "Unsupported object type %s", obj.getClass());
         final ReadyLocalTransaction readyLocal = (ReadyLocalTransaction) obj;
         final BatchedModifications batched = new BatchedModifications(readyLocal.getTransactionId(),
                 readyLocal.getRemoteVersion());
@@ -69,7 +71,7 @@ public final class ReadyLocalTransactionSerializer extends JSerializer {
         private final BatchedModifications message;
 
         BatchedCursor(final BatchedModifications message) {
-            this.message = Preconditions.checkNotNull(message);
+            this.message = requireNonNull(message);
         }
 
         @Override
index 7642a90c5f4efd6518e6f1145cb9bfe5f2f62a3b..7feb6c46e631f9a89a309e34cdc562358b88a4c1 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore.messages;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorPath;
 import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
 import java.io.Serializable;
 
 /**
@@ -23,7 +24,7 @@ public class RegisterDataTreeNotificationListenerReply implements Serializable {
     private final ActorRef listenerRegistrationPath;
 
     public RegisterDataTreeNotificationListenerReply(final ActorRef listenerRegistrationPath) {
-        this.listenerRegistrationPath = Preconditions.checkNotNull(listenerRegistrationPath);
+        this.listenerRegistrationPath = requireNonNull(listenerRegistrationPath);
     }
 
     public ActorPath getListenerRegistrationPath() {
index 640ce37245fe2db91108881df2af09180455d075..8ef201c314aa6a280129e1fce4b8a1a0a31cdf07 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.persisted;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Collection;
 import java.util.Optional;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -26,7 +27,7 @@ abstract class AbstractDataTreeCandidateNode implements DataTreeCandidateNode {
     private final ModificationType type;
 
     protected AbstractDataTreeCandidateNode(final ModificationType type) {
-        this.type = Preconditions.checkNotNull(type);
+        this.type = requireNonNull(type);
     }
 
     @Override
index 1f755506a5a77f69d1947065b3b569e43a9f5b3b..4ca35098c5b4d6189adf006ec3444de689397001 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.controller.cluster.datastore.persisted;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.io.ByteStreams;
 import java.io.DataInput;
@@ -40,7 +39,7 @@ public abstract class AbstractIdentifiablePayload<T extends Identifier>
         }
 
         protected AbstractProxy(final byte[] serialized) {
-            this.serialized = Preconditions.checkNotNull(serialized);
+            this.serialized = requireNonNull(serialized);
         }
 
         @Override
index 4d38c35d48edbc47be194b32ff4793acc8604c7d..aaa86413bee47533188e21b0662d3ebb77d13748 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore.persisted;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.io.ByteArrayDataOutput;
 import com.google.common.io.ByteStreams;
 import java.io.DataInput;
@@ -49,7 +50,7 @@ public final class CommitTransactionPayload extends Payload implements Serializa
         }
 
         Proxy(final byte[] serialized) {
-            this.serialized = Preconditions.checkNotNull(serialized);
+            this.serialized = requireNonNull(serialized);
         }
 
         @Override
@@ -75,7 +76,7 @@ public final class CommitTransactionPayload extends Payload implements Serializa
     private final byte[] serialized;
 
     CommitTransactionPayload(final byte[] serialized) {
-        this.serialized = Preconditions.checkNotNull(serialized);
+        this.serialized = requireNonNull(serialized);
     }
 
     public static CommitTransactionPayload create(final TransactionIdentifier transactionId,
index 4598f68a449c003e43e801af465d50c900f1f3d5..a3f41ed65ddfbfb21c4da06d804f1a0278db6c75 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore.persisted;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableRangeSet;
 import com.google.common.collect.ImmutableRangeSet.Builder;
@@ -33,7 +34,7 @@ public final class FrontendClientMetadata implements Identifiable<ClientIdentifi
 
     public FrontendClientMetadata(final ClientIdentifier identifier, final RangeSet<UnsignedLong> purgedHistories,
             final Collection<FrontendHistoryMetadata> currentHistories) {
-        this.identifier = Preconditions.checkNotNull(identifier);
+        this.identifier = requireNonNull(identifier);
         this.purgedHistories = ImmutableRangeSet.copyOf(purgedHistories);
         this.currentHistories = ImmutableList.copyOf(currentHistories);
     }
index 6820e1c885b0b6857523610dc26b1a0d1b4ea6db..2cede0db5ec61853a22860a99eee9ee023be014c 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.persisted;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Collection;
 import java.util.Optional;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -25,7 +26,7 @@ abstract class ModifiedDataTreeCandidateNode extends AbstractDataTreeCandidateNo
     private ModifiedDataTreeCandidateNode(final ModificationType type,
             final Collection<DataTreeCandidateNode> children) {
         super(type);
-        this.children = Preconditions.checkNotNull(children);
+        this.children = requireNonNull(children);
     }
 
     static DataTreeCandidateNode create(final ModificationType type, final Collection<DataTreeCandidateNode> children) {
index eb6ebb3d6220164290b24c8dbbe7d4d6e58869f6..0285b264c48a50201159c22adb96dee876e2ec1f 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore.shardmanager;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.Props;
-import com.google.common.base.Preconditions;
 import java.util.concurrent.CountDownLatch;
 import org.opendaylight.controller.cluster.datastore.AbstractDataStore;
 import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
@@ -37,14 +39,14 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
     }
 
     protected final void checkSealed() {
-        Preconditions.checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
+        checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
     }
 
     ClusterWrapper getCluster() {
         return cluster;
     }
 
-    public T cluster(ClusterWrapper newCluster) {
+    public T cluster(final ClusterWrapper newCluster) {
         checkSealed();
         this.cluster = newCluster;
         return self();
@@ -54,7 +56,7 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return configuration;
     }
 
-    public T configuration(Configuration newConfiguration) {
+    public T configuration(final Configuration newConfiguration) {
         checkSealed();
         this.configuration = newConfiguration;
         return self();
@@ -66,7 +68,7 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
 
     public T datastoreContextFactory(final DatastoreContextFactory newDatastoreContextFactory) {
         checkSealed();
-        this.datastoreContextFactory = Preconditions.checkNotNull(newDatastoreContextFactory);
+        this.datastoreContextFactory = requireNonNull(newDatastoreContextFactory);
         return self();
     }
 
@@ -84,7 +86,7 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return waitTillReadyCountDownLatch;
     }
 
-    public T waitTillReadyCountDownLatch(CountDownLatch newWaitTillReadyCountDownLatch) {
+    public T waitTillReadyCountDownLatch(final CountDownLatch newWaitTillReadyCountDownLatch) {
         checkSealed();
         this.waitTillReadyCountDownLatch = newWaitTillReadyCountDownLatch;
         return self();
@@ -94,7 +96,7 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return primaryShardInfoCache;
     }
 
-    public T primaryShardInfoCache(PrimaryShardInfoFutureCache newPrimaryShardInfoCache) {
+    public T primaryShardInfoCache(final PrimaryShardInfoFutureCache newPrimaryShardInfoCache) {
         checkSealed();
         this.primaryShardInfoCache = newPrimaryShardInfoCache;
         return self();
@@ -104,7 +106,7 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return restoreFromSnapshot;
     }
 
-    public T restoreFromSnapshot(DatastoreSnapshot newRestoreFromSnapshot) {
+    public T restoreFromSnapshot(final DatastoreSnapshot newRestoreFromSnapshot) {
         checkSealed();
         this.restoreFromSnapshot = newRestoreFromSnapshot;
         return self();
@@ -112,12 +114,12 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
 
     protected void verify() {
         sealed = true;
-        Preconditions.checkNotNull(cluster, "cluster should not be null");
-        Preconditions.checkNotNull(configuration, "configuration should not be null");
-        Preconditions.checkNotNull(datastoreContextFactory, "datastoreContextFactory should not be null");
-        Preconditions.checkNotNull(distributedDataStore, "distributedDataStore should not be null");
-        Preconditions.checkNotNull(waitTillReadyCountDownLatch, "waitTillReadyCountdownLatch should not be null");
-        Preconditions.checkNotNull(primaryShardInfoCache, "primaryShardInfoCache should not be null");
+        requireNonNull(cluster, "cluster should not be null");
+        requireNonNull(configuration, "configuration should not be null");
+        requireNonNull(datastoreContextFactory, "datastoreContextFactory should not be null");
+        requireNonNull(distributedDataStore, "distributedDataStore should not be null");
+        requireNonNull(waitTillReadyCountDownLatch, "waitTillReadyCountdownLatch should not be null");
+        requireNonNull(primaryShardInfoCache, "primaryShardInfoCache should not be null");
     }
 
     public Props props() {
index c1ccf65772e2575deed748822ac12bf404ab741c..270c99d86cb58396d36815748a1ff4fa96624aec 100644 (file)
@@ -13,7 +13,6 @@ import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.serialization.Serialization;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -278,7 +277,7 @@ final class ShardInformation {
     }
 
     void setSchemaContext(final SchemaContext schemaContext) {
-        schemaContextProvider.set(Preconditions.checkNotNull(schemaContext));
+        schemaContextProvider.set(requireNonNull(schemaContext));
     }
 
     @VisibleForTesting
index 43446b5ce2ce760d13c29a92e0a38c79acd74d9b..77a0e88393d4760cf251de4d1f4df7bcb904f97e 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.controller.cluster.datastore.shardmanager;
 
 import static akka.pattern.Patterns.ask;
+import static java.util.Objects.requireNonNull;
 
 import akka.actor.ActorRef;
 import akka.actor.Address;
@@ -34,7 +35,6 @@ import akka.persistence.SnapshotOffer;
 import akka.persistence.SnapshotSelectionCriteria;
 import akka.util.Timeout;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -1964,10 +1964,10 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
          */
         protected AutoFindPrimaryFailureResponseHandler(final ActorRef targetActor, final String shardName,
                 final String persistenceId, final ActorRef shardManagerActor) {
-            this.targetActor = Preconditions.checkNotNull(targetActor);
-            this.shardName = Preconditions.checkNotNull(shardName);
-            this.persistenceId = Preconditions.checkNotNull(persistenceId);
-            this.shardManagerActor = Preconditions.checkNotNull(shardManagerActor);
+            this.targetActor = requireNonNull(targetActor);
+            this.shardName = requireNonNull(shardName);
+            this.persistenceId = requireNonNull(persistenceId);
+            this.shardManagerActor = requireNonNull(shardManagerActor);
         }
 
         public ActorRef getTargetActor() {
index 219c5bb4958c6da4254eeff397c8b84f71c16b65..244b0a186cdaba4b3400a5be8dcc3d08e08d30ae 100644 (file)
@@ -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.datastore.shardmanager;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.pattern.Patterns;
-import com.google.common.base.Preconditions;
 import java.util.List;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
@@ -37,8 +37,8 @@ final class ShardManagerInfo extends AbstractMXBean implements ShardManagerInfoM
     ShardManagerInfo(final ActorRef shardManager, final MemberName memberName, final String name,
         final String mxBeanType) {
         super(name, mxBeanType, JMX_CATEGORY_SHARD_MANAGER);
-        this.shardManager = Preconditions.checkNotNull(shardManager);
-        this.memberName = Preconditions.checkNotNull(memberName);
+        this.shardManager = requireNonNull(shardManager);
+        this.memberName = requireNonNull(memberName);
     }
 
     @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch"})
index b1e9079f508669163b619fe67ebf7fd3c6b017bb..6c33652bb1a6cde93cad77ec48adbe4068289060 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore.shardmanager;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.Address;
 import akka.actor.AddressFromURIString;
-import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
@@ -35,17 +36,17 @@ class ShardPeerAddressResolver implements PeerAddressResolver {
     private final String shardManagerType;
     private final MemberName localMemberName;
 
-    ShardPeerAddressResolver(String shardManagerType, MemberName localMemberName) {
+    ShardPeerAddressResolver(final String shardManagerType, final MemberName localMemberName) {
         this.shardManagerIdentifier = ShardManagerIdentifier.builder().type(shardManagerType).build().toString();
         this.shardManagerType = shardManagerType;
-        this.localMemberName = Preconditions.checkNotNull(localMemberName);
+        this.localMemberName = requireNonNull(localMemberName);
     }
 
-    void addPeerAddress(MemberName memberName, Address address) {
+    void addPeerAddress(final MemberName memberName, final Address address) {
         memberNameToAddress.put(memberName, address);
     }
 
-    void removePeerAddress(MemberName memberName) {
+    void removePeerAddress(final MemberName memberName) {
         memberNameToAddress.remove(memberName);
     }
 
@@ -53,7 +54,7 @@ class ShardPeerAddressResolver implements PeerAddressResolver {
         return this.memberNameToAddress.keySet();
     }
 
-    Address getPeerAddress(MemberName memberName) {
+    Address getPeerAddress(final MemberName memberName) {
         return memberNameToAddress.get(memberName);
     }
 
@@ -68,11 +69,11 @@ class ShardPeerAddressResolver implements PeerAddressResolver {
         return peerAddresses;
     }
 
-    ShardIdentifier getShardIdentifier(MemberName memberName, String shardName) {
+    ShardIdentifier getShardIdentifier(final MemberName memberName, final String shardName) {
         return ShardIdentifier.create(shardName, memberName, shardManagerType);
     }
 
-    String getShardActorAddress(String shardName, MemberName memberName) {
+    String getShardActorAddress(final String shardName, final MemberName memberName) {
         Address memberAddress = memberNameToAddress.get(memberName);
         if (memberAddress != null) {
             return getShardManagerActorPathBuilder(memberAddress).append("/").append(
@@ -82,12 +83,12 @@ class ShardPeerAddressResolver implements PeerAddressResolver {
         return null;
     }
 
-    StringBuilder getShardManagerActorPathBuilder(Address address) {
+    StringBuilder getShardManagerActorPathBuilder(final Address address) {
         return new StringBuilder().append(address.toString()).append("/user/").append(shardManagerIdentifier);
     }
 
     @Override
-    public String resolve(String peerId) {
+    public String resolve(final String peerId) {
         if (peerId == null) {
             return null;
         }
@@ -97,7 +98,7 @@ class ShardPeerAddressResolver implements PeerAddressResolver {
     }
 
     @Override
-    public void setResolved(String peerId, String address) {
+    public void setResolved(final String peerId, final String address) {
         memberNameToAddress.put(ShardIdentifier.fromShardIdString(peerId).getMemberName(),
                 AddressFromURIString.parse(address));
     }
index e63ab9744514cf2fd94e4d822df3fc020ce52058..7b574530ee490824cf4f3a10343eea367cef6ef1 100644 (file)
@@ -5,10 +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.datastore.shardstrategy;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
@@ -21,16 +22,14 @@ public class ShardStrategyFactory {
     private final LogicalDatastoreType logicalStoreType;
 
     public ShardStrategyFactory(final Configuration configuration, final LogicalDatastoreType logicalStoreType) {
-        Preconditions.checkState(configuration != null, "configuration should not be missing");
+        checkState(configuration != null, "configuration should not be missing");
         this.configuration = configuration;
-        this.logicalStoreType = Preconditions.checkNotNull(logicalStoreType);
+        this.logicalStoreType = requireNonNull(logicalStoreType);
     }
 
     public ShardStrategy getStrategy(final YangInstanceIdentifier path) {
-        Preconditions.checkNotNull(path, "path should not be null");
-
         // try with the legacy module based shard mapping
-        final String moduleName = getModuleName(path);
+        final String moduleName = getModuleName(requireNonNull(path, "path should not be null"));
         final ShardStrategy shardStrategy = configuration.getStrategyForModule(moduleName);
         if (shardStrategy == null) {
             // retry with prefix based sharding
index eeb39eaef564ec53ad2494e60d1264bcb79cb579..a1499c5882dd1e7a6b37585885ba65170968a8e1 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore.utils;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableRangeSet;
 import com.google.common.collect.Range;
 import com.google.common.collect.RangeSet;
@@ -29,7 +30,7 @@ public final class UnsignedLongRangeSet implements Mutable {
     private final RangeSet<UnsignedLong> rangeset;
 
     private UnsignedLongRangeSet(final RangeSet<UnsignedLong> rangeset) {
-        this.rangeset = Preconditions.checkNotNull(rangeset);
+        this.rangeset = requireNonNull(rangeset);
     }
 
     public static UnsignedLongRangeSet create() {
index 4a36c386b146e9da1f7b1caaee95b1bf976e5def..1592dc7dd3259201d0133024557244a14e4c9e89 100644 (file)
@@ -5,10 +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.sharding;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Map;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
@@ -33,8 +33,8 @@ public class DistributedShardModification extends WriteableNodeWithSubshard {
                                         final Map<PathArgument, WriteableModificationNode> subshards,
                                         final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards) {
         super(subshards);
-        this.context = Preconditions.checkNotNull(context);
-        this.childShards = Preconditions.checkNotNull(childShards);
+        this.context = requireNonNull(context);
+        this.childShards = requireNonNull(childShards);
     }
 
     @Override
index 8fc1f4863d39ed4efd12b40e09cef6022301c2d8..37ac32ac3e9a154e0aa770f7c81daa6eb5df21f6 100644 (file)
@@ -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.sharding;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import java.util.Map;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
@@ -29,7 +29,7 @@ public final class DistributedShardModificationFactory {
     DistributedShardModificationFactory(final DOMDataTreeIdentifier root,
                                         final Map<PathArgument, WriteableModificationNode> children,
                                         final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards) {
-        this.root = Preconditions.checkNotNull(root);
+        this.root = requireNonNull(root);
         this.children = ImmutableMap.copyOf(children);
         this.childShards = ImmutableMap.copyOf(childShards);
     }
index 7dbdd290e69d9e6fa7be758c0d76b09387d78de2..d7d75c24754c02b0f518f58fdb0ec754fdcc3bf8 100644 (file)
@@ -5,16 +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.cluster.sharding;
 
 import static akka.actor.ActorRef.noSender;
+import static java.util.Objects.requireNonNull;
 import static org.opendaylight.controller.cluster.datastore.utils.ClusterUtils.SHARD_PREFIX_QNAME;
 import static org.opendaylight.controller.cluster.datastore.utils.ClusterUtils.SHARD_REPLICAS_QNAME;
 import static org.opendaylight.controller.cluster.datastore.utils.ClusterUtils.SHARD_REPLICA_QNAME;
 
 import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
 import java.util.Collection;
 import java.util.EnumMap;
 import java.util.List;
@@ -57,8 +56,8 @@ public class PrefixedShardConfigUpdateHandler {
             new EnumMap<>(LogicalDatastoreType.class);
 
     public PrefixedShardConfigUpdateHandler(final ActorRef handlingActor, final MemberName memberName) {
-        this.handlingActor = Preconditions.checkNotNull(handlingActor);
-        this.memberName = Preconditions.checkNotNull(memberName);
+        this.handlingActor = requireNonNull(handlingActor);
+        this.memberName = requireNonNull(memberName);
     }
 
     public void initListener(final AbstractDataStore dataStore, final LogicalDatastoreType type) {
index d33ad50c09396b69153371f2c8f2fb3771d68e3d..8ad10bc5e7e8c0dc1c86349fa775481e64830dc3 100644 (file)
@@ -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.sharding;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.Props;
-import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 import org.opendaylight.controller.cluster.dom.api.LeaderLocation;
 import org.opendaylight.controller.cluster.dom.api.LeaderLocationListener;
@@ -30,8 +30,8 @@ public final class RoleChangeListenerActor extends AbstractUntypedActor {
     private final ActorRef roleChangeNotifier;
 
     private RoleChangeListenerActor(final ActorRef roleChangeNotifier, final LeaderLocationListener listener) {
-        this.roleChangeNotifier = Preconditions.checkNotNull(roleChangeNotifier);
-        this.leaderLocationListener = Preconditions.checkNotNull(listener);
+        this.roleChangeNotifier = requireNonNull(roleChangeNotifier);
+        this.leaderLocationListener = requireNonNull(listener);
     }
 
     @Override
index a9a6ce836ef2ae0511d3fcdc368ba9b7d369360a..f60fac40598a9bf709ad90d84f81e8c71d9fe231 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.cluster.sharding;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -91,7 +92,7 @@ class ShardProxyTransaction implements DOMDataTreeShardWriteTransaction {
     private YangInstanceIdentifier toRelative(final YangInstanceIdentifier path) {
         final Optional<YangInstanceIdentifier> relative =
                 path.relativeTo(modification.getPrefix().getRootIdentifier());
-        Preconditions.checkArgument(relative.isPresent());
+        checkArgument(relative.isPresent());
         return relative.get();
     }
 
@@ -99,7 +100,7 @@ class ShardProxyTransaction implements DOMDataTreeShardWriteTransaction {
     public void ready() {
         LOG.debug("Readying transaction for shard {}", shardRoot);
 
-        Preconditions.checkNotNull(modification, "Attempting to ready an empty transaction.");
+        requireNonNull(modification, "Attempting to ready an empty transaction.");
 
         cohorts.add(modification.seal());
         for (Entry<DOMDataTreeIdentifier, ForeignShardModificationContext> entry
@@ -136,7 +137,7 @@ class ShardProxyTransaction implements DOMDataTreeShardWriteTransaction {
     }
 
     private void checkTransactionReadied() {
-        Preconditions.checkState(!cohorts.isEmpty(), "Transaction not readied yet");
+        checkState(!cohorts.isEmpty(), "Transaction not readied yet");
     }
 
     @Override
index bad52b3ec2cacd1464cccdfc9ecac8c1d34d2363..845104ea7b76310eddfd0f98e1ee3e8000b36dad 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.controller.cluster.sharding;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
@@ -25,7 +27,6 @@ import akka.cluster.Member;
 import akka.dispatch.OnComplete;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
-import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -812,11 +813,11 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor {
         }
 
         private void verify() {
-            Preconditions.checkNotNull(shardingService);
-            Preconditions.checkNotNull(actorSystem);
-            Preconditions.checkNotNull(cluster);
-            Preconditions.checkNotNull(distributedConfigDatastore);
-            Preconditions.checkNotNull(distributedOperDatastore);
+            requireNonNull(shardingService);
+            requireNonNull(actorSystem);
+            requireNonNull(cluster);
+            requireNonNull(distributedConfigDatastore);
+            requireNonNull(distributedOperDatastore);
         }
 
         public Props props() {
index b443a69e1f06de79aeeff862c8f86288dc85e88c..379940db6a6833ed00a47cad2d2050b543489b18 100644 (file)
@@ -5,11 +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.sharding;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.Address;
-import com.google.common.base.Preconditions;
 import java.util.Collection;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -60,11 +61,8 @@ public class ShardingServiceAddressResolver {
     }
 
     public String resolve(final MemberName memberName) {
-        Preconditions.checkNotNull(memberName);
-        final Address address = memberNameToAddress.get(memberName);
-        Preconditions.checkNotNull(address, "Requested member[%s] is not present in the resolver ",
-                memberName.toString());
-
+        final Address address = memberNameToAddress.get(requireNonNull(memberName));
+        checkNotNull(address, "Requested member[%s] is not present in the resolver", memberName);
         return getActorPathBuilder(address).toString();
     }
 }
index 9ea641c865d7e97604d9eb9f47bf4f35f750f5cc..eafb0b903177ecf90d4fcd8d296a7d1a8c2a068e 100644 (file)
@@ -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.sharding.messages;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import java.io.Serializable;
 import org.opendaylight.controller.cluster.sharding.ShardedDataTreeActor;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
@@ -26,7 +26,7 @@ public class LookupPrefixShard implements Serializable {
     private final DOMDataTreeIdentifier prefix;
 
     public LookupPrefixShard(final DOMDataTreeIdentifier prefix) {
-        this.prefix = Preconditions.checkNotNull(prefix);
+        this.prefix = requireNonNull(prefix);
     }
 
     public DOMDataTreeIdentifier getPrefix() {
index fb7f01764260edd10bca4bbb4b9956504bdaaf18..833fd0ea64185686723a678f5e821cb7536f99da 100644 (file)
@@ -5,11 +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.sharding.messages;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import java.io.Serializable;
 import java.util.Collection;
@@ -27,7 +25,7 @@ public class NotifyProducerCreated implements Serializable {
     private final Collection<DOMDataTreeIdentifier> subtrees;
 
     public NotifyProducerCreated(final Collection<DOMDataTreeIdentifier> subtrees) {
-        this.subtrees = ImmutableList.copyOf(Preconditions.checkNotNull(subtrees));
+        this.subtrees = ImmutableList.copyOf(subtrees);
     }
 
     public Collection<DOMDataTreeIdentifier> getSubtrees() {
index 24d871edad254c538d2a0c3a241e62e13127ff9c..18af2c79cdb5a702115f62b03367e480f548fb5f 100644 (file)
@@ -5,11 +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.sharding.messages;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import java.io.Serializable;
 import java.util.Collection;
@@ -27,7 +25,7 @@ public class NotifyProducerRemoved implements Serializable {
     private final Collection<DOMDataTreeIdentifier> subtrees;
 
     public NotifyProducerRemoved(final Collection<DOMDataTreeIdentifier> subtrees) {
-        this.subtrees = ImmutableList.copyOf(Preconditions.checkNotNull(subtrees));
+        this.subtrees = ImmutableList.copyOf(subtrees);
     }
 
     public Collection<DOMDataTreeIdentifier> getSubtrees() {
index d6a4319c0b301ea8493fab1ef2cf6a71afae6bfc..de49217d3a959c15eb95575fc6a8c81a89a02496 100644 (file)
@@ -5,10 +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.sharding.messages;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.controller.cluster.sharding.ShardedDataTreeActor;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 
@@ -17,12 +17,10 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
  * the system entirely the actor responds with a success.
  */
 public class PrefixShardRemovalLookup {
-
     private final DOMDataTreeIdentifier prefix;
 
     public PrefixShardRemovalLookup(final DOMDataTreeIdentifier prefix) {
-
-        this.prefix = Preconditions.checkNotNull(prefix);
+        this.prefix = requireNonNull(prefix);
     }
 
     public DOMDataTreeIdentifier getPrefix() {
@@ -31,8 +29,6 @@ public class PrefixShardRemovalLookup {
 
     @Override
     public String toString() {
-        return "PrefixShardRemovalLookup{"
-                + "prefix=" + prefix
-                + '}';
+        return "PrefixShardRemovalLookup{" + "prefix=" + prefix + '}';
     }
 }
index 14866d447a785cef63bf7f97c6195db59a5bea86..6d661e6aa22839d060974bd924bc6ed6ceff869d 100644 (file)
@@ -23,7 +23,6 @@ import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL
 
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Map;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
@@ -157,7 +156,7 @@ public class DatastoreContextIntrospectorTest {
         updated = introspector.update(null);
         assertFalse("updated", updated);
 
-        updated = introspector.update(new Hashtable<>());
+        updated = introspector.update(new HashMap<>());
         assertFalse("updated", updated);
     }
 
index 35ddd7e7792493a24dc9e78677638310d6e8c8ee..ab7de92484b2c2c28843f9bc690b7f5e6d859d3d 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static java.util.Objects.requireNonNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -17,12 +18,11 @@ import akka.cluster.Cluster;
 import akka.cluster.ClusterEvent.CurrentClusterState;
 import akka.cluster.Member;
 import akka.cluster.MemberStatus;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Stopwatch;
-import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Uninterruptibles;
 import com.typesafe.config.Config;
 import com.typesafe.config.ConfigFactory;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
@@ -157,7 +157,7 @@ public class MemberNode {
 
     public static void verifyRaftPeersPresent(final AbstractDataStore datastore, final String shardName,
             final String... peerMemberNames) throws Exception {
-        final Set<String> peerIds = Sets.newHashSet();
+        final Set<String> peerIds = new HashSet<>();
         for (String p: peerMemberNames) {
             peerIds.add(ShardIdentifier.create(shardName, MemberName.forName(p),
                 datastore.getActorUtils().getDataStoreName()).toString());
@@ -278,9 +278,9 @@ public class MemberNode {
         }
 
         public MemberNode build() throws Exception {
-            Preconditions.checkNotNull(moduleShardsConfig, "moduleShardsConfig must be specified");
-            Preconditions.checkNotNull(akkaConfig, "akkaConfig must be specified");
-            Preconditions.checkNotNull(testName, "testName must be specified");
+            requireNonNull(moduleShardsConfig, "moduleShardsConfig must be specified");
+            requireNonNull(akkaConfig, "akkaConfig must be specified");
+            requireNonNull(testName, "testName must be specified");
 
             if (schemaContext == null) {
                 schemaContext = SchemaContextHelper.full();
index 35cb8ed6294fc365f8fea4cbdfade63289b1c335..731aa72604f00ad87c3befe6c561fef459a6b3d9 100644 (file)
@@ -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.datastore;
 
 import static org.junit.Assert.assertEquals;
@@ -34,12 +33,12 @@ import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking
 import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.immediatePreCommit;
 
 import com.google.common.base.Ticker;
-import com.google.common.collect.Maps;
 import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.FutureCallback;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -199,7 +198,7 @@ public class ShardDataTreeTest extends AbstractTest {
 
         shardDataTree.applySnapshot(newDataTree.takeStateSnapshot());
 
-        Map<YangInstanceIdentifier, ModificationType> expChanges = Maps.newHashMap();
+        Map<YangInstanceIdentifier, ModificationType> expChanges = new HashMap<>();
         expChanges.put(CarsModel.newCarPath("optima"), ModificationType.WRITE);
         expChanges.put(CarsModel.newCarPath("murano"), ModificationType.WRITE);
         expChanges.put(CarsModel.newCarPath("sportage"), ModificationType.DELETE);
index b7a303e8d2eec6729e8952065566923f1fc152bd..13d3882a04b0fe0681d3bc7c4cd2cf1bc10ab2a1 100644 (file)
@@ -5,9 +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.datastore;
 
+import static java.util.Objects.requireNonNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
@@ -22,7 +22,6 @@ import akka.dispatch.Futures;
 import akka.testkit.TestActorRef;
 import com.codahale.metrics.Snapshot;
 import com.codahale.metrics.Timer;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
@@ -383,7 +382,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest {
             private final TransactionIdentifier transactionId;
 
             Builder(final TransactionIdentifier transactionId) {
-                this.transactionId = Preconditions.checkNotNull(transactionId);
+                this.transactionId = requireNonNull(transactionId);
             }
 
             Builder expectCanCommit(final Class<?> newExpCanCommitType, final Object newCanCommitReply) {
index 1efb1e9df4a8fa31f51b691653c73907a20d13b3..9a0234768994fd446c5af6c03268e356078db961 100644 (file)
@@ -43,7 +43,6 @@ import akka.serialization.Serialization;
 import akka.testkit.TestActorRef;
 import akka.testkit.javadsl.TestKit;
 import akka.util.Timeout;
-import com.google.common.base.Function;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
@@ -64,6 +63,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.function.Consumer;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -1363,10 +1363,8 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         assertEquals("getType", shardMrgIDSuffix, datastoreSnapshot.getType());
         assertNull("Expected null ShardManagerSnapshot", datastoreSnapshot.getShardManagerSnapshot());
 
-        Function<ShardSnapshot, String> shardNameTransformer = ShardSnapshot::getName;
-
         assertEquals("Shard names", Sets.newHashSet("shard1", "shard2"), Sets.newHashSet(
-            datastoreSnapshot.getShardSnapshots().stream().map(shardNameTransformer).collect(Collectors.toSet())));
+            datastoreSnapshot.getShardSnapshots().stream().map(ShardSnapshot::getName).collect(Collectors.toSet())));
 
         // Add a new replica
 
@@ -1387,7 +1385,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         datastoreSnapshot = expectMsgClassOrFailure(DatastoreSnapshot.class, kit, "GetSnapshot");
 
         assertEquals("Shard names", Sets.newHashSet("shard1", "shard2", "astronauts"), Sets.newHashSet(
-                Lists.transform(datastoreSnapshot.getShardSnapshots(), shardNameTransformer)));
+                Lists.transform(datastoreSnapshot.getShardSnapshots(), ShardSnapshot::getName)));
 
         ShardManagerSnapshot snapshot = datastoreSnapshot.getShardManagerSnapshot();
         assertNotNull("Expected ShardManagerSnapshot", snapshot);
index b4f725a3c4d58958a66b028794c8afdbe89993c4..1f60cdfae43da6ca9499268932aa0493299aa205 100644 (file)
@@ -29,11 +29,11 @@ import akka.japi.Creator;
 import akka.testkit.TestActorRef;
 import akka.testkit.javadsl.TestKit;
 import akka.util.Timeout;
-import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.typesafe.config.ConfigFactory;
 import java.time.Duration;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
@@ -74,10 +74,9 @@ public class ActorUtilsTest extends AbstractActorTest {
     }
 
     private static final class MockShardManager extends UntypedAbstractActor {
-
+        private final Map<String,Object> findPrimaryResponses = new HashMap<>();
         private final boolean found;
         private final ActorRef actorRef;
-        private final Map<String,Object> findPrimaryResponses = Maps.newHashMap();
 
         private MockShardManager(final boolean found, final ActorRef actorRef) {
 
index d3b0e4828a399636ebbd397e85f5ccd4ad9b5de8..4924e092babcef803a6014478843487c382f5c20 100644 (file)
@@ -5,10 +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.md.sal.dom.broker.impl;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import java.util.Collection;
 import java.util.Map;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
@@ -45,8 +46,8 @@ abstract class AbstractDOMForwardedCompositeTransaction<K, T extends DOMStoreTra
      *            Key,value map of backing transactions.
      */
     protected AbstractDOMForwardedCompositeTransaction(final Object identifier, final Map<K, T> backingTxs) {
-        this.identifier = Preconditions.checkNotNull(identifier, "Identifier should not be null");
-        this.backingTxs = Preconditions.checkNotNull(backingTxs, "Backing transactions should not be null");
+        this.identifier = requireNonNull(identifier, "Identifier should not be null");
+        this.backingTxs = requireNonNull(backingTxs, "Backing transactions should not be null");
     }
 
     /**
@@ -60,10 +61,8 @@ abstract class AbstractDOMForwardedCompositeTransaction<K, T extends DOMStoreTra
      *             if no subtransaction is associated with key.
      */
     protected final T getSubtransaction(final K key) {
-        Preconditions.checkNotNull(key, "key must not be null.");
-
-        final T ret = backingTxs.get(key);
-        Preconditions.checkArgument(ret != null, "No subtransaction associated with %s", key);
+        final T ret = backingTxs.get(requireNonNull(key, "key must not be null."));
+        checkArgument(ret != null, "No subtransaction associated with %s", key);
         return ret;
     }
 
index b65d5217b6e2d20160294c06bcf22f1a0d1e3719..f928fa2a163eacf7e108669585dbd99a72079fd1 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import com.google.common.collect.Maps;
@@ -33,8 +34,8 @@ abstract class AbstractDOMRpcRoutingTableEntry {
 
     AbstractDOMRpcRoutingTableEntry(final SchemaPath schemaPath,
         final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) {
-        this.schemaPath = Preconditions.checkNotNull(schemaPath);
-        this.implementations = Preconditions.checkNotNull(implementations);
+        this.schemaPath = requireNonNull(schemaPath);
+        this.implementations = requireNonNull(implementations);
     }
 
     final SchemaPath getSchemaPath() {
index ea581ee89a958dec12aef308ae76d9ec92c971cf..fec0a7687fb01cc94a9f2c519a59aaaa994bbede 100644 (file)
@@ -5,10 +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;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.Supplier;
 import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.Futures;
@@ -45,8 +45,8 @@ final class CommitCoordinationTask<T> implements Callable<T> {
             final Collection<DOMStoreThreePhaseCommitCohort> cohorts,
             final DurationStatisticsTracker commitStatTracker,
             final Supplier<T> futureValueSupplier) {
-        this.tx = Preconditions.checkNotNull(transaction, "transaction must not be null");
-        this.cohorts = Preconditions.checkNotNull(cohorts, "cohorts must not be null");
+        this.tx = requireNonNull(transaction, "transaction must not be null");
+        this.cohorts = requireNonNull(cohorts, "cohorts must not be null");
         this.commitStatTracker = commitStatTracker;
         this.futureValueSupplier = futureValueSupplier;
     }
index d75ad263f5d1bff02eb5b8e4ed3730ce6d9c48fa..6e11c5f5bf5d469509584c56c83711509ccb3c1f 100755 (executable)
@@ -5,10 +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.md.sal.dom.broker.impl;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.Supplier;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -71,12 +72,12 @@ final class DOMDataBrokerTransactionChainImpl extends
                                              final TransactionChainListener listener) {
         super(chains);
         this.chainId = chainId;
-        this.broker = Preconditions.checkNotNull(broker);
-        this.listener = Preconditions.checkNotNull(listener);
+        this.broker = requireNonNull(broker);
+        this.listener = requireNonNull(listener);
     }
 
     private void checkNotFailed() {
-        Preconditions.checkState(state != State.FAILED, "Transaction chain has failed");
+        checkState(state != State.FAILED, "Transaction chain has failed");
     }
 
     @Override
index 19570a2fa2b0f97cca7563699a9890629bf03d75..27267b969ff7cbbbda2a20acb77f431d098ced60 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.Supplier;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.Futures;
@@ -85,7 +87,7 @@ class DOMForwardedWriteTransaction<T extends DOMStoreWriteTransaction> extends
     protected DOMForwardedWriteTransaction(final Object identifier, final Map<LogicalDatastoreType, T> backingTxs,
                                            final AbstractDOMForwardedTransactionFactory<?> commitImpl) {
         super(identifier, backingTxs);
-        this.commitImpl = Preconditions.checkNotNull(commitImpl, "commitImpl must not be null.");
+        this.commitImpl = requireNonNull(commitImpl, "commitImpl must not be null.");
     }
 
     @Override
@@ -134,7 +136,7 @@ class DOMForwardedWriteTransaction<T extends DOMStoreWriteTransaction> extends
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
-    private <V> ListenableFuture<V> doCommit(Supplier<V> futureValueSupplier) {
+    private <V> ListenableFuture<V> doCommit(final Supplier<V> futureValueSupplier) {
         final AbstractDOMForwardedTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
         checkRunning(impl);
 
@@ -157,6 +159,6 @@ class DOMForwardedWriteTransaction<T extends DOMStoreWriteTransaction> extends
     }
 
     private void checkRunning(final AbstractDOMForwardedTransactionFactory<?> impl) {
-        Preconditions.checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
+        checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
     }
 }
index c241c95015523d8467dcb4960336d440378f7131..47ff2c286958edacf8f6519bc355c5e2ef1c38a3 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import com.lmax.disruptor.EventFactory;
@@ -40,8 +41,8 @@ final class DOMNotificationRouterEvent {
     ListenableFuture<Void> initialize(final DOMNotification notification,
                                       final Collection<ListenerRegistration<? extends DOMNotificationListener>>
                                               subscribers) {
-        this.notification = Preconditions.checkNotNull(notification);
-        this.subscribers = Preconditions.checkNotNull(subscribers);
+        this.notification = requireNonNull(notification);
+        this.subscribers = requireNonNull(subscribers);
         this.future = SettableFuture.create();
         return this.future;
     }
index 6e6d45b3c02285c547403d756b7770ea4c555666..724276f6b8a954f0457486f54297f04ca9064308 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import com.google.common.collect.LinkedListMultimap;
@@ -47,7 +48,7 @@ final class DOMRpcRoutingTable {
 
     private DOMRpcRoutingTable(final Map<SchemaPath, AbstractDOMRpcRoutingTableEntry> rpcs,
                                final SchemaContext schemaContext) {
-        this.rpcs = Preconditions.checkNotNull(rpcs);
+        this.rpcs = requireNonNull(rpcs);
         this.schemaContext = schemaContext;
     }
 
index 6819fdd6453ac4c614a6ab94095debbdb8984581..d616fb896ba400601d52841905e2d077a936801d 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.List;
 import java.util.Map;
@@ -26,7 +27,7 @@ final class GlobalDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntr
     private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId,
                                           final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
         super(rpcId.getType(), impls);
-        this.rpcId = Preconditions.checkNotNull(rpcId);
+        this.rpcId = requireNonNull(rpcId);
     }
 
     // We do not need the RpcDefinition, but this makes sure we do not
index 1ca312489b454a1f7bb9a84be73b71ec98fb552c..22625ed156616984f84b6d90ee79664518aea0d3 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
@@ -28,7 +29,7 @@ final class PingPongTransaction implements FutureCallback<CommitInfo> {
     private DOMDataReadWriteTransaction frontendTransaction;
 
     PingPongTransaction(final DOMDataReadWriteTransaction delegate) {
-        this.delegate = Preconditions.checkNotNull(delegate);
+        this.delegate = requireNonNull(delegate);
         future = SettableFuture.create();
     }
 
index ae34b9101741fc0ece5961e6f442497e69352fb5..b4ae1cf55997b54de2cf2f9516ff21163cfdbb40 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import java.util.List;
@@ -34,14 +35,14 @@ final class RoutedDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntr
     private RoutedDOMRpcRoutingTableEntry(final DOMRpcIdentifier globalRpcId, final YangInstanceIdentifier keyId,
                                           final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
         super(globalRpcId.getType(), impls);
-        this.keyId = Preconditions.checkNotNull(keyId);
-        this.globalRpcId = Preconditions.checkNotNull(globalRpcId);
+        this.keyId = requireNonNull(keyId);
+        this.globalRpcId = requireNonNull(globalRpcId);
     }
 
     RoutedDOMRpcRoutingTableEntry(final RpcDefinition def, final YangInstanceIdentifier keyId,
                                   final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
         super(def.getPath(), impls);
-        this.keyId = Preconditions.checkNotNull(keyId);
+        this.keyId = requireNonNull(keyId);
         this.globalRpcId = DOMRpcIdentifier.create(def.getPath());
     }
 
index 1d5912cc6a23b917f1844026f650efb1237e56d8..b28ca701a2d1e4f824c25c72852588223f397116 100644 (file)
@@ -5,10 +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.md.sal.dom.broker.impl;
 
-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.Supplier;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -55,7 +56,7 @@ public class SerializedDOMDataBroker extends AbstractDOMDataBroker {
     public SerializedDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores,
                                    final ListeningExecutorService executor) {
         super(datastores);
-        this.executor = Preconditions.checkNotNull(executor, "executor must not be null.");
+        this.executor = requireNonNull(executor, "executor must not be null.");
     }
 
     public DurationStatisticsTracker getCommitStatsTracker() {
@@ -65,8 +66,8 @@ public class SerializedDOMDataBroker extends AbstractDOMDataBroker {
     @Override
     protected <T> ListenableFuture<T> commit(final DOMDataWriteTransaction transaction,
             final Collection<DOMStoreThreePhaseCommitCohort> cohorts, final Supplier<T> futureValueSupplier) {
-        Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
-        Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
+        checkArgument(transaction != null, "Transaction must not be null.");
+        checkArgument(cohorts != null, "Cohorts must not be null.");
         LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
 
         ListenableFuture<T> commitFuture;
index 4d7ff0a78b8eb2b169394b02732aa45f540a009e..747d8a02a7062e6a5f0718f2c572db8fc046202c 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
 
 import java.util.Collections;
 import java.util.Map;
@@ -45,8 +45,8 @@ public class LegacyShardedDOMDataBrokerAdapter implements DOMDataBroker {
 
     public LegacyShardedDOMDataBrokerAdapter(final ShardedDOMDataBrokerAdapter delegateDataBroker,
                                              final DOMSchemaService schemaService) {
-        this.delegateDataBroker = checkNotNull(delegateDataBroker);
-        this.schemaService = checkNotNull(schemaService);
+        this.delegateDataBroker = requireNonNull(delegateDataBroker);
+        this.schemaService = requireNonNull(schemaService);
     }
 
     @Override
index 59df7239cff90b95bfb7220613a1cb406e3b68be..d73a71df918e13df684aaf6184d1f7c1c110bcd1 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
@@ -37,8 +37,8 @@ class ShardedDOMDataBrokerDelegatingReadTransaction implements DOMDataReadOnlyTr
 
     ShardedDOMDataBrokerDelegatingReadTransaction(final Object txIdentifier,
                                                          final DOMDataTreeReadTransaction delegateTx) {
-        this.delegateTx = checkNotNull(delegateTx);
-        this.txIdentifier = checkNotNull(txIdentifier);
+        this.delegateTx = requireNonNull(delegateTx);
+        this.txIdentifier = requireNonNull(txIdentifier);
     }
 
     @Override
index 48b56954adb544e0b5f24c179f93d9348d1a9ece..e2bf680014038563acb4eebe7d6e8391d6ab3f2f 100644 (file)
@@ -13,7 +13,6 @@ import static java.util.Objects.requireNonNull;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
@@ -21,6 +20,8 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
+import java.util.EnumMap;
+import java.util.LinkedList;
 import java.util.Map;
 import java.util.Queue;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -70,7 +71,7 @@ class ShardedDOMDataBrokerDelegatingReadWriteTransaction implements DOMDataReadW
         this.readTxDelegate = requireNonNull(readTxDelegate);
         this.writeTxDelegate = requireNonNull(writeTxDelegate);
         this.txIdentifier = requireNonNull(readWriteTxId);
-        this.initialReadMap = Maps.newEnumMap(LogicalDatastoreType.class);
+        this.initialReadMap = new EnumMap<>(LogicalDatastoreType.class);
 
         final InMemoryDataTreeFactory treeFactory = new InMemoryDataTreeFactory();
         final ImmutableMap.Builder<LogicalDatastoreType, DataTreeSnapshot> snapshotMapBuilder = ImmutableMap.builder();
@@ -81,7 +82,7 @@ class ShardedDOMDataBrokerDelegatingReadWriteTransaction implements DOMDataReadW
             tree.setSchemaContext(ctx);
             snapshotMapBuilder.put(store, tree.takeSnapshot());
 
-            modificationHistoryMapBuilder.put(store, Lists.newLinkedList());
+            modificationHistoryMapBuilder.put(store, new LinkedList<>());
         }
 
         modificationHistoryMap = modificationHistoryMapBuilder.build();
index 57e1116fa14379911242bb3406546a7a7e2e64a9..103fe394ddc72f744891fb16ceb6b8f83a692a6c 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapte
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
@@ -27,14 +27,13 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 @Deprecated
 class ShardedDOMDataBrokerDelegatingTransactionChain implements DOMTransactionChain, DOMTransactionChainListener {
+    private final Map<Object, AsyncTransaction<?, ?>> transactionMap = new HashMap<>();
     private final org.opendaylight.mdsal.dom.api.DOMTransactionChain txChainDelegate;
     private final SchemaContext schemaContext;
     private final TransactionChainListener txChainListener;
     private final Object txChainIdentifier;
     private final AtomicLong txNum = new AtomicLong();
 
-    private final Map<Object, AsyncTransaction<?, ?>> transactionMap;
-
     ShardedDOMDataBrokerDelegatingTransactionChain(final Object txChainIdentifier,
                                                           final SchemaContext schemaContext,
                                                           final org.opendaylight.mdsal.dom.api.DOMDataBroker
@@ -45,7 +44,6 @@ class ShardedDOMDataBrokerDelegatingTransactionChain implements DOMTransactionCh
         this.txChainIdentifier = requireNonNull(txChainIdentifier);
         this.txChainListener = requireNonNull(txChainListener);
         this.txChainDelegate = brokerDelegate.createTransactionChain(this);
-        transactionMap = Maps.newHashMap();
     }
 
     @Override
@@ -93,13 +91,13 @@ class ShardedDOMDataBrokerDelegatingTransactionChain implements DOMTransactionCh
     }
 
     @Override
-    public void onTransactionChainFailed(org.opendaylight.mdsal.dom.api.DOMTransactionChain chain,
-            DOMDataTreeTransaction transaction, Throwable cause) {
+    public void onTransactionChainFailed(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain,
+            final DOMDataTreeTransaction transaction, final Throwable cause) {
         txChainListener.onTransactionChainFailed(this, transactionFromDelegate(transaction.getIdentifier()), cause);
     }
 
     @Override
-    public void onTransactionChainSuccessful(org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) {
+    public void onTransactionChainSuccessful(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) {
         txChainListener.onTransactionChainSuccessful(this);
     }
 
index 32aa222ac464a2c4f127d41f58698951f4832b2f..25019ff3d55603c02a547b9b90205b5b63423a8c 100644 (file)
@@ -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.legacy.sharded.adapter;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
 
 import com.google.common.util.concurrent.FluentFuture;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -24,9 +23,9 @@ class ShardedDOMDataBrokerDelegatingWriteTransaction implements DOMDataWriteTran
     private final Object txIdentifier;
 
     ShardedDOMDataBrokerDelegatingWriteTransaction(final Object txIdentifier,
-                                                          final DOMDataTreeWriteTransaction delegateTx) {
-        this.delegateTx = checkNotNull(delegateTx);
-        this.txIdentifier = checkNotNull(txIdentifier);
+                                                   final DOMDataTreeWriteTransaction delegateTx) {
+        this.delegateTx = requireNonNull(delegateTx);
+        this.txIdentifier = requireNonNull(txIdentifier);
     }
 
     @Override
index 0f8d2a70e31afc072bee7320eff8eee047c28a03..96bf5a8b64da2388b87b86a04faf94687f037a60 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.spi.rpc;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -18,13 +19,13 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 
 @Deprecated
 public abstract class RpcRoutingStrategy implements Identifiable<QName> {
-
     private static final QName CONTEXT_REFERENCE = QName.create("urn:opendaylight:yang:extension:yang-ext",
             "2013-07-09", "context-reference").intern();
+
     private final QName identifier;
 
     private RpcRoutingStrategy(final QName identifier) {
-        this.identifier = Preconditions.checkNotNull(identifier);
+        this.identifier = requireNonNull(identifier);
     }
 
     /**
@@ -85,8 +86,8 @@ public abstract class RpcRoutingStrategy implements Identifiable<QName> {
 
         private RoutedRpcStrategy(final QName identifier, final QName ctx, final QName leaf) {
             super(identifier);
-            this.context = Preconditions.checkNotNull(ctx);
-            this.leaf = Preconditions.checkNotNull(leaf);
+            this.context = requireNonNull(ctx);
+            this.leaf = requireNonNull(leaf);
         }
 
         @Override
index d967e93a7a02a54c9d393d5579485058abc21c9a..5a47b975203fe05d43fb405e3b10b898d167ae19 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.controller.sal.core.spi.data;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import java.util.AbstractMap.SimpleEntry;
 import java.util.Map.Entry;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
@@ -43,11 +45,11 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         private final AbstractSnapshotBackedTransactionChain<?> chain;
 
         Idle(final AbstractSnapshotBackedTransactionChain<?> chain) {
-            this.chain = Preconditions.checkNotNull(chain);
+            this.chain = requireNonNull(chain);
         }
 
         @Override
-        protected DataTreeSnapshot getSnapshot(Object transactionId) {
+        protected DataTreeSnapshot getSnapshot(final Object transactionId) {
             return chain.takeSnapshot();
         }
     }
@@ -62,7 +64,7 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         private volatile DataTreeSnapshot snapshot;
 
         Allocated(final DOMStoreWriteTransaction transaction) {
-            this.transaction = Preconditions.checkNotNull(transaction);
+            this.transaction = requireNonNull(transaction);
         }
 
         public DOMStoreWriteTransaction getTransaction() {
@@ -70,9 +72,9 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         }
 
         @Override
-        protected DataTreeSnapshot getSnapshot(Object transactionId) {
+        protected DataTreeSnapshot getSnapshot(final Object transactionId) {
             final DataTreeSnapshot ret = snapshot;
-            Preconditions.checkState(ret != null,
+            checkState(ret != null,
                     "Could not get snapshot for transaction %s - previous transaction %s is not ready yet",
                     transactionId, transaction.getIdentifier());
             return ret;
@@ -80,8 +82,7 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
 
         void setSnapshot(final DataTreeSnapshot snapshot) {
             final boolean success = SNAPSHOT_UPDATER.compareAndSet(this, null, snapshot);
-            Preconditions.checkState(success, "Transaction %s has already been marked as ready",
-                    transaction.getIdentifier());
+            checkState(success, "Transaction %s has already been marked as ready", transaction.getIdentifier());
         }
     }
 
@@ -92,11 +93,11 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         private final String message;
 
         Shutdown(final String message) {
-            this.message = Preconditions.checkNotNull(message);
+            this.message = requireNonNull(message);
         }
 
         @Override
-        protected DataTreeSnapshot getSnapshot(Object transactionId) {
+        protected DataTreeSnapshot getSnapshot(final Object transactionId) {
             throw new IllegalStateException(message);
         }
     }
@@ -115,7 +116,7 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         state = idleState;
     }
 
-    private Entry<State, DataTreeSnapshot> getSnapshot(T transactionId) {
+    private Entry<State, DataTreeSnapshot> getSnapshot(final T transactionId) {
         final State localState = state;
         return new SimpleEntry<>(localState, localState.getSnapshot(transactionId));
     }
@@ -130,7 +131,7 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         return newReadOnlyTransaction(nextTransactionIdentifier());
     }
 
-    protected DOMStoreReadTransaction newReadOnlyTransaction(T transactionId) {
+    protected DOMStoreReadTransaction newReadOnlyTransaction(final T transactionId) {
         final Entry<State, DataTreeSnapshot> entry = getSnapshot(transactionId);
         return SnapshotBackedTransactions.newReadTransaction(transactionId, getDebugTransactions(), entry.getValue(),
             this);
@@ -146,7 +147,7 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         return newReadWriteTransaction(nextTransactionIdentifier());
     }
 
-    protected DOMStoreReadWriteTransaction newReadWriteTransaction(T transactionId) {
+    protected DOMStoreReadWriteTransaction newReadWriteTransaction(final T transactionId) {
         Entry<State, DataTreeSnapshot> entry;
         DOMStoreReadWriteTransaction ret;
 
@@ -164,7 +165,7 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         return newWriteOnlyTransaction(nextTransactionIdentifier());
     }
 
-    protected DOMStoreWriteTransaction newWriteOnlyTransaction(T transactionId) {
+    protected DOMStoreWriteTransaction newWriteOnlyTransaction(final T transactionId) {
         Entry<State, DataTreeSnapshot> entry;
         DOMStoreWriteTransaction ret;
 
@@ -203,8 +204,8 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         if (localState instanceof Allocated) {
             final Allocated allocated = (Allocated)localState;
             final DOMStoreWriteTransaction transaction = allocated.getTransaction();
-            Preconditions.checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s",
-                    tx, transaction);
+            checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s", tx,
+                transaction);
             allocated.setSnapshot(tree);
         } else {
             LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState);
@@ -218,8 +219,7 @@ public abstract class AbstractSnapshotBackedTransactionChain<T> extends Transact
         final State localState = state;
 
         do {
-            Preconditions.checkState(!CLOSED.equals(localState), "Transaction chain %s has been closed", this);
-
+            checkState(!CLOSED.equals(localState), "Transaction chain %s has been closed", this);
             if (FAILED.equals(localState)) {
                 LOG.debug("Ignoring user close in failed state");
                 return;
index be5cbead3a7fb9cbf4e344dc55e3a1793274f2d7..b36211da8f0fec2c08bf7922c69cbac0c77dab90 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.controller.sal.core.spi.data;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
@@ -58,7 +57,7 @@ public final class SnapshotBackedReadTransaction<T> extends AbstractDOMStoreTran
     SnapshotBackedReadTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot,
             final TransactionClosePrototype<T> closeImpl) {
         super(identifier, debug);
-        this.stableSnapshot = Preconditions.checkNotNull(snapshot);
+        this.stableSnapshot = requireNonNull(snapshot);
         this.closeImpl = closeImpl;
         LOG.debug("ReadOnly Tx: {} allocated with snapshot {}", identifier, snapshot);
     }
@@ -82,7 +81,7 @@ public final class SnapshotBackedReadTransaction<T> extends AbstractDOMStoreTran
     @SuppressWarnings("checkstyle:IllegalCatch")
     public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
         LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
-        checkNotNull(path, "Path must not be null.");
+        requireNonNull(path, "Path must not be null.");
 
         final DataTreeSnapshot snapshot = stableSnapshot;
         if (snapshot == null) {
@@ -100,7 +99,7 @@ public final class SnapshotBackedReadTransaction<T> extends AbstractDOMStoreTran
     @Override
     public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
         LOG.debug("Tx: {} Exists: {}", getIdentifier(), path);
-        checkNotNull(path, "Path must not be null.");
+        requireNonNull(path, "Path must not be null.");
 
         try {
             return Futures.immediateCheckedFuture(read(path).checkedGet().isPresent());
index 435261435fee21c3b1bb5de9219e4f5824ff6d90..4b87548c3e576a1071a2f5132c0456d3e901d9b7 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.sal.core.spi.data;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Optional;
@@ -42,7 +42,7 @@ public final class SnapshotBackedReadWriteTransaction<T> extends SnapshotBackedW
     @SuppressWarnings("checkstyle:IllegalCatch")
     public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
         LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
-        checkNotNull(path, "Path must not be null.");
+        requireNonNull(path, "Path must not be null.");
 
         final Optional<NormalizedNode<?, ?>> result;
         try {
index fe3d219272b7b78b5d01bf8584daaceebfec90af..ee48bf6a44e703c4bbe1ef9133a8698117428073 100644 (file)
@@ -8,11 +8,11 @@
 package org.opendaylight.controller.sal.core.spi.data;
 
 import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects.ToStringHelper;
 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 org.eclipse.jdt.annotation.Nullable;
@@ -53,7 +53,7 @@ public class SnapshotBackedWriteTransaction<T> extends AbstractDOMStoreTransacti
     SnapshotBackedWriteTransaction(final T identifier, final boolean debug,
             final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
         super(identifier, debug);
-        this.readyImpl = Preconditions.checkNotNull(readyImpl, "readyImpl must not be null.");
+        this.readyImpl = requireNonNull(readyImpl, "readyImpl must not be null.");
         mutableTree = snapshot.newModification();
         LOG.debug("Write Tx: {} allocated with snapshot {}", identifier, snapshot);
     }
index 73a471c5b2f9c6daac9a496c57097231b5f48b88..33c5c35f0416b8a8ba9a02897a67c48ddb01bb69 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.controller.remote.rpc.registry;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.Address;
 import akka.actor.Props;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
@@ -41,7 +42,7 @@ public class ActionRegistry extends BucketStoreActor<ActionRoutingTable> {
     public ActionRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker,
                           final ActorRef rpcRegistrar) {
         super(config, config.getRpcRegistryPersistenceId(), new ActionRoutingTable(rpcInvoker, ImmutableSet.of()));
-        this.rpcRegistrar = Preconditions.checkNotNull(rpcRegistrar);
+        this.rpcRegistrar = requireNonNull(rpcRegistrar);
         this.mxBean = new RemoteActionRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
                 config.getAskDuration()), config.getAskDuration());
     }
@@ -111,7 +112,7 @@ public class ActionRegistry extends BucketStoreActor<ActionRoutingTable> {
 
         @VisibleForTesting
         public RemoteActionEndpoint(final ActorRef router, final Collection<DOMActionInstance> actions) {
-            this.router = Preconditions.checkNotNull(router);
+            this.router = requireNonNull(router);
             this.actions = ImmutableSet.copyOf(actions);
         }
 
index 68fead4407781f534b0f9b4aee3ae7e2b012f908..bcb31990712b8a74f6503e320ff0d9089150d1b4 100644 (file)
@@ -7,11 +7,13 @@
  */
 package org.opendaylight.controller.remote.rpc.registry;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.Address;
 import akka.actor.Props;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
@@ -44,7 +46,7 @@ public class RpcRegistry extends BucketStoreActor<RoutingTable> {
 
     public RpcRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker, final ActorRef rpcRegistrar) {
         super(config, config.getRpcRegistryPersistenceId(), new RoutingTable(rpcInvoker, ImmutableSet.of()));
-        this.rpcRegistrar = Preconditions.checkNotNull(rpcRegistrar);
+        this.rpcRegistrar = requireNonNull(rpcRegistrar);
         this.mxBean = new RemoteRpcRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
                 config.getAskDuration()), config.getAskDuration());
     }
@@ -123,7 +125,7 @@ public class RpcRegistry extends BucketStoreActor<RoutingTable> {
 
         @VisibleForTesting
         public RemoteRpcEndpoint(final ActorRef router, final Collection<DOMRpcIdentifier> rpcs) {
-            this.router = Preconditions.checkNotNull(router);
+            this.router = requireNonNull(router);
             this.rpcs = ImmutableSet.copyOf(rpcs);
         }
 
@@ -144,7 +146,7 @@ public class RpcRegistry extends BucketStoreActor<RoutingTable> {
             final List<DOMRpcIdentifier> rpcRouteIdentifiers;
 
             AbstractRouteMessage(final Collection<DOMRpcIdentifier> rpcRouteIdentifiers) {
-                Preconditions.checkArgument(rpcRouteIdentifiers != null && !rpcRouteIdentifiers.isEmpty(),
+                checkArgument(rpcRouteIdentifiers != null && !rpcRouteIdentifiers.isEmpty(),
                         "Route Identifiers must be supplied");
                 this.rpcRouteIdentifiers = ImmutableList.copyOf(rpcRouteIdentifiers);
             }
index 6c5ca77b037fec1f0ccc6fdc0823fc7a9ae65b8f..b494256d500f2fe53f2660c3216ce503a4b09d91 100644 (file)
@@ -5,9 +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.remote.rpc.registry.gossip;
 
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
 import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_ALL_BUCKETS;
 import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_BUCKET_VERSIONS;
 
@@ -25,8 +27,6 @@ import akka.persistence.SaveSnapshotSuccess;
 import akka.persistence.SnapshotOffer;
 import akka.persistence.SnapshotSelectionCriteria;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Verify;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.SetMultimap;
@@ -89,9 +89,9 @@ public abstract class BucketStoreActor<T extends BucketData<T>> extends
     private boolean persisting;
 
     protected BucketStoreActor(final RemoteOpsProviderConfig config, final String persistenceId, final T initialData) {
-        this.config = Preconditions.checkNotNull(config);
-        this.initialData = Preconditions.checkNotNull(initialData);
-        this.persistenceId = Preconditions.checkNotNull(persistenceId);
+        this.config = requireNonNull(config);
+        this.initialData = requireNonNull(initialData);
+        this.persistenceId = requireNonNull(persistenceId);
     }
 
     static ExecuteInActor getBucketsByMembersMessage(final Collection<Address> members) {
@@ -224,7 +224,7 @@ public abstract class BucketStoreActor<T extends BucketData<T>> extends
         if (bumpIncarnation) {
             LOG.debug("Version wrapped. incrementing incarnation");
 
-            Verify.verify(incarnation < Integer.MAX_VALUE, "Ran out of incarnations, cannot continue");
+            verify(incarnation < Integer.MAX_VALUE, "Ran out of incarnations, cannot continue");
             incarnation = incarnation + 1;
 
             persisting = true;
@@ -389,7 +389,7 @@ public abstract class BucketStoreActor<T extends BucketData<T>> extends
     }
 
     private LocalBucket<T> getLocalBucket() {
-        Preconditions.checkState(localBucket != null, "Attempted to access local bucket before recovery completed");
+        checkState(localBucket != null, "Attempted to access local bucket before recovery completed");
         return localBucket;
     }
 }
index a6a0c2b6f790a93d29ac56d9745484a97dacc65d..950b5f9f080a51acc28689269a211ca4c079b1a2 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.controller.remote.rpc.registry.gossip;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.Address;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import java.io.Serializable;
 import java.util.Map;
@@ -21,7 +22,7 @@ final class GossipEnvelope implements Serializable {
     private final Address to;
 
     GossipEnvelope(final Address from, final Address to, final Map<Address, ? extends Bucket<?>> buckets) {
-        this.to = Preconditions.checkNotNull(to);
+        this.to = requireNonNull(to);
         this.buckets = ImmutableMap.copyOf(buckets);
         this.from = from;
     }
index e75bef24c7aa22e7758b430a6ca9aeba31f8f381..f43a1d9f9613e3871c6190948c12fb7f7172e1e0 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.controller.remote.rpc.registry.gossip;
 
+import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorRefProvider;
 import akka.actor.ActorSelection;
@@ -18,8 +21,6 @@ import akka.cluster.ClusterActorRefProvider;
 import akka.cluster.ClusterEvent;
 import akka.cluster.Member;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Verify;
 import com.google.common.collect.Maps;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -85,7 +86,7 @@ public class Gossiper extends AbstractUntypedActorWithMetering {
     private BucketStoreAccess bucketStore;
 
     Gossiper(final RemoteOpsProviderConfig config, final Boolean autoStartGossipTicks) {
-        this.config = Preconditions.checkNotNull(config);
+        this.config = requireNonNull(config);
         this.autoStartGossipTicks = autoStartGossipTicks.booleanValue();
     }
 
@@ -243,7 +244,7 @@ public class Gossiper extends AbstractUntypedActorWithMetering {
         }
 
         LOG.trace("Gossiping to [{}]", address);
-        getLocalStatusAndSendTo(Verify.verifyNotNull(peers.get(address)));
+        getLocalStatusAndSendTo(verifyNotNull(peers.get(address)));
     }
 
     /**
index 5e9d907aadd18227869cf8bb8dc8c0bc0a6e25cd..313dac8089116564ea36059a3f2a86a6e8185f88 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.remote.rpc.registry.gossip;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
 
 /**
  * Local bucket implementation. Unlike a full-blown {@link Bucket}, this class is mutable and tracks when it has been
@@ -30,9 +31,9 @@ final class LocalBucket<T extends BucketData<T>> {
     private boolean bumpVersion;
 
     LocalBucket(final int incarnation, final T data) {
-        Preconditions.checkArgument(incarnation >= 0);
-        this.version = ((long)incarnation) << Integer.SIZE;
-        this.data = Preconditions.checkNotNull(data);
+        checkArgument(incarnation >= 0);
+        this.version = (long)incarnation << Integer.SIZE;
+        this.data = requireNonNull(data);
     }
 
     T getData() {
@@ -49,7 +50,7 @@ final class LocalBucket<T extends BucketData<T>> {
     }
 
     boolean setData(final T newData) {
-        this.data = Preconditions.checkNotNull(newData);
+        this.data = requireNonNull(newData);
         if (!bumpVersion) {
             return false;
         }
index dbeccb24564cdcb345e885da0203ffadfb42c1ba..5ea18d2cb66c274b9aece6762ee10fa60a37b55b 100644 (file)
@@ -7,6 +7,10 @@
  */
 package org.opendaylight.controller.remote.rpc.registry.mbeans;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.Props;
@@ -21,7 +25,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.remote.rpc.RemoteOpsProviderConfig;
@@ -76,8 +79,8 @@ public class RemoteRpcRegistryMXBeanImplTest {
     public void testGetGlobalRpcEmptyBuckets() {
         final Set<String> globalRpc = mxBean.getGlobalRpc();
 
-        Assert.assertNotNull(globalRpc);
-        Assert.assertTrue(globalRpc.isEmpty());
+        assertNotNull(globalRpc);
+        assertTrue(globalRpc.isEmpty());
     }
 
     @Test
@@ -85,19 +88,19 @@ public class RemoteRpcRegistryMXBeanImplTest {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final Set<String> globalRpc = mxBean.getGlobalRpc();
 
-        Assert.assertNotNull(globalRpc);
-        Assert.assertEquals(1, globalRpc.size());
+        assertNotNull(globalRpc);
+        assertEquals(1, globalRpc.size());
 
         final String rpc = globalRpc.iterator().next();
-        Assert.assertEquals(EMPTY_SCHEMA_PATH.toString(), rpc);
+        assertEquals(EMPTY_SCHEMA_PATH.toString(), rpc);
     }
 
     @Test
     public void testGetLocalRegisteredRoutedRpcEmptyBuckets() {
         final Set<String> localRegisteredRoutedRpc = mxBean.getLocalRegisteredRoutedRpc();
 
-        Assert.assertNotNull(localRegisteredRoutedRpc);
-        Assert.assertTrue(localRegisteredRoutedRpc.isEmpty());
+        assertNotNull(localRegisteredRoutedRpc);
+        assertTrue(localRegisteredRoutedRpc.isEmpty());
     }
 
     @Test
@@ -105,20 +108,20 @@ public class RemoteRpcRegistryMXBeanImplTest {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final Set<String> localRegisteredRoutedRpc = mxBean.getLocalRegisteredRoutedRpc();
 
-        Assert.assertNotNull(localRegisteredRoutedRpc);
-        Assert.assertEquals(1, localRegisteredRoutedRpc.size());
+        assertNotNull(localRegisteredRoutedRpc);
+        assertEquals(1, localRegisteredRoutedRpc.size());
 
         final String localRpc = localRegisteredRoutedRpc.iterator().next();
-        Assert.assertTrue(localRpc.contains(LOCAL_QNAME.toString()));
-        Assert.assertTrue(localRpc.contains(LOCAL_SCHEMA_PATH.toString()));
+        assertTrue(localRpc.contains(LOCAL_QNAME.toString()));
+        assertTrue(localRpc.contains(LOCAL_SCHEMA_PATH.toString()));
     }
 
     @Test
     public void testFindRpcByNameEmptyBuckets() {
         final Map<String, String> rpcByName = mxBean.findRpcByName("");
 
-        Assert.assertNotNull(rpcByName);
-        Assert.assertTrue(rpcByName.isEmpty());
+        assertNotNull(rpcByName);
+        assertTrue(rpcByName.isEmpty());
     }
 
     @Test
@@ -126,17 +129,17 @@ public class RemoteRpcRegistryMXBeanImplTest {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final Map<String, String> rpcByName = mxBean.findRpcByName("");
 
-        Assert.assertNotNull(rpcByName);
-        Assert.assertEquals(1, rpcByName.size());
-        Assert.assertTrue(rpcByName.containsValue(LOCAL_QNAME.getLocalName()));
+        assertNotNull(rpcByName);
+        assertEquals(1, rpcByName.size());
+        assertTrue(rpcByName.containsValue(LOCAL_QNAME.getLocalName()));
     }
 
     @Test
     public void testFindRpcByRouteEmptyBuckets() {
         final Map<String, String> rpcByRoute = mxBean.findRpcByRoute("");
 
-        Assert.assertNotNull(rpcByRoute);
-        Assert.assertTrue(rpcByRoute.isEmpty());
+        assertNotNull(rpcByRoute);
+        assertTrue(rpcByRoute.isEmpty());
     }
 
     @Test
@@ -144,15 +147,15 @@ public class RemoteRpcRegistryMXBeanImplTest {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final Map<String, String> rpcByRoute = mxBean.findRpcByRoute("");
 
-        Assert.assertNotNull(rpcByRoute);
-        Assert.assertEquals(1, rpcByRoute.size());
-        Assert.assertTrue(rpcByRoute.containsValue(LOCAL_QNAME.getLocalName()));
+        assertNotNull(rpcByRoute);
+        assertEquals(1, rpcByRoute.size());
+        assertTrue(rpcByRoute.containsValue(LOCAL_QNAME.getLocalName()));
     }
 
     @Test
     public void testGetBucketVersionsEmptyBuckets() {
         final String bucketVersions = mxBean.getBucketVersions();
-        Assert.assertEquals(Collections.EMPTY_MAP.toString(), bucketVersions);
+        assertEquals(Collections.emptyMap().toString(), bucketVersions);
     }
 
     @Test
@@ -160,6 +163,6 @@ public class RemoteRpcRegistryMXBeanImplTest {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final String bucketVersions = mxBean.getBucketVersions();
 
-        Assert.assertTrue(bucketVersions.contains(testActor.provider().getDefaultAddress().toString()));
+        assertTrue(bucketVersions.contains(testActor.provider().getDefaultAddress().toString()));
     }
 }
index c883fe0b588ba23be844ad35d0c84ddcb3dc877a..232391209b506d076fe202641a3e4fcdcdf1b004 100644 (file)
@@ -5,10 +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.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -58,8 +58,8 @@ public final class ProduceTransactionsHandler extends AbstractTransactionHandler
     private ProduceTransactionsHandler(final DOMDataTreeProducer producer, final DOMDataTreeIdentifier idListItem,
             final ProduceTransactionsInput input) {
         super(input);
-        this.itemProducer = Preconditions.checkNotNull(producer);
-        this.idListItem = Preconditions.checkNotNull(idListItem);
+        this.itemProducer = requireNonNull(producer);
+        this.idListItem = requireNonNull(idListItem);
     }
 
     public static ListenableFuture<RpcResult<ProduceTransactionsOutput>> start(
index bd755d40c8b24fc87cb1ff9b608ca1b0970fb8c1..4f4b7f8e105d5751346e3196feec763ab69176df 100644 (file)
@@ -5,10 +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.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
@@ -39,14 +40,12 @@ public class PublishNotificationsTask implements Runnable {
 
     public PublishNotificationsTask(final NotificationPublishService notificationPublishService,
                                     final String notificationId, final long secondsToTake, final long maxPerSecond) {
-        Preconditions.checkNotNull(notificationPublishService);
-        Preconditions.checkNotNull(notificationId);
-        Preconditions.checkArgument(secondsToTake > 0);
-        Preconditions.checkArgument(maxPerSecond > 0);
 
-        this.notificationPublishService = notificationPublishService;
-        this.notificationId = notificationId;
+        this.notificationPublishService = requireNonNull(notificationPublishService);
+        this.notificationId = requireNonNull(notificationId);
+        checkArgument(secondsToTake > 0);
         this.timeToTake = secondsToTake * SECOND_AS_NANO;
+        checkArgument(maxPerSecond > 0);
         this.delay = SECOND_AS_NANO / maxPerSecond;
 
         LOG.debug("Delay : {}", delay);
@@ -76,7 +75,7 @@ public class PublishNotificationsTask implements Runnable {
         LOG.debug("current {}, starttime: {}, timetotake: {}, current-start = {}",
                 current, startTime, timeToTake, current - startTime);
 
-        if ((current - startTime) > timeToTake) {
+        if (current - startTime > timeToTake) {
             LOG.debug("Sequence number: {}", sequenceNumber);
             scheduledFuture.cancel(false);
             executor.shutdown();
index 70b920dc8d3f1eb7b3f5df89097e6a1bb671a18a..b0503b240611176458732b95194681d6e598d8dc 100644 (file)
@@ -5,10 +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.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.LinkedHashSet;
@@ -88,7 +88,7 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle
         Simple(final DOMDataBroker dataBroker, final YangInstanceIdentifier idListItem,
             final WriteTransactionsInput input) {
             super(idListItem, input);
-            this.dataBroker = Preconditions.checkNotNull(dataBroker);
+            this.dataBroker = requireNonNull(dataBroker);
         }
 
         @Override
@@ -123,7 +123,7 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle
 
     WriteTransactionsHandler(final YangInstanceIdentifier idListItem, final WriteTransactionsInput input) {
         super(input);
-        this.idListItem = Preconditions.checkNotNull(idListItem);
+        this.idListItem = requireNonNull(idListItem);
     }
 
     public static ListenableFuture<RpcResult<WriteTransactionsOutput>> start(final DOMDataBroker domDataBroker,
index c6744a9393faf96a0a8e643e7258b03516ee3c59..331ee91850dc69d3aa4aa98ccda17f7d42403fa9 100644 (file)
@@ -5,10 +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.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutput;
 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutputBuilder;
@@ -18,7 +18,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class YnlListener implements OdlMdsalLowlevelTargetListener {
-
     private static final Logger LOG = LoggerFactory.getLogger(YnlListener.class);
 
     private final String id;
@@ -29,8 +28,7 @@ public class YnlListener implements OdlMdsalLowlevelTargetListener {
     private final AtomicLong errNot = new AtomicLong();
 
     public YnlListener(final String id) {
-        Preconditions.checkNotNull(id);
-        this.id = id;
+        this.id = requireNonNull(id);
     }
 
     @Override
index fc1e380a4c16bf324ee85e611dc510d602d89073..4b425d121af7c5c10b8c33beec9367a6c27a981d 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.sample.toaster.provider;
 
+import static java.util.Objects.requireNonNull;
 import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE;
 import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE;
 import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
@@ -14,7 +15,6 @@ import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL
 import static org.opendaylight.yangtools.yang.common.RpcError.ErrorType.APPLICATION;
 
 import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -120,9 +120,8 @@ public class OpendaylightToaster extends AbstractMXBean
     public void init() {
         LOG.info("Initializing...");
 
-        Preconditions.checkNotNull(dataBroker, "dataBroker must be set");
-        dataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener(
-                DataTreeIdentifier.create(CONFIGURATION, TOASTER_IID), this);
+        dataTreeChangeListenerRegistration = requireNonNull(dataBroker, "dataBroker must be set")
+            .registerDataTreeChangeListener(DataTreeIdentifier.create(CONFIGURATION, TOASTER_IID), this);
         setToasterStatusUp(null);
 
         // Register our MXBean.