From a90276953f9ce9d539af868116059e14d656fc50 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Tue, 12 Feb 2019 12:04:48 +0100 Subject: [PATCH] Switch to Objects.requireNonNull MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ... instead of Guava’s Preconditions.checkNotNull. Change-Id: If7979ac0071e8c1d1af2d7913c6df791942825ab Signed-off-by: Stephen Kitt --- .../api/gen/plugin/CodeGeneratorImpl.java | 7 ++++--- .../BindingDOMDataTreeListenerAdapter.java | 5 +++-- ...ingDataTreeChangeListenerRegistration.java | 5 +++-- .../invoke/LocalNameRpcServiceInvoker.java | 5 +++-- .../osgi/impl/ModuleInfoBundleTracker.java | 4 ++-- .../osgi/impl/OsgiModuleInfoRegistry.java | 10 ++++----- .../SimpleBindingRuntimeContextService.java | 6 +++--- .../DataNodeContainerSerializerSource.java | 7 ++++--- .../gen/impl/DataObjectSerializerSource.java | 5 +++-- .../gen/spi/StaticConstantDefinition.java | 8 +++---- .../impl/BindingNormalizedNodeCache.java | 7 ++++--- .../impl/BindingToNormalizedStreamWriter.java | 6 ++++-- .../codec/impl/EncapsulatedValueCodec.java | 9 ++++---- .../binding/dom/codec/impl/IdentityCodec.java | 4 +++- .../codec/impl/InstanceIdentifierCodec.java | 5 +++-- .../impl/MissingSchemaForClassException.java | 5 +++-- .../dom/codec/impl/ReflectionBasedCodec.java | 4 ++-- .../codec/impl/SchemaRootCodecContext.java | 6 +++--- .../codec/impl/UnionValueOptionContext.java | 7 ++++--- .../codec/util/ChoiceDispatchSerializer.java | 5 +++-- ...entationClassDiscoveredAfterCodecTest.java | 4 ++-- .../generator/util/YangSchemaUtils.java | 4 ++-- .../yang/types/AbstractTypeProvider.java | 12 +++++------ .../generator/impl/AbstractTypesTest.java | 6 +++--- .../java/api/generator/GeneratorJavaFile.java | 3 +-- .../reflect/StringValueObjectFactory.java | 9 ++++---- .../testutils/DataBrokerFailuresImpl.java | 11 +++++----- .../javav2/api/DataTreeIdentifier.java | 7 ++++--- .../api/DataTreeListeningException.java | 7 ++++--- .../api/DataTreeProducerBusyException.java | 7 ++++--- ...BindingDOMDataTreeCommitCohortAdapter.java | 7 ++++--- ...OMDataTreeCommitCohortRegistryAdapter.java | 7 ++++--- .../BindingDOMDataTreeListenerAdapter.java | 9 ++++---- .../BindingDOMDataTreeProducerAdapter.java | 5 +++-- .../BindingDOMDataTreeServiceAdapter.java | 7 ++++--- .../NotificationListenerInvoker.java | 4 +++- .../impl/operation/RpcServiceAdapter.java | 6 +++--- .../BindingDataTreeListenerRegistration.java | 5 +++-- .../generator/impl/StaticBindingProperty.java | 9 ++++---- .../AbstractStreamWriterGenerator.java | 4 +++- .../AbstractAugmentSerializerSource.java | 5 +++-- ...ractDataNodeContainerSerializerSource.java | 7 ++++--- .../AbstractTreeNodeSerializerSource.java | 5 +++-- .../javav2/dom/codec/impl/AnyxmlCodec.java | 4 +++- .../BindingNormalizedNodeCodecRegistry.java | 5 +++-- .../impl/BindingToNormalizedNodeCodec.java | 5 +++-- .../javav2/dom/codec/impl/IdentityCodec.java | 4 +++- .../codec/impl/InstanceIdentifierCodec.java | 5 +++-- ...tractBindingNormalizedNodeCacheHolder.java | 5 +++-- .../cache/BindingNormalizedNodeCache.java | 7 ++++--- .../cache/CachingNormalizedNodeCodec.java | 5 +++-- .../impl/context/SchemaRootCodecContext.java | 10 +++++---- .../impl/context/UnionValueOptionContext.java | 7 ++++--- .../context/base/AnyxmlNodeCodecContext.java | 8 ++++--- .../context/base/BindingCodecContext.java | 6 ++++-- .../base/DataContainerCodecPrototype.java | 11 +++++----- .../codec/impl/context/base/LazyTreeNode.java | 8 ++++--- .../context/base/LeafNodeCodecContext.java | 8 ++++--- .../base/MissingSchemaForClassException.java | 5 +++-- .../BindingToNormalizedStreamWriter.java | 6 ++++-- .../serializer/ChoiceDispatchSerializer.java | 5 +++-- .../dom/codec/impl/value/BitsCodec.java | 4 +++- .../impl/value/EncapsulatedValueCodec.java | 9 ++++---- .../impl/value/ReflectionBasedCodec.java | 5 +++-- .../LazyDataTreeModification.java | 7 ++++--- .../LazyTreeNodeModification.java | 7 ++++--- .../generator/impl/AugmentToGenType.java | 3 ++- .../generator/impl/BindingGeneratorImpl.java | 6 ++++-- .../javav2/generator/impl/GenHelperUtil.java | 19 +++++++++-------- .../generator/impl/RpcActionGenHelper.java | 5 +---- .../generator/yang/types/TypeGenHelper.java | 3 ++- .../yang/types/TypeProviderImpl.java | 7 ++++--- .../generator/util/AbstractBaseType.java | 21 ++++++++++--------- .../binding/javav2/generator/util/Types.java | 11 +++++----- .../builder/AbstractGeneratedTypeBuilder.java | 6 ++++-- .../java/api/generator/GeneratorJavaFile.java | 6 ++++-- .../AbstractPrimitiveRangeGenerator.java | 9 ++++---- .../AbstractRangeGenerator.java | 5 +++-- .../api/generator/renderers/BaseRenderer.java | 16 +++++++------- .../generator/renderers/ClassRenderer.java | 3 ++- .../renderers/InterfaceRenderer.java | 5 +++-- .../generator/renderers/UnionRenderer.java | 3 ++- .../api/generator/util/TextTemplateUtil.java | 10 +++++---- .../api/gen/plugin/CodeGeneratorImpl.java | 4 ++-- .../context/BindingRuntimeContext.java | 6 ++++-- .../runtime/javassist/JavassistUtils.java | 6 ++++-- .../reflection/AugmentationFieldGetter.java | 5 +++-- .../javav2/spec/base/IdentifiableItem.java | 7 ++++--- .../javav2/spec/base/InstanceIdentifier.java | 14 +++++++------ .../mdsal/binding/javav2/spec/base/Item.java | 5 +++-- .../spec/runtime/BindingNamespaceType.java | 5 +++-- .../javav2/util/StringValueObjectFactory.java | 9 ++++---- .../dom/broker/AbstractDOMRoutingTable.java | 5 +++-- .../broker/AbstractDOMRoutingTableEntry.java | 7 ++++--- .../AbstractDOMRpcRoutingTableEntry.java | 5 +++-- .../dom/broker/CommitCoordinationTask.java | 7 ++++--- .../DOMDataBrokerTransactionChainImpl.java | 6 ++++-- .../broker/DOMDataTreeShardRegistration.java | 7 ++++--- .../broker/DOMNotificationRouterEvent.java | 7 ++++--- .../dom/broker/SerializedDOMDataBroker.java | 4 +++- .../broker/ShardedDOMDataTreeProducer.java | 6 ++++-- .../ShardedDOMDataTreeWriteTransaction.java | 10 +++++---- .../TransactionChainWriteTransaction.java | 9 ++++---- .../ChainedTransactionCommitImpl.java | 5 +++-- .../DOMStoreTransactionChainImpl.java | 5 +++-- .../DataTreeModificationCursorAdaptor.java | 5 +++-- .../ForeignShardThreePhaseCommitCohort.java | 7 ++++--- ...OMDataTreeShardThreePhaseCommitCohort.java | 8 ++++--- ...nMemoryDOMStoreThreePhaseCommitCohort.java | 8 +++---- .../InMemoryShardDataModificationCursor.java | 5 +++-- .../InMemoryShardDataModificationFactory.java | 5 +++-- ...emoryDOMDataTreeShardWriteTransaction.java | 16 +++++++------- .../ShardCanCommitCoordinationTask.java | 7 ++++--- .../inmemory/ShardCommitCoordinationTask.java | 9 ++++---- .../store/inmemory/ShardDataModification.java | 5 +++-- .../ShardDataModificationFactoryBuilder.java | 5 +++-- .../ShardRootModificationContext.java | 7 ++++--- .../inmemory/ShardSubmitCoordinationTask.java | 5 +++-- ...gEntityOwnershipCandidateRegistration.java | 5 +++-- ...ngEntityOwnershipListenerRegistration.java | 7 ++++--- .../mdsal/eos/binding/api/Entity.java | 5 +++-- .../mdsal/eos/dom/api/DOMEntity.java | 5 +++-- .../SimpleDOMEntityOwnershipService.java | 6 +++--- .../mdsal/model/ietf/util/IpClass.java | 4 ++-- 124 files changed, 475 insertions(+), 347 deletions(-) diff --git a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/maven/api/gen/plugin/CodeGeneratorImpl.java b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/maven/api/gen/plugin/CodeGeneratorImpl.java index 5ed142fba3..9108d318d2 100644 --- a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/maven/api/gen/plugin/CodeGeneratorImpl.java +++ b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/maven/api/gen/plugin/CodeGeneratorImpl.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.maven.api.gen.plugin; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Joiner; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Table; @@ -166,7 +167,7 @@ public final class CodeGeneratorImpl implements BasicCodeGenerator, BuildContext } private static void setOutputBaseDirAsSourceFolder(final File outputBaseDir, final MavenProject mavenProject) { - Preconditions.checkNotNull(mavenProject, "Maven project needs to be set in this phase"); + requireNonNull(mavenProject, "Maven project needs to be set in this phase"); mavenProject.addCompileSourceRoot(outputBaseDir.getPath()); } @@ -188,7 +189,7 @@ public final class CodeGeneratorImpl implements BasicCodeGenerator, BuildContext @Override public void setBuildContext(final BuildContext buildContext) { - this.buildContext = Preconditions.checkNotNull(buildContext); + this.buildContext = requireNonNull(buildContext); } private Set generateYangModuleInfo(final File outputBaseDir, final Module module, final SchemaContext ctx, diff --git a/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMDataTreeListenerAdapter.java b/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMDataTreeListenerAdapter.java index ccd08ed834..91ca03256d 100644 --- a/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMDataTreeListenerAdapter.java +++ b/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMDataTreeListenerAdapter.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.adapter; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.Maps; import java.util.ArrayList; import java.util.Collection; @@ -35,7 +36,7 @@ public class BindingDOMDataTreeListenerAdapter extends AbstractBindingAdapter domReg) { super(listener); - this.domReg = Preconditions.checkNotNull(domReg); + this.domReg = requireNonNull(domReg); } @Override diff --git a/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/LocalNameRpcServiceInvoker.java b/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/LocalNameRpcServiceInvoker.java index a2a13ef2d8..0f1322a7e7 100644 --- a/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/LocalNameRpcServiceInvoker.java +++ b/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/LocalNameRpcServiceInvoker.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.adapter.invoke; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; @@ -20,7 +21,7 @@ final class LocalNameRpcServiceInvoker extends AbstractMappedRpcInvoker private LocalNameRpcServiceInvoker(final QNameModule module, final Map map) { super(map); - this.module = Preconditions.checkNotNull(module); + this.module = requireNonNull(module); } static RpcServiceInvoker instanceFor(final QNameModule module, final Map qnameToMethod) { diff --git a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/ModuleInfoBundleTracker.java b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/ModuleInfoBundleTracker.java index 3933b0328b..aeecbbbb92 100644 --- a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/ModuleInfoBundleTracker.java +++ b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/ModuleInfoBundleTracker.java @@ -7,7 +7,7 @@ */ package org.opendaylight.mdsal.binding.dom.codec.osgi.impl; -import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.Objects.requireNonNull; import com.google.common.collect.ImmutableList; import com.google.common.io.Resources; @@ -46,7 +46,7 @@ final class ModuleInfoBundleTracker implements BundleTrackerCustomizer inner; ObjectRegistrationWrapper(final ObjectRegistration inner) { - this.inner = checkNotNull(inner); + this.inner = requireNonNull(inner); } @Override diff --git a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/SimpleBindingRuntimeContextService.java b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/SimpleBindingRuntimeContextService.java index 4c56edcca4..a4bb7bdb7a 100644 --- a/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/SimpleBindingRuntimeContextService.java +++ b/binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/SimpleBindingRuntimeContextService.java @@ -7,9 +7,9 @@ */ package org.opendaylight.mdsal.binding.dom.codec.osgi.impl; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Verify.verifyNotNull; +import static java.util.Objects.requireNonNull; import com.google.common.util.concurrent.ListenableFuture; import javax.annotation.concurrent.GuardedBy; @@ -39,8 +39,8 @@ final class SimpleBindingRuntimeContextService extends SimpleBindingRuntimeContextService(final BundleContext context, final ClassLoadingStrategy strategy, final SchemaSourceProvider sourceProvider) { super(context, BindingRuntimeContextListener.class, null); - this.sourceProvider = checkNotNull(sourceProvider); - this.strategy = checkNotNull(strategy); + this.sourceProvider = requireNonNull(sourceProvider); + this.strategy = requireNonNull(strategy); } @Override diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/impl/DataNodeContainerSerializerSource.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/impl/DataNodeContainerSerializerSource.java index e7ad321324..9bed830009 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/impl/DataNodeContainerSerializerSource.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/impl/DataNodeContainerSerializerSource.java @@ -8,7 +8,8 @@ package org.opendaylight.mdsal.binding.dom.codec.gen.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.util.HashMap; import java.util.Map; import org.opendaylight.mdsal.binding.dom.codec.util.BindingSchemaMapping; @@ -46,8 +47,8 @@ abstract class DataNodeContainerSerializerSource extends DataObjectSerializerSou DataNodeContainerSerializerSource(final AbstractGenerator generator, final GeneratedType type, final DataNodeContainer node) { super(generator); - this.dtoType = Preconditions.checkNotNull(type); - this.schemaNode = Preconditions.checkNotNull(node); + this.dtoType = requireNonNull(type); + this.schemaNode = requireNonNull(node); } /** diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/impl/DataObjectSerializerSource.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/impl/DataObjectSerializerSource.java index 9d3a0309d3..8ec0a4d631 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/impl/DataObjectSerializerSource.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/impl/DataObjectSerializerSource.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.codec.gen.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import org.opendaylight.mdsal.binding.dom.codec.gen.spi.AbstractSource; import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy; import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; @@ -35,7 +36,7 @@ abstract class DataObjectSerializerSource extends AbstractSource { * @param generator Parent generator */ DataObjectSerializerSource(final AbstractGenerator generator) { - this.generator = Preconditions.checkNotNull(generator); + this.generator = requireNonNull(generator); } @SuppressWarnings("unchecked") diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/spi/StaticConstantDefinition.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/spi/StaticConstantDefinition.java index 951635e2c7..743b852535 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/spi/StaticConstantDefinition.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/gen/spi/StaticConstantDefinition.java @@ -7,7 +7,7 @@ */ package org.opendaylight.mdsal.binding.dom.codec.gen.spi; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; /** * Definition of static property for generated class. @@ -27,9 +27,9 @@ public class StaticConstantDefinition { private final Object value; public StaticConstantDefinition(final String name, final Class type, final Object value) { - this.name = Preconditions.checkNotNull(name); - this.type = Preconditions.checkNotNull(type); - this.value = Preconditions.checkNotNull(value); + this.name = requireNonNull(name); + this.type = requireNonNull(type); + this.value = requireNonNull(value); } public String getName() { diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingNormalizedNodeCache.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingNormalizedNodeCache.java index dc30e1243c..7b594e92b3 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingNormalizedNodeCache.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingNormalizedNodeCache.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.codec.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -23,8 +24,8 @@ final class BindingNormalizedNodeCache extends CacheLoader subtreeRoot) { - this.cacheHolder = Preconditions.checkNotNull(cacheHolder, "cacheHolder"); - this.subtreeRoot = Preconditions.checkNotNull(subtreeRoot, "subtreeRoot"); + this.cacheHolder = requireNonNull(cacheHolder, "cacheHolder"); + this.subtreeRoot = requireNonNull(subtreeRoot, "subtreeRoot"); } @Override diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingToNormalizedStreamWriter.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingToNormalizedStreamWriter.java index fc982428b8..03cf03a1ce 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingToNormalizedStreamWriter.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingToNormalizedStreamWriter.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.codec.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Preconditions; import java.io.IOException; import java.util.AbstractMap; @@ -35,8 +37,8 @@ final class BindingToNormalizedStreamWriter implements BindingStreamEventWriter, BindingToNormalizedStreamWriter(final NodeCodecContext rootNodeSchema, final NormalizedNodeStreamWriter delegate) { - this.rootNodeSchema = Preconditions.checkNotNull(rootNodeSchema); - this.delegate = Preconditions.checkNotNull(delegate); + this.rootNodeSchema = requireNonNull(rootNodeSchema); + this.delegate = requireNonNull(delegate); } static BindingToNormalizedStreamWriter create(final NodeCodecContext schema, diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/EncapsulatedValueCodec.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/EncapsulatedValueCodec.java index 95e43f688c..560e733252 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/EncapsulatedValueCodec.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/EncapsulatedValueCodec.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.codec.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Throwables; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -34,9 +35,9 @@ final class EncapsulatedValueCodec extends ReflectionBasedCodec implements Schem private EncapsulatedValueCodec(final Class typeClz, final MethodHandle constructor, final MethodHandle getter, final Class valueType) { super(typeClz); - this.constructor = Preconditions.checkNotNull(constructor); - this.getter = Preconditions.checkNotNull(getter); - this.valueType = Preconditions.checkNotNull(valueType); + this.constructor = requireNonNull(constructor); + this.getter = requireNonNull(getter); + this.valueType = requireNonNull(valueType); } static Callable loader(final Class typeClz, TypeDefinition typeDef) { diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/IdentityCodec.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/IdentityCodec.java index 06c8c2718f..cc98fb0bed 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/IdentityCodec.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/IdentityCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.codec.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Preconditions; import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext; import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; @@ -18,7 +20,7 @@ final class IdentityCodec implements Codec> { private final BindingRuntimeContext context; IdentityCodec(final BindingRuntimeContext context) { - this.context = Preconditions.checkNotNull(context); + this.context = requireNonNull(context); } @Override diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/InstanceIdentifierCodec.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/InstanceIdentifierCodec.java index b077a4969a..becd7c208a 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/InstanceIdentifierCodec.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/InstanceIdentifierCodec.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.codec.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.Iterables; import java.util.ArrayList; import java.util.List; @@ -20,7 +21,7 @@ final class InstanceIdentifierCodec implements Codec clz) { super(String.format("Schema is not available for %s", clz)); - this.bindingClass = Preconditions.checkNotNull(clz); + this.bindingClass = requireNonNull(clz); } static MissingSchemaForClassException forClass(final Class clz) { diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/ReflectionBasedCodec.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/ReflectionBasedCodec.java index a609e390b5..1f3a7e2383 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/ReflectionBasedCodec.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/ReflectionBasedCodec.java @@ -7,14 +7,14 @@ */ package org.opendaylight.mdsal.binding.dom.codec.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; abstract class ReflectionBasedCodec extends ValueTypeCodec { private final Class typeClass; ReflectionBasedCodec(final Class typeClass) { - this.typeClass = Preconditions.checkNotNull(typeClass); + this.typeClass = requireNonNull(typeClass); } protected final Class getTypeClass() { diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java index 33b2b797ac..23355d7847 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java @@ -8,8 +8,8 @@ package org.opendaylight.mdsal.binding.dom.codec.impl; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Verify.verify; +import static java.util.Objects.requireNonNull; import com.google.common.base.Throwables; import com.google.common.base.Verify; @@ -219,8 +219,8 @@ final class SchemaRootCodecContext extends DataContainerCo private ActionCodecContext prepareActionContext(final int inputOffset, final int outputOffset, final int expectedArgsLength, final Class> action, final Class actionType) { - final ParameterizedType paramType = checkNotNull(ClassLoaderUtils.findParameterizedType(action, actionType), - "There does not exist any ParameterType in %s", action); + final ParameterizedType paramType = requireNonNull(ClassLoaderUtils.findParameterizedType(action, actionType), + () -> "There does not exist any ParameterType in " + action); final Type[] args = paramType.getActualTypeArguments(); checkArgument(args.length == expectedArgsLength, "Unexpected (%s) Action generatic arguments", args.length); final ActionDefinition schema = factory().getRuntimeContext().getActionDefinition(action); diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/UnionValueOptionContext.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/UnionValueOptionContext.java index 5b1ae9eeb1..6143f08ef5 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/UnionValueOptionContext.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/UnionValueOptionContext.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.codec.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Throwables; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -28,8 +29,8 @@ final class UnionValueOptionContext { UnionValueOptionContext(final Class unionType, final Class valueType, final Method getter, final Codec codec) { - this.bindingType = Preconditions.checkNotNull(valueType); - this.codec = Preconditions.checkNotNull(codec); + this.bindingType = requireNonNull(valueType); + this.codec = requireNonNull(codec); try { this.getter = MethodHandles.publicLookup().unreflect(getter).asType(OBJECT_TYPE); diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/util/ChoiceDispatchSerializer.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/util/ChoiceDispatchSerializer.java index 31c4645da1..609bec050d 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/util/ChoiceDispatchSerializer.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/util/ChoiceDispatchSerializer.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.dom.codec.util; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.io.IOException; import org.opendaylight.yangtools.yang.binding.BindingStreamEventWriter; import org.opendaylight.yangtools.yang.binding.DataContainer; @@ -27,7 +28,7 @@ public final class ChoiceDispatchSerializer implements DataObjectSerializerImple @SuppressWarnings("rawtypes") private ChoiceDispatchSerializer(final Class choiceClass) { - this.choiceClass = Preconditions.checkNotNull(choiceClass); + this.choiceClass = requireNonNull(choiceClass); } public static ChoiceDispatchSerializer from(final Class choiceClass) { diff --git a/binding/mdsal-binding-dom-codec/src/test/java/org/opendaylight/mdsal/binding/dom/codec/test/AugmentationClassDiscoveredAfterCodecTest.java b/binding/mdsal-binding-dom-codec/src/test/java/org/opendaylight/mdsal/binding/dom/codec/test/AugmentationClassDiscoveredAfterCodecTest.java index 4b8602af55..6152808357 100644 --- a/binding/mdsal-binding-dom-codec/src/test/java/org/opendaylight/mdsal/binding/dom/codec/test/AugmentationClassDiscoveredAfterCodecTest.java +++ b/binding/mdsal-binding-dom-codec/src/test/java/org/opendaylight/mdsal/binding/dom/codec/test/AugmentationClassDiscoveredAfterCodecTest.java @@ -7,9 +7,9 @@ */ package org.opendaylight.mdsal.binding.dom.codec.test; +import static java.util.Objects.requireNonNull; import static org.junit.Assert.assertNotNull; -import com.google.common.base.Preconditions; import java.util.HashSet; import java.util.Map.Entry; import java.util.Set; @@ -121,7 +121,7 @@ public class AugmentationClassDiscoveredAfterCodecTest { } protected ClassExcludingClassLoadingStrategy(final GeneratedClassLoadingStrategy delegate) { - this.delegate = Preconditions.checkNotNull(delegate); + this.delegate = requireNonNull(delegate); } @Override diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtils.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtils.java index 5386a77593..c4f670b360 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtils.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/YangSchemaUtils.java @@ -7,8 +7,8 @@ */ package org.opendaylight.mdsal.binding.generator.util; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; import com.google.common.base.Preconditions; import java.net.URI; @@ -36,7 +36,7 @@ public final class YangSchemaUtils { } public static QName getAugmentationQName(final AugmentationSchemaNode augmentation) { - checkNotNull(augmentation, "Augmentation must not be null."); + requireNonNull(augmentation, "Augmentation must not be null."); final QName identifier = getAugmentationIdentifier(augmentation); if (identifier != null) { return identifier; diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/AbstractTypeProvider.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/AbstractTypeProvider.java index f9e1abb9fb..4441081f77 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/AbstractTypeProvider.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/yang/types/AbstractTypeProvider.java @@ -831,7 +831,7 @@ public abstract class AbstractTypeProvider implements TypeProvider { */ private GeneratedTransferObject wrapJavaTypeIntoTO(final String basePackageName, final TypeDefinition typedef, final Type javaType, final String moduleName) { - Preconditions.checkNotNull(javaType, "javaType cannot be null"); + requireNonNull(javaType, "javaType cannot be null"); final GeneratedTOBuilder genTOBuilder = typedefToTransferObject(basePackageName, typedef, moduleName); genTOBuilder.setRestrictions(BindingGeneratorUtil.getRestrictions(typedef)); @@ -887,8 +887,8 @@ public abstract class AbstractTypeProvider implements TypeProvider { */ public List provideGeneratedTOBuildersForUnionTypeDef(final JavaTypeName typeName, final UnionTypeDefinition typedef, final SchemaNode parentNode) { - Preconditions.checkNotNull(typedef, "Type Definition cannot be NULL!"); - Preconditions.checkNotNull(typedef.getQName(), "Type definition QName cannot be NULL!"); + requireNonNull(typedef, "Type Definition cannot be NULL!"); + requireNonNull(typedef.getQName(), "Type definition QName cannot be NULL!"); final List generatedTOBuilders = new ArrayList<>(); final List> unionTypes = typedef.getTypes(); @@ -1325,9 +1325,9 @@ public abstract class AbstractTypeProvider implements TypeProvider { final TypeDefinition type = CompatUtils.compatLeafType(node); final QName typeQName = type.getQName(); final TypeDefinition base = baseTypeDefForExtendedType(type); - Preconditions.checkNotNull(type, "Cannot provide default construction for null type of %s", node); - Preconditions.checkNotNull(defaultValue, "Cannot provide default construction for null default statement of %s", - node); + requireNonNull(type, () -> "Cannot provide default construction for null type of " + node); + requireNonNull(defaultValue, () -> "Cannot provide default construction for null default statement of " + + node); final StringBuilder sb = new StringBuilder(); String result = null; diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypesTest.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypesTest.java index e416b869a6..db4e8a4ce2 100644 --- a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypesTest.java +++ b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/AbstractTypesTest.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.generator.impl; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.io.File; import java.net.URISyntaxException; import java.net.URL; @@ -27,8 +28,7 @@ public abstract class AbstractTypesTest { @Before public void loadTestResources() throws URISyntaxException { File testSourcesDir = new File(testSourcesDirUrl.toURI()); - File[] testFiles = Preconditions.checkNotNull(testSourcesDir.listFiles(), testSourcesDir - + " does not denote a directory"); + File[] testFiles = requireNonNull(testSourcesDir.listFiles(), testSourcesDir + " does not denote a directory"); testModels = new HashSet<>(); for (File file : testFiles) { if (file.isFile()) { diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/GeneratorJavaFile.java b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/GeneratorJavaFile.java index 891e2e0962..c7b1c37284 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/GeneratorJavaFile.java +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/GeneratorJavaFile.java @@ -10,7 +10,6 @@ package org.opendaylight.mdsal.binding.java.api.generator; import static java.util.Objects.requireNonNull; import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; import java.io.File; @@ -79,7 +78,7 @@ public final class GeneratorJavaFile { * @param types set of types for which JAVA code should be generated */ public GeneratorJavaFile(final Collection types) { - this.types = Preconditions.checkNotNull(types); + this.types = requireNonNull(types); generators.add(new InterfaceGenerator()); generators.add(new TOGenerator()); generators.add(new EnumGenerator()); diff --git a/binding/mdsal-binding-spec-util/src/main/java/org/opendaylight/mdsal/binding/spec/reflect/StringValueObjectFactory.java b/binding/mdsal-binding-spec-util/src/main/java/org/opendaylight/mdsal/binding/spec/reflect/StringValueObjectFactory.java index ac281ca986..06af2a195f 100644 --- a/binding/mdsal-binding-spec-util/src/main/java/org/opendaylight/mdsal/binding/spec/reflect/StringValueObjectFactory.java +++ b/binding/mdsal-binding-spec-util/src/main/java/org/opendaylight/mdsal/binding/spec/reflect/StringValueObjectFactory.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.spec.reflect; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -48,9 +49,9 @@ public final class StringValueObjectFactory { private final T template; private StringValueObjectFactory(final T template, final MethodHandle constructor, final MethodHandle setter) { - this.template = Preconditions.checkNotNull(template); + this.template = requireNonNull(template); this.constructor = constructor.bindTo(template); - this.setter = Preconditions.checkNotNull(setter); + this.setter = requireNonNull(setter); } public static StringValueObjectFactory create(final Class clazz, final String templateString) { @@ -137,7 +138,7 @@ public final class StringValueObjectFactory { @SuppressWarnings("checkstyle:illegalCatch") public T newInstance(final String string) { - Preconditions.checkNotNull(string, "Argument may not be null"); + requireNonNull(string, "Argument may not be null"); try { final T ret = (T) constructor.invokeExact(); diff --git a/binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/DataBrokerFailuresImpl.java b/binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/DataBrokerFailuresImpl.java index 8b1f5db618..96f6d156e7 100644 --- a/binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/DataBrokerFailuresImpl.java +++ b/binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/DataBrokerFailuresImpl.java @@ -7,9 +7,10 @@ */ package org.opendaylight.mdsal.binding.testutils; +import static java.util.Objects.requireNonNull; + import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.Futures; -import java.util.Objects; import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; @@ -59,26 +60,26 @@ public class DataBrokerFailuresImpl extends ForwardingDataBroker implements Data @Override public void failReads(ReadFailedException exception) { unfailReads(); - readException = Objects.requireNonNull(exception, "exception == null"); + readException = requireNonNull(exception, "exception == null"); } @Override public void failReads(int howManyTimes, ReadFailedException exception) { unfailReads(); howManyFailingReads.set(howManyTimes); - readException = Objects.requireNonNull(exception, "exception == null"); + readException = requireNonNull(exception, "exception == null"); } @Override public void failCommits(TransactionCommitFailedException exception) { unfailCommits(); - this.commitException = Objects.requireNonNull(exception, "exception == null"); + this.commitException = requireNonNull(exception, "exception == null"); } @Override public void failCommits(int howManyTimes, TransactionCommitFailedException exception) { howManyFailingCommits.set(howManyTimes); - this.commitException = Objects.requireNonNull(exception, "exception == null"); + this.commitException = requireNonNull(exception, "exception == null"); } @Override diff --git a/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeIdentifier.java b/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeIdentifier.java index dc8864cc9e..6eda831e44 100644 --- a/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeIdentifier.java +++ b/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeIdentifier.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.api; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.io.Serializable; import java.util.Objects; import javax.annotation.Nonnull; @@ -32,8 +33,8 @@ public final class DataTreeIdentifier implements Immutable, private final LogicalDatastoreType datastoreType; private DataTreeIdentifier(final LogicalDatastoreType datastoreType, final InstanceIdentifier rootIdentifier) { - this.datastoreType = Preconditions.checkNotNull(datastoreType); - this.rootIdentifier = Preconditions.checkNotNull(rootIdentifier); + this.datastoreType = requireNonNull(datastoreType); + this.rootIdentifier = requireNonNull(rootIdentifier); } public static DataTreeIdentifier create(final LogicalDatastoreType datastoreType, diff --git a/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeListeningException.java b/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeListeningException.java index 02f4bbe815..a49e507a74 100644 --- a/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeListeningException.java +++ b/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeListeningException.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.api; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -23,11 +24,11 @@ public class DataTreeListeningException extends Exception { private static final long serialVersionUID = 1L; public DataTreeListeningException(@Nonnull String message, @Nullable Throwable cause) { - super(Preconditions.checkNotNull(message, "message"), cause); + super(requireNonNull(message, "message"), cause); } public DataTreeListeningException(@Nonnull String message) { - super(Preconditions.checkNotNull(message, "message")); + super(requireNonNull(message, "message")); } } diff --git a/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeProducerBusyException.java b/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeProducerBusyException.java index 473df96c52..c005db927e 100644 --- a/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeProducerBusyException.java +++ b/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/DataTreeProducerBusyException.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.api; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import javax.annotation.Nonnull; /** @@ -23,10 +24,10 @@ public class DataTreeProducerBusyException extends DataTreeProducerException { public DataTreeProducerBusyException(@Nonnull final String message, @Nonnull final Throwable cause) { - super(Preconditions.checkNotNull(message, "message"), cause); + super(requireNonNull(message, "message"), cause); } public DataTreeProducerBusyException(@Nonnull final String message) { - super(Preconditions.checkNotNull(message, "message")); + super(requireNonNull(message, "message")); } } \ No newline at end of file diff --git a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeCommitCohortAdapter.java b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeCommitCohortAdapter.java index 82f50d9d13..1689a4b151 100644 --- a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeCommitCohortAdapter.java +++ b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeCommitCohortAdapter.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.adapter.impl.data.tree; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.SettableFuture; import java.util.Collection; @@ -38,8 +39,8 @@ public class BindingDOMDataTreeCommitCohortAdapter implement public BindingDOMDataTreeCommitCohortAdapter(final BindingToNormalizedNodeCodec codec, final DataTreeCommitCohort cohort) { - this.codec = Preconditions.checkNotNull(codec); - this.cohort = Preconditions.checkNotNull(cohort); + this.codec = requireNonNull(codec); + this.cohort = requireNonNull(cohort); } @Nonnull diff --git a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeCommitCohortRegistryAdapter.java b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeCommitCohortRegistryAdapter.java index e918940b57..7b69055325 100644 --- a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeCommitCohortRegistryAdapter.java +++ b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeCommitCohortRegistryAdapter.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.adapter.impl.data.tree; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import javax.annotation.Nonnull; import org.opendaylight.mdsal.binding.javav2.api.DataTreeCommitCohort; import org.opendaylight.mdsal.binding.javav2.api.DataTreeCommitCohortRegistry; @@ -31,8 +32,8 @@ public final class BindingDOMDataTreeCommitCohortRegistryAdapter implements Data private BindingDOMDataTreeCommitCohortRegistryAdapter(final BindingToNormalizedNodeCodec codec, final DOMDataTreeCommitCohortRegistry registry) { - this.codec = Preconditions.checkNotNull(codec); - this.registry = Preconditions.checkNotNull(registry); + this.codec = requireNonNull(codec); + this.registry = requireNonNull(registry); } /** diff --git a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeListenerAdapter.java b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeListenerAdapter.java index c75c89e8c7..648579ac8d 100644 --- a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeListenerAdapter.java +++ b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeListenerAdapter.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.adapter.impl.data.tree; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.collect.Maps; import java.util.ArrayList; import java.util.Collection; @@ -43,9 +44,9 @@ public class BindingDOMDataTreeListenerAdapter implements DOMDataTreeListener { public BindingDOMDataTreeListenerAdapter(final DataTreeListener delegate, final BindingToNormalizedNodeCodec codec, final LogicalDatastoreType store) { - this.delegate = Preconditions.checkNotNull(delegate, "delegate"); - this.codec = Preconditions.checkNotNull(codec, "codec"); - this.store = Preconditions.checkNotNull(store, "store"); + this.delegate = requireNonNull(delegate, "delegate"); + this.codec = requireNonNull(codec, "codec"); + this.store = requireNonNull(store, "store"); } @Override diff --git a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeProducerAdapter.java b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeProducerAdapter.java index 772c42672e..2453e12583 100644 --- a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeProducerAdapter.java +++ b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeProducerAdapter.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.adapter.impl.data.tree; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.util.Collection; import javax.annotation.Nonnull; import org.opendaylight.mdsal.binding.javav2.api.CursorAwareWriteTransaction; @@ -32,7 +33,7 @@ public final class BindingDOMDataTreeProducerAdapter implements DataTreeProducer private BindingDOMDataTreeProducerAdapter(final DOMDataTreeProducer delegate, final BindingToNormalizedNodeCodec codec) { - this.delegate = Preconditions.checkNotNull(delegate); + this.delegate = requireNonNull(delegate); this.codec = codec; } diff --git a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeServiceAdapter.java b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeServiceAdapter.java index 34dbe1667a..2918f3d5c1 100644 --- a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeServiceAdapter.java +++ b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/data/tree/BindingDOMDataTreeServiceAdapter.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.adapter.impl.data.tree; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.util.Collection; import javax.annotation.Nonnull; import org.opendaylight.mdsal.binding.javav2.api.DataTreeIdentifier; @@ -34,8 +35,8 @@ public final class BindingDOMDataTreeServiceAdapter implements DataTreeService { private BindingDOMDataTreeServiceAdapter(final DOMDataTreeService delegate, final BindingToNormalizedNodeCodec codec) { - this.delegate = Preconditions.checkNotNull(delegate, "delegate"); - this.codec = Preconditions.checkNotNull(codec, "codec"); + this.delegate = requireNonNull(delegate, "delegate"); + this.codec = requireNonNull(codec, "codec"); } /** diff --git a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/notification/NotificationListenerInvoker.java b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/notification/NotificationListenerInvoker.java index 8156d8d891..6db4e816d6 100644 --- a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/notification/NotificationListenerInvoker.java +++ b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/notification/NotificationListenerInvoker.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.adapter.impl.notification; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; @@ -114,7 +116,7 @@ public final class NotificationListenerInvoker { @SuppressWarnings("checkstyle:IllegalCatch") public void invokeNotification(@Nonnull final NotificationListener impl, @Nonnull final QName notificationName, @Nullable final Instantiable input) { - Preconditions.checkNotNull(impl, "implementation must be supplied"); + requireNonNull(impl, "implementation must be supplied"); final MethodHandle invoker = methodInvokers.get(notificationName); Preconditions.checkArgument(invoker != null, "Supplied notification is not valid for implementation %s", impl); try { diff --git a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/operation/RpcServiceAdapter.java b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/operation/RpcServiceAdapter.java index 3495ee850d..25d6b21089 100644 --- a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/operation/RpcServiceAdapter.java +++ b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/impl/operation/RpcServiceAdapter.java @@ -61,9 +61,9 @@ class RpcServiceAdapter implements InvocationHandler { RpcServiceAdapter(final Class> 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); strategy = createStrategy(type); proxy = (Rpc) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, this); } diff --git a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/registration/BindingDataTreeListenerRegistration.java b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/registration/BindingDataTreeListenerRegistration.java index e096a07c50..41ed4b4f78 100644 --- a/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/registration/BindingDataTreeListenerRegistration.java +++ b/binding2/mdsal-binding2-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/adapter/registration/BindingDataTreeListenerRegistration.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.adapter.registration; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import org.opendaylight.mdsal.binding.javav2.api.DataTreeListener; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; @@ -27,7 +28,7 @@ public class BindingDataTreeListenerRegistration public BindingDataTreeListenerRegistration(final L listener, final ListenerRegistration domReg) { super(listener); - this.domReg = Preconditions.checkNotNull(domReg); + this.domReg = requireNonNull(domReg); } @Override diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/impl/StaticBindingProperty.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/impl/StaticBindingProperty.java index 94fef6b73b..62754501b8 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/impl/StaticBindingProperty.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/impl/StaticBindingProperty.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.generator.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; /** * Definition of static property for Binding objects. @@ -29,9 +30,9 @@ public class StaticBindingProperty { private final Object value; public StaticBindingProperty(final String name, final Class type, final Object value) { - this.name = Preconditions.checkNotNull(name); - this.type = Preconditions.checkNotNull(type); - this.value = Preconditions.checkNotNull(value); + this.name = requireNonNull(name); + this.type = requireNonNull(type); + this.value = requireNonNull(value); } public String getName() { diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/generator/AbstractStreamWriterGenerator.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/generator/AbstractStreamWriterGenerator.java index 49debf64ef..4715f6d640 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/generator/AbstractStreamWriterGenerator.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/generator/AbstractStreamWriterGenerator.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.generator.spi.generator; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.cache.CacheBuilder; @@ -83,7 +85,7 @@ public abstract class AbstractStreamWriterGenerator extends AbstractGenerator im } protected AbstractStreamWriterGenerator(final JavassistUtils utils) { - this.javassist = Preconditions.checkNotNull(utils, "JavassistUtils instance is required."); + this.javassist = requireNonNull(utils, "JavassistUtils instance is required."); this.serializeArguments = new CtClass[] { javassist.asCtClass(TreeNodeSerializerRegistry.class), javassist.asCtClass(TreeNode.class), javassist.asCtClass(BindingStreamEventWriter.class), }; javassist.appendClassLoaderIfMissing(TreeNodeSerializerPrototype.class.getClassLoader()); diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractAugmentSerializerSource.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractAugmentSerializerSource.java index 3db728c108..525f72da0a 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractAugmentSerializerSource.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractAugmentSerializerSource.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.generator.spi.source; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; import org.opendaylight.mdsal.binding.javav2.dom.codec.generator.spi.generator.AbstractGenerator; @@ -28,7 +29,7 @@ public abstract class AbstractAugmentSerializerSource extends AbstractDataNodeCo final Collection augmentationSchemas) { // Note: passing first augmentation schema node just to avoid exceptions from super class. super(generator, type, augmentationSchemas.stream().findFirst().get()); - this.augmentationSchemas = Preconditions.checkNotNull(augmentationSchemas); + this.augmentationSchemas = requireNonNull(augmentationSchemas); } /** diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractDataNodeContainerSerializerSource.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractDataNodeContainerSerializerSource.java index 4102204a94..681eb4bffe 100755 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractDataNodeContainerSerializerSource.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractDataNodeContainerSerializerSource.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.generator.spi.source; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -56,8 +57,8 @@ public abstract class AbstractDataNodeContainerSerializerSource extends Abstract public AbstractDataNodeContainerSerializerSource(final AbstractGenerator generator, final GeneratedType type, final DataNodeContainer node) { super(generator); - this.dtoType = Preconditions.checkNotNull(type); - this.schemaNode = Preconditions.checkNotNull(node); + this.dtoType = requireNonNull(type); + this.schemaNode = requireNonNull(node); } /** diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractTreeNodeSerializerSource.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractTreeNodeSerializerSource.java index 1153bed650..487d6d2cbf 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractTreeNodeSerializerSource.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/generator/spi/source/AbstractTreeNodeSerializerSource.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.generator.spi.source; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import org.opendaylight.mdsal.binding.javav2.dom.codec.generator.spi.generator.AbstractGenerator; import org.opendaylight.mdsal.binding.javav2.dom.codec.generator.spi.generator.AbstractStreamWriterGenerator; import org.opendaylight.mdsal.binding.javav2.generator.api.ClassLoadingStrategy; @@ -39,7 +40,7 @@ public abstract class AbstractTreeNodeSerializerSource extends AbstractSource { * -parent generator */ AbstractTreeNodeSerializerSource(final AbstractGenerator generator) { - this.generator = Preconditions.checkNotNull(generator); + this.generator = requireNonNull(generator); } @SuppressWarnings("unchecked") diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/AnyxmlCodec.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/AnyxmlCodec.java index 57641cfa50..9f6798aca9 100755 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/AnyxmlCodec.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/AnyxmlCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import javax.xml.transform.dom.DOMSource; @@ -29,7 +31,7 @@ public final class AnyxmlCodec implements Codec { * - binding runtime context */ public AnyxmlCodec(final BindingRuntimeContext context) { - this.context = Preconditions.checkNotNull(context); + this.context = requireNonNull(context); } @Override diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/BindingNormalizedNodeCodecRegistry.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/BindingNormalizedNodeCodecRegistry.java index 65fbcd7c33..38c77f8a3e 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/BindingNormalizedNodeCodecRegistry.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/BindingNormalizedNodeCodecRegistry.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -80,7 +81,7 @@ public class BindingNormalizedNodeCodecRegistry implements TreeNodeSerializerReg * - serializer generator */ public BindingNormalizedNodeCodecRegistry(final TreeNodeSerializerGenerator generator) { - this.generator = Preconditions.checkNotNull(generator); + this.generator = requireNonNull(generator); this.serializers = CacheBuilder.newBuilder().weakKeys().build(new GeneratorLoader()); } diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/BindingToNormalizedNodeCodec.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/BindingToNormalizedNodeCodec.java index 9268cc9d0b..c59f2510a7 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/BindingToNormalizedNodeCodec.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/BindingToNormalizedNodeCodec.java @@ -8,6 +8,7 @@ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl; 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; @@ -112,8 +113,8 @@ public final class BindingToNormalizedNodeCodec */ public BindingToNormalizedNodeCodec(final GeneratedClassLoadingStrategy classLoadingStrategy, final BindingNormalizedNodeCodecRegistry codecRegistry, final boolean waitForSchema) { - this.classLoadingStrategy = Preconditions.checkNotNull(classLoadingStrategy, "classLoadingStrategy"); - this.codecRegistry = Preconditions.checkNotNull(codecRegistry, "codecRegistry"); + this.classLoadingStrategy = requireNonNull(classLoadingStrategy, "classLoadingStrategy"); + this.codecRegistry = requireNonNull(codecRegistry, "codecRegistry"); this.futureSchema = waitForSchema ? new FutureSchema(WAIT_DURATION_SEC, TimeUnit.SECONDS) : null; } diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/IdentityCodec.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/IdentityCodec.java index 8a0a4f8d70..c514862749 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/IdentityCodec.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/IdentityCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import org.opendaylight.mdsal.binding.javav2.runtime.context.BindingRuntimeContext; @@ -30,7 +32,7 @@ public final class IdentityCodec implements Codec> { * - binding runtime context */ public IdentityCodec(final BindingRuntimeContext context) { - this.context = Preconditions.checkNotNull(context); + this.context = requireNonNull(context); } @Override diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/InstanceIdentifierCodec.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/InstanceIdentifierCodec.java index 60834d4c51..dccbf1ce22 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/InstanceIdentifierCodec.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/InstanceIdentifierCodec.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; import java.util.ArrayList; import java.util.List; @@ -38,7 +39,7 @@ public final class InstanceIdentifierCodec implements Codec> cacheSpec) { - cachedValues = Preconditions.checkNotNull(cacheSpec); + cachedValues = requireNonNull(cacheSpec); } public BindingNormalizedNodeCache getCachingSerializer(final DataContainerCodecContext childCtx) { diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/cache/BindingNormalizedNodeCache.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/cache/BindingNormalizedNodeCache.java index cf9a69ff78..84561ad2a0 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/cache/BindingNormalizedNodeCache.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/cache/BindingNormalizedNodeCache.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.cache; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -32,8 +33,8 @@ public class BindingNormalizedNodeCache extends CacheLoader subtreeRoot) { - this.cacheHolder = Preconditions.checkNotNull(cacheHolder, "cacheHolder"); - this.subtreeRoot = Preconditions.checkNotNull(subtreeRoot, "subtreeRoot"); + this.cacheHolder = requireNonNull(cacheHolder, "cacheHolder"); + this.subtreeRoot = requireNonNull(subtreeRoot, "subtreeRoot"); } @Override diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/cache/CachingNormalizedNodeCodec.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/cache/CachingNormalizedNodeCodec.java index f1bf7d2b7c..e0b83261e8 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/cache/CachingNormalizedNodeCodec.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/cache/CachingNormalizedNodeCodec.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.cache; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.util.Set; import javax.annotation.Nonnull; import org.opendaylight.mdsal.binding.javav2.dom.codec.api.BindingNormalizedNodeCachingCodec; @@ -32,7 +33,7 @@ public class CachingNormalizedNodeCodec extends AbstractBind public CachingNormalizedNodeCodec(final DataContainerCodecContext subtreeRoot, final Set> cacheSpec) { super(cacheSpec); - this.context = Preconditions.checkNotNull(subtreeRoot); + this.context = requireNonNull(subtreeRoot); } @Nonnull diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/SchemaRootCodecContext.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/SchemaRootCodecContext.java index b985e3f150..5b8bdf8f9a 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/SchemaRootCodecContext.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/SchemaRootCodecContext.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; @@ -126,8 +128,8 @@ public final class SchemaRootCodecContext extends DataContai * @return operation schema or null, if operation is not present in schema context. */ private ContainerSchemaNode getOperationDataSchema(final SchemaContext schema, final SchemaPath path) { - Preconditions.checkNotNull(schema, "Schema context must not be null."); - Preconditions.checkNotNull(path, "Schema path must not be null."); + requireNonNull(schema, "Schema context must not be null."); + requireNonNull(path, "Schema path must not be null."); final Iterator it = path.getPathFromRoot().iterator(); Preconditions.checkArgument(it.hasNext(), "Operation must have QName."); final QName operationName = it.next(); @@ -151,8 +153,8 @@ public final class SchemaRootCodecContext extends DataContai } private ContainerSchemaNode getOperationDataSchema(final OperationDefinition operation, final QName qname) { - Preconditions.checkNotNull(operation, "Operation Schema must not be null."); - Preconditions.checkNotNull(qname, "QName must not be null."); + requireNonNull(operation, "Operation Schema must not be null."); + requireNonNull(qname, "QName must not be null."); switch (qname.getLocalName()) { case "input": return operation.getInput(); diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/UnionValueOptionContext.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/UnionValueOptionContext.java index 6b143066cc..e9e125aa08 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/UnionValueOptionContext.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/UnionValueOptionContext.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -50,8 +51,8 @@ public class UnionValueOptionContext { */ public UnionValueOptionContext(final Class unionType, final Class valueType, final Method getter, final Codec codec) { - this.bindingType = Preconditions.checkNotNull(valueType); - this.codec = Preconditions.checkNotNull(codec); + this.bindingType = requireNonNull(valueType); + this.codec = requireNonNull(codec); try { this.getter = MethodHandles.publicLookup().unreflect(getter).asType(OBJECT_TYPE); diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/AnyxmlNodeCodecContext.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/AnyxmlNodeCodecContext.java index fad47d78e2..db5bf5dc43 100755 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/AnyxmlNodeCodecContext.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/AnyxmlNodeCodecContext.java @@ -8,6 +8,8 @@ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableCollection; @@ -39,9 +41,9 @@ public final class AnyxmlNodeCodecContext extends NodeCodecC AnyxmlNodeCodecContext(final DataSchemaNode schema, final Codec codec, final Method getter, final SchemaContext schemaContext) { this.yangIdentifier = new YangInstanceIdentifier.NodeIdentifier(schema.getQName()); - this.valueCodec = Preconditions.checkNotNull(codec); - this.getter = Preconditions.checkNotNull(getter); - this.schema = Preconditions.checkNotNull(schema); + this.valueCodec = requireNonNull(codec); + this.getter = requireNonNull(getter); + this.schema = requireNonNull(schema); } @Override diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/BindingCodecContext.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/BindingCodecContext.java index edcd894b8f..a3564d3d4f 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/BindingCodecContext.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/BindingCodecContext.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; @@ -107,12 +109,12 @@ public final class BindingCodecContext implements CodecContextFactory, BindingTr * - binding normalized node codec registry */ public BindingCodecContext(final BindingRuntimeContext context, final BindingNormalizedNodeCodecRegistry registry) { - this.context = Preconditions.checkNotNull(context, "Binding Runtime Context is required."); + this.context = requireNonNull(context, "Binding Runtime Context is required."); this.root = SchemaRootCodecContext.create(this); this.identityCodec = new IdentityCodec(context); this.anyxmlCodec = new AnyxmlCodec(context); this.instanceIdentifierCodec = new InstanceIdentifierCodec(this); - this.registry = Preconditions.checkNotNull(registry); + this.registry = requireNonNull(registry); } @Override diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/DataContainerCodecPrototype.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/DataContainerCodecPrototype.java index 1ab7a7f521..f668c10bae 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/DataContainerCodecPrototype.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/DataContainerCodecPrototype.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; @@ -51,10 +52,10 @@ public final class DataContainerCodecPrototype implements NodeContextSupplier @SuppressWarnings({"rawtypes", "unchecked"}) private DataContainerCodecPrototype(final Class cls, final YangInstanceIdentifier.PathArgument arg, final T nodeSchema, final CodecContextFactory factory) { - this.bindingClass = Preconditions.checkNotNull(cls); - this.yangArg = Preconditions.checkNotNull(arg); - this.schema = Preconditions.checkNotNull(nodeSchema); - this.factory = Preconditions.checkNotNull(factory); + this.bindingClass = requireNonNull(cls); + this.yangArg = requireNonNull(arg); + this.schema = requireNonNull(nodeSchema); + this.factory = requireNonNull(factory); this.bindingArg = new Item(bindingClass); diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/LazyTreeNode.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/LazyTreeNode.java index 98b9729a8b..ef7d8133d6 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/LazyTreeNode.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/LazyTreeNode.java @@ -8,6 +8,8 @@ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base; +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; @@ -54,8 +56,8 @@ class LazyTreeNode implements InvocationHandler, Augmentatio @SuppressWarnings({ "rawtypes", "unchecked" }) LazyTreeNode(final TreeNodeCodecContext ctx, final NormalizedNodeContainer data) { - this.context = Preconditions.checkNotNull(ctx, "Context must not be null"); - this.data = Preconditions.checkNotNull(data, "Data must not be null"); + this.context = requireNonNull(ctx, "Context must not be null"); + this.data = requireNonNull(data, "Data must not be null"); } @Override @@ -188,7 +190,7 @@ class LazyTreeNode implements InvocationHandler, Augmentatio if (aug != null) { return aug.get(cls); } - Preconditions.checkNotNull(cls,"Supplied augmentation must not be null."); + requireNonNull(cls,"Supplied augmentation must not be null."); @SuppressWarnings({"unchecked","rawtypes"}) final Optional> augCtx = context.possibleStreamChild((Class) cls); diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/LeafNodeCodecContext.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/LeafNodeCodecContext.java index 3676ffe9d0..711cfe5155 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/LeafNodeCodecContext.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/LeafNodeCodecContext.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableCollection; @@ -51,9 +53,9 @@ public final class LeafNodeCodecContext extends NodeCodecCon LeafNodeCodecContext(final DataSchemaNode schema, final Codec codec, final Method getter, final SchemaContext schemaContext) { this.yangIdentifier = new YangInstanceIdentifier.NodeIdentifier(schema.getQName()); - this.valueCodec = Preconditions.checkNotNull(codec); - this.getter = Preconditions.checkNotNull(getter); - this.schema = Preconditions.checkNotNull(schema); + this.valueCodec = requireNonNull(codec); + this.getter = requireNonNull(getter); + this.schema = requireNonNull(schema); this.defaultObject = createDefaultObject(schema, valueCodec, schemaContext); } diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/MissingSchemaForClassException.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/MissingSchemaForClassException.java index e0e1749d34..4bf75e637f 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/MissingSchemaForClassException.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/context/base/MissingSchemaForClassException.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.MissingSchemaException; import org.opendaylight.mdsal.binding.javav2.runtime.context.BindingRuntimeContext; import org.opendaylight.mdsal.binding.javav2.spec.structural.Augmentation; @@ -31,7 +32,7 @@ public final class MissingSchemaForClassException extends MissingSchemaException private MissingSchemaForClassException(final Class clz) { super(String.format("Schema is not available for %s", clz)); - this.bindingClass = Preconditions.checkNotNull(clz); + this.bindingClass = requireNonNull(clz); } static MissingSchemaForClassException forClass(final Class clz) { diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/serializer/BindingToNormalizedStreamWriter.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/serializer/BindingToNormalizedStreamWriter.java index 28eaba57a9..d98e6b4a98 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/serializer/BindingToNormalizedStreamWriter.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/serializer/BindingToNormalizedStreamWriter.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.serializer; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import java.io.IOException; @@ -49,8 +51,8 @@ public final class BindingToNormalizedStreamWriter private BindingToNormalizedStreamWriter(final NodeCodecContext rootNodeSchema, final NormalizedNodeStreamWriter delegate) { - this.rootNodeSchema = Preconditions.checkNotNull(rootNodeSchema); - this.delegate = Preconditions.checkNotNull(delegate); + this.rootNodeSchema = requireNonNull(rootNodeSchema); + this.delegate = requireNonNull(delegate); } /** diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/serializer/ChoiceDispatchSerializer.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/serializer/ChoiceDispatchSerializer.java index d1dc638ccc..9605fa300f 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/serializer/ChoiceDispatchSerializer.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/serializer/ChoiceDispatchSerializer.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.serializer; +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.mdsal.binding.javav2.spec.base.Instantiable; import org.opendaylight.mdsal.binding.javav2.spec.base.Item; @@ -33,7 +34,7 @@ public final class ChoiceDispatchSerializer implements TreeNodeSerializerImpleme @SuppressWarnings("rawtypes") private ChoiceDispatchSerializer(final Class choiceClass) { - this.choiceClass = Preconditions.checkNotNull(choiceClass); + this.choiceClass = requireNonNull(choiceClass); } /** diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/BitsCodec.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/BitsCodec.java index c7fac4584f..36b870c0e9 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/BitsCodec.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/BitsCodec.java @@ -8,6 +8,8 @@ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.value; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; @@ -46,7 +48,7 @@ final class BitsCodec extends ReflectionBasedCodec implements SchemaUnawareCodec final Map getters) { super(typeClass); - this.ctor = Preconditions.checkNotNull(ctor); + this.ctor = requireNonNull(ctor); this.ctorArgs = ImmutableSet.copyOf(ctorArgs); this.getters = ImmutableMap.copyOf(getters); } diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/EncapsulatedValueCodec.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/EncapsulatedValueCodec.java index 431edbf126..8dc0b02855 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/EncapsulatedValueCodec.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/EncapsulatedValueCodec.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.value; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -38,9 +39,9 @@ public final class EncapsulatedValueCodec extends ReflectionBasedCodec implement final Class valueType) { super(typeClz); - this.constructor = Preconditions.checkNotNull(constructor); - this.getter = Preconditions.checkNotNull(getter); - this.valueType = Preconditions.checkNotNull(valueType); + this.constructor = requireNonNull(constructor); + this.getter = requireNonNull(getter); + this.valueType = requireNonNull(valueType); } static Callable loader(final Class typeClz, final TypeDefinition typeDef) { diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/ReflectionBasedCodec.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/ReflectionBasedCodec.java index 10da93cdda..d9f1bc89aa 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/ReflectionBasedCodec.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/impl/value/ReflectionBasedCodec.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.value; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; @Beta public abstract class ReflectionBasedCodec extends ValueTypeCodec { @@ -17,7 +18,7 @@ public abstract class ReflectionBasedCodec extends ValueTypeCodec { private final Class typeClass; protected ReflectionBasedCodec(final Class typeClass) { - this.typeClass = Preconditions.checkNotNull(typeClass); + this.typeClass = requireNonNull(typeClass); } protected final Class getTypeClass() { diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/modification/LazyDataTreeModification.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/modification/LazyDataTreeModification.java index 39804fbb57..6a127dfaa1 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/modification/LazyDataTreeModification.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/modification/LazyDataTreeModification.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.modification; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -40,8 +41,8 @@ public final class LazyDataTreeModification implements DataT private final TreeNodeModification rootNode; private LazyDataTreeModification(final DataTreeIdentifier path, final TreeNodeModification modification) { - this.path = Preconditions.checkNotNull(path); - this.rootNode = Preconditions.checkNotNull(modification); + this.path = requireNonNull(path); + this.rootNode = requireNonNull(modification); } @Nonnull diff --git a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/modification/LazyTreeNodeModification.java b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/modification/LazyTreeNodeModification.java index 6b3761dda0..f22ba6f4f5 100644 --- a/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/modification/LazyTreeNodeModification.java +++ b/binding2/mdsal-binding2-dom-codec/src/main/java/org/opendaylight/mdsal/binding/javav2/dom/codec/modification/LazyTreeNodeModification.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.binding.javav2.dom.codec.modification; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -51,8 +52,8 @@ final class LazyTreeNodeModification implements TreeNodeModi private Collection> childNodesCache; private LazyTreeNodeModification(final BindingTreeNodeCodec codec, final DataTreeCandidateNode domData) { - this.codec = Preconditions.checkNotNull(codec); - this.domData = Preconditions.checkNotNull(domData); + this.codec = requireNonNull(codec); + this.domData = requireNonNull(domData); this.identifier = codec.deserializePathArgument(domData.getIdentifier()); } diff --git a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/AugmentToGenType.java b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/AugmentToGenType.java index beb9f5ab53..efd19c3b43 100644 --- a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/AugmentToGenType.java +++ b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/AugmentToGenType.java @@ -8,6 +8,7 @@ package org.opendaylight.mdsal.binding.javav2.generator.impl; +import static java.util.Objects.requireNonNull; import static org.opendaylight.mdsal.binding.javav2.generator.impl.GenHelperUtil.processUsesImplements; import com.google.common.annotations.Beta; @@ -178,7 +179,7 @@ final class AugmentToGenType { public static Module findAugmentTargetModule(final SchemaContext schemaContext, final AugmentationSchemaNode aug) { - Preconditions.checkNotNull(aug, "Augmentation schema can not be null."); + requireNonNull(aug, "Augmentation schema can not be null."); final QName first = aug.getTargetPath().getPathFromRoot().iterator().next(); return schemaContext.findModule(first.getModule()).orElse(null); } diff --git a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/BindingGeneratorImpl.java b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/BindingGeneratorImpl.java index cbb4bb2e02..9b30a35957 100644 --- a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/BindingGeneratorImpl.java +++ b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/BindingGeneratorImpl.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.generator.impl; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import java.util.ArrayList; @@ -136,8 +138,8 @@ public class BindingGeneratorImpl implements BindingGenerator { final List filteredGenTypes = new ArrayList<>(); for (final Module m : modules) { - final ModuleContext ctx = Preconditions.checkNotNull(this.genCtx.get(m), - "Module context not found for module %s", m); + final ModuleContext ctx = requireNonNull(this.genCtx.get(m), + () -> "Module context not found for module " + m); filteredGenTypes.addAll(ctx.getGeneratedTypes()); final Set additionalTypes = ((TypeProviderImpl) this.typeProvider).getAdditionalTypes().get(m); if (additionalTypes != null) { diff --git a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/GenHelperUtil.java b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/GenHelperUtil.java index b65758a6cd..9dc44c119e 100755 --- a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/GenHelperUtil.java +++ b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/GenHelperUtil.java @@ -9,6 +9,7 @@ package org.opendaylight.mdsal.binding.javav2.generator.impl; import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; import static org.opendaylight.mdsal.binding.javav2.generator.impl.AuxiliaryGenUtils.addTOToTypeBuilder; import static org.opendaylight.mdsal.binding.javav2.generator.impl.AuxiliaryGenUtils.annotateDeprecatedIfNecessary; import static org.opendaylight.mdsal.binding.javav2.generator.impl.AuxiliaryGenUtils.constructGetter; @@ -299,14 +300,14 @@ final class GenHelperUtil { if (superChildNode instanceof DataNodeContainer || superChildNode instanceof ChoiceSchemaNode) { final QName childQName = createQNameFromSuperNode(module, node, superChildNode); DataSchemaNode childNode = ((DataNodeContainer) node).getDataChildByName(childQName); - Preconditions.checkNotNull(childNode, "%s->%s", node, childQName); + requireNonNull(childNode, () -> node + "->" + childQName); final GeneratedTypeBuilder type = genCtx.get(module).getChildNode(childNode.getPath()); final GeneratedTypeBuilder superType = genCtx.get(superModule).getChildNode(superChildNode .getPath()); - Preconditions.checkNotNull(type, "%s->%s", module, childNode.getPath()); - Preconditions.checkNotNull(superType, "%s->%s", superModule, superChildNode.getPath()); + requireNonNull(type, () -> module + "->" + childNode.getPath()); + requireNonNull(superType, () -> superModule + "->" + superChildNode.getPath()); type.addImplementsType(superType); if (superChildNode instanceof ListSchemaNode && !((ListSchemaNode) superChildNode).getKeyDefinition().isEmpty()) { @@ -326,12 +327,12 @@ final class GenHelperUtil { for (CaseSchemaNode superCaseNode : ((ChoiceSchemaNode) superNode).getCases().values()) { final QName childQName = createQNameFromSuperNode(module, node, superCaseNode); CaseSchemaNode caseNode = ((ChoiceSchemaNode) node).getCaseNodeByName(childQName); - Preconditions.checkNotNull(caseNode, "%s->%s", node, childQName); + requireNonNull(caseNode, () -> node + "->" + childQName); final GeneratedTypeBuilder type = genCtx.get(module).getCase(caseNode.getPath()); final GeneratedTypeBuilder superType = genCtx.get(superModule).getCase(superCaseNode.getPath()); - Preconditions.checkNotNull(type, "%s->%s", module, caseNode.getPath()); - Preconditions.checkNotNull(superType, "%s->%s", superModule, superCaseNode.getPath()); + requireNonNull(type, () -> module + "->" + caseNode.getPath()); + requireNonNull(superType, () -> superModule + "->" + superCaseNode.getPath()); type.addImplementsType(superType); addUsesImplements(superCaseNode, superModule, caseNode, module, schemaContext, genCtx, namespaceType); } @@ -364,7 +365,7 @@ final class GenHelperUtil { } } - Preconditions.checkNotNull(groupingNode, "%s->%s", module, usesNode.getGroupingPath()); + requireNonNull(groupingNode, () -> module + "->" + usesNode.getGroupingPath()); Preconditions.checkState(groupingNode instanceof GroupingDefinition, "%s->%s", module, usesNode.getGroupingPath()); return (GroupingDefinition) groupingNode; @@ -910,7 +911,7 @@ final class GenHelperUtil { || typeDef instanceof UnionTypeDefinition || typeDef instanceof BitsTypeDefinition)) { LeafSchemaNode originalLeaf = (LeafSchemaNode) ((DerivableSchemaNode) leaf).getOriginal() .orElse(null); - Preconditions.checkNotNull(originalLeaf); + requireNonNull(originalLeaf); returnType = genCtx.get(findParentModule(schemaContext, originalLeaf)).getInnerType(typeDef .getPath()); } else { @@ -1388,7 +1389,7 @@ final class GenHelperUtil { final IdentitySchemaNode identity, final Module module, final boolean verboseClassComments, final Map genCtx) { - Preconditions.checkNotNull(identity, "Identity can not be null!"); + requireNonNull(identity, "Identity can not be null!"); //check first if identity has been resolved as base identity of some other one GeneratedTypeBuilder newType = findIdentityByQname(identity.getQName(), genCtx); diff --git a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/RpcActionGenHelper.java b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/RpcActionGenHelper.java index edc5560cf5..a1446fd298 100755 --- a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/RpcActionGenHelper.java +++ b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/RpcActionGenHelper.java @@ -35,13 +35,10 @@ import static org.opendaylight.mdsal.binding.javav2.generator.util.Types.paramet import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; - import java.util.Collection; import java.util.Map; import java.util.Optional; import java.util.Set; - import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; import org.opendaylight.mdsal.binding.javav2.generator.spi.TypeProvider; import org.opendaylight.mdsal.binding.javav2.generator.util.BindingTypes; @@ -106,7 +103,7 @@ final class RpcActionGenHelper { final Map> genTypeBuilders, final Map genCtx, final TypeProvider typeProvider, final BindingNamespaceType namespaceType) { - Preconditions.checkNotNull(parent, "Parent should not be NULL."); + requireNonNull(parent, "Parent should not be NULL."); final Collection potentials = parent.getChildNodes(); for (DataSchemaNode potential : potentials) { if (resolveDataSchemaNodesCheck(module, schemaContext, potential)) { diff --git a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/yang/types/TypeGenHelper.java b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/yang/types/TypeGenHelper.java index d827fca3d6..f90263ab1e 100755 --- a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/yang/types/TypeGenHelper.java +++ b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/yang/types/TypeGenHelper.java @@ -8,6 +8,7 @@ package org.opendaylight.mdsal.binding.javav2.generator.yang.types; +import static java.util.Objects.requireNonNull; import static org.opendaylight.mdsal.binding.javav2.generator.util.BindingGeneratorUtil.encodeAngleBrackets; import static org.opendaylight.mdsal.binding.javav2.generator.yang.types.TypeProviderImpl.addUnitsToGenTO; import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule; @@ -180,7 +181,7 @@ public final class TypeGenHelper { static GeneratedTransferObject wrapJavaTypeIntoTO(final String basePackageName, final TypeDefinition typedef, final Type javaType, final String moduleName, final ModuleContext context) { - Preconditions.checkNotNull(javaType, "javaType cannot be null"); + requireNonNull(javaType, "javaType cannot be null"); final String propertyName = "value"; final GeneratedTOBuilderImpl genTOBuilder = typedefToTransferObject(basePackageName, typedef, moduleName, diff --git a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/yang/types/TypeProviderImpl.java b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/yang/types/TypeProviderImpl.java index 33b0b86956..e9662be608 100755 --- a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/yang/types/TypeProviderImpl.java +++ b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/yang/types/TypeProviderImpl.java @@ -8,6 +8,7 @@ package org.opendaylight.mdsal.binding.javav2.generator.yang.types; +import static java.util.Objects.requireNonNull; import static org.opendaylight.mdsal.binding.javav2.generator.util.BindingGeneratorUtil.encodeAngleBrackets; import static org.opendaylight.mdsal.binding.javav2.generator.util.BindingGeneratorUtil.packageNameWithNamespacePrefix; import static org.opendaylight.mdsal.binding.javav2.generator.util.Types.getOuterClassPackageName; @@ -345,9 +346,9 @@ public final class TypeProviderImpl implements TypeProvider { public List provideGeneratedTOBuildersForUnionTypeDef(final String basePackageName, final UnionTypeDefinition typedef, final String typeDefName, final SchemaNode parentNode, final ModuleContext context) { - Preconditions.checkNotNull(basePackageName, "Base Package Name cannot be NULL!"); - Preconditions.checkNotNull(typedef, "Type Definition cannot be NULL!"); - Preconditions.checkNotNull(typedef.getQName(), "Type definition QName cannot be NULL!"); + requireNonNull(basePackageName, "Base Package Name cannot be NULL!"); + requireNonNull(typedef, "Type Definition cannot be NULL!"); + requireNonNull(typedef.getQName(), "Type definition QName cannot be NULL!"); final List generatedTOBuilders = new ArrayList<>(); final List> unionTypes = typedef.getTypes(); diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/AbstractBaseType.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/AbstractBaseType.java index f12b041345..9186a7fd97 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/AbstractBaseType.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/AbstractBaseType.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.generator.util; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import java.util.Objects; import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext; import org.opendaylight.mdsal.binding.javav2.model.api.Type; @@ -41,10 +42,10 @@ public abstract class AbstractBaseType implements Type { * string with the name for this Type */ protected AbstractBaseType(final String pkName, final String name, final ModuleContext context) { - Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!"); - Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!"); + requireNonNull(pkName, "Package Name for Generated Type cannot be null!"); + requireNonNull(name, "Name of Generated Type cannot be null!"); this.packageName = JavaIdentifierNormalizer.normalizeFullPackageName(pkName); - Preconditions.checkNotNull(context, + requireNonNull(context, "In case of not having identifiers normalized, ModuleContext instance must be provided."); this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context); } @@ -63,14 +64,14 @@ public abstract class AbstractBaseType implements Type { */ protected AbstractBaseType(final String pkName, final String name, final boolean isNormalized, final ModuleContext context) { - Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!"); - Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!"); + requireNonNull(pkName, "Package Name for Generated Type cannot be null!"); + requireNonNull(name, "Name of Generated Type cannot be null!"); if (isNormalized) { this.packageName = pkName; this.name = name; } else { this.packageName = JavaIdentifierNormalizer.normalizeFullPackageName(pkName); - Preconditions.checkNotNull(context, + requireNonNull(context, "In case of not having identifiers normalized, ModuleContext instance must be provided."); this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context); } @@ -78,8 +79,8 @@ public abstract class AbstractBaseType implements Type { protected AbstractBaseType(final String pkName, final String name, final boolean isPkNameNormalized, final boolean isTypeNormalized, final ModuleContext context) { - Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!"); - Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!"); + requireNonNull(pkName, "Package Name for Generated Type cannot be null!"); + requireNonNull(name, "Name of Generated Type cannot be null!"); if (isPkNameNormalized) { this.packageName = pkName; } else { @@ -89,7 +90,7 @@ public abstract class AbstractBaseType implements Type { if (isTypeNormalized) { this.name = name; } else { - Preconditions.checkNotNull(context, + requireNonNull(context, "In case of not having identifiers normalized ModuleContext instance must be provided."); this.name = JavaIdentifierNormalizer.normalizeClassIdentifier(pkName, name, context); } diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/Types.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/Types.java index 33f9aa5742..ff58d6cffa 100644 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/Types.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/Types.java @@ -8,9 +8,10 @@ package org.opendaylight.mdsal.binding.javav2.generator.util; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.CharMatcher; -import com.google.common.base.Preconditions; import com.google.common.base.Splitter; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; @@ -306,13 +307,13 @@ public final class Types { */ private BaseTypeWithRestrictionsImpl(final String pkName, final String name, final Restrictions restrictions) { super(pkName, name, null); - this.restrictions = Preconditions.checkNotNull(restrictions); + this.restrictions = requireNonNull(restrictions); } private BaseTypeWithRestrictionsImpl(final String pkName, final String name, final Restrictions restrictions, final ModuleContext moduleContext) { super(pkName, name, moduleContext); - this.restrictions = Preconditions.checkNotNull(restrictions); + this.restrictions = requireNonNull(restrictions); } @Override @@ -398,8 +399,8 @@ public final class Types { private final RangeConstraint rangeConstraint; private DefaultRestrictions(final T min, final T max) { - Preconditions.checkNotNull(min); - Preconditions.checkNotNull(max); + requireNonNull(min); + requireNonNull(max); this.rangeConstraint = new RangeConstraint() { @Override diff --git a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java index 7d7dfe46ff..fd3da8fbac 100755 --- a/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java +++ b/binding2/mdsal-binding2-generator-util/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/util/generated/type/builder/AbstractGeneratedTypeBuilder.java @@ -8,6 +8,8 @@ package org.opendaylight.mdsal.binding.javav2.generator.util.generated.type.builder; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -128,7 +130,7 @@ abstract class AbstractGeneratedTypeBuilder types) { - this.buildContext = Preconditions.checkNotNull(buildContext); - this.types = Preconditions.checkNotNull(types); + this.buildContext = requireNonNull(buildContext); + this.types = requireNonNull(types); this.generators.add(new EnumGenerator()); this.generators.add(new InterfaceGenerator()); this.generators.add(new BuilderGenerator()); diff --git a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/range_generators/AbstractPrimitiveRangeGenerator.java b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/range_generators/AbstractPrimitiveRangeGenerator.java index 3779f4a04f..15120b42fd 100644 --- a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/range_generators/AbstractPrimitiveRangeGenerator.java +++ b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/range_generators/AbstractPrimitiveRangeGenerator.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.java.api.generator.range_generators; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.Range; import java.util.ArrayList; import java.util.Collection; @@ -26,9 +27,9 @@ abstract class AbstractPrimitiveRangeGenerator> protected AbstractPrimitiveRangeGenerator(final Class typeClass, final String primitiveName, final T minValue, final T maxValue) { super(typeClass); - this.primitiveName = Preconditions.checkNotNull(primitiveName); - this.minValue = Preconditions.checkNotNull(minValue); - this.maxValue = Preconditions.checkNotNull(maxValue); + this.primitiveName = requireNonNull(primitiveName); + this.minValue = requireNonNull(minValue); + this.maxValue = requireNonNull(maxValue); } /** diff --git a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/range_generators/AbstractRangeGenerator.java b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/range_generators/AbstractRangeGenerator.java index b524a9bcc7..007e39b868 100644 --- a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/range_generators/AbstractRangeGenerator.java +++ b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/range_generators/AbstractRangeGenerator.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.java.api.generator.range_generators; -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 java.util.Map; @@ -45,7 +46,7 @@ public abstract class AbstractRangeGenerator> { private final Class type; protected AbstractRangeGenerator(final Class typeClass) { - this.type = Preconditions.checkNotNull(typeClass); + this.type = requireNonNull(typeClass); } public static AbstractRangeGenerator forType(@Nonnull final Type type) { diff --git a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/BaseRenderer.java b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/BaseRenderer.java index c7b66e927d..e81dd9d84a 100644 --- a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/BaseRenderer.java +++ b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/BaseRenderer.java @@ -9,8 +9,8 @@ package org.opendaylight.mdsal.binding.javav2.java.api.generator.renderers; import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import java.util.Collection; @@ -44,7 +44,7 @@ public abstract class BaseRenderer { private final Map importedNames = new HashMap<>(); protected BaseRenderer(final GeneratedType type) { - this.genType = Preconditions.checkNotNull(type); + this.genType = requireNonNull(type); this.importMap = new HashMap<>(); } @@ -167,9 +167,9 @@ public abstract class BaseRenderer { checkArgument(parentGenType.getPackageName() != null, "Parent Generated Type cannot have Package Name referenced as NULL!"); - final String typeName = Preconditions.checkNotNull(type.getName()); - final String typePackageName = Preconditions.checkNotNull(type.getPackageName()); - final String parentTypeName = Preconditions.checkNotNull(parentGenType.getName()); + final String typeName = requireNonNull(type.getName()); + final String typePackageName = requireNonNull(type.getPackageName()); + final String parentTypeName = requireNonNull(parentGenType.getName()); if (typeName.equals(parentTypeName) || typePackageName.startsWith("java.lang") || typePackageName.isEmpty()) { return; } @@ -199,8 +199,8 @@ public abstract class BaseRenderer { checkArgument(type != null, "Type parameter MUST be specified and cannot be NULL!"); checkArgument(importMap != null, "Imports Map cannot be NULL!"); - final String typePackageName = Preconditions.checkNotNull(type.getPackageName()); - final String typeName = Preconditions.checkNotNull(type.getName()); + final String typePackageName = requireNonNull(type.getPackageName()); + final String typeName = requireNonNull(type.getName()); final String importedPackageName = importMap.get(typeName); final StringBuilder sb; if (typePackageName.equals(importedPackageName)) { @@ -325,7 +325,7 @@ public abstract class BaseRenderer { protected String getterMethod(final GeneratedProperty field) { final StringBuilder sb = new StringBuilder(); final String name = TextTemplateUtil.fieldName(field); - final String importedName = Preconditions.checkNotNull(importedName(field.getReturnType())); + final String importedName = requireNonNull(importedName(field.getReturnType())); sb.append("public ") .append(importedName) .append(' ') diff --git a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/ClassRenderer.java b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/ClassRenderer.java index d727dbffbd..962955900d 100644 --- a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/ClassRenderer.java +++ b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/ClassRenderer.java @@ -8,6 +8,7 @@ package org.opendaylight.mdsal.binding.javav2.java.api.generator.renderers; +import static java.util.Objects.requireNonNull; import static org.opendaylight.mdsal.binding.javav2.java.api.generator.util.TextTemplateUtil.fieldName; import static org.opendaylight.mdsal.binding.javav2.java.api.generator.util.TextTemplateUtil.setterMethod; @@ -83,7 +84,7 @@ public class ClassRenderer extends BaseRenderer { if (restrictions != null && restrictions.getRangeConstraint().isPresent()) { rangeGenerator = AbstractRangeGenerator.forType(findProperty(genType, "value").getReturnType()); - Preconditions.checkNotNull(rangeGenerator); + requireNonNull(rangeGenerator); } else { rangeGenerator = null; } diff --git a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/InterfaceRenderer.java b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/InterfaceRenderer.java index 369e2bf660..6ac8d53cb1 100755 --- a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/InterfaceRenderer.java +++ b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/InterfaceRenderer.java @@ -8,7 +8,8 @@ package org.opendaylight.mdsal.binding.javav2.java.api.generator.renderers; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.util.AbstractMap.SimpleEntry; import java.util.ArrayDeque; import java.util.ArrayList; @@ -45,7 +46,7 @@ public class InterfaceRenderer extends BaseRenderer { */ public InterfaceRenderer(final GeneratedType type) { super(type); - Preconditions.checkNotNull(type, "Generated type reference cannot be NULL!"); + requireNonNull(type, "Generated type reference cannot be NULL!"); } @Override diff --git a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/UnionRenderer.java b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/UnionRenderer.java index 4d42e3130c..890c440780 100644 --- a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/UnionRenderer.java +++ b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/renderers/UnionRenderer.java @@ -7,6 +7,7 @@ */ package org.opendaylight.mdsal.binding.javav2.java.api.generator.renderers; +import static java.util.Objects.requireNonNull; import static org.opendaylight.mdsal.binding.javav2.generator.util.Types.BOOLEAN; import com.google.common.base.Preconditions; @@ -188,7 +189,7 @@ public class UnionRenderer extends ClassRenderer { final StringBuilder sb1 = new StringBuilder(); final String name = TextTemplateUtil.fieldName(field); - final String importedName = Preconditions.checkNotNull(importedName(field.getReturnType())); + final String importedName = requireNonNull(importedName(field.getReturnType())); sb1.append("public ") .append(importedName) .append(' ') diff --git a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/util/TextTemplateUtil.java b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/util/TextTemplateUtil.java index f825bba659..fe357898d2 100755 --- a/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/util/TextTemplateUtil.java +++ b/binding2/mdsal-binding2-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/javav2/java/api/generator/util/TextTemplateUtil.java @@ -8,6 +8,8 @@ package org.opendaylight.mdsal.binding.javav2.java.api.generator.util; +import static java.util.Objects.requireNonNull; + import com.google.common.base.CharMatcher; import com.google.common.base.Preconditions; import com.google.common.base.Splitter; @@ -381,7 +383,7 @@ public final class TextTemplateUtil { * @return underscored string form */ public static String fieldName(final GeneratedProperty property) { - final String name = Preconditions.checkNotNull(property.getName()); + final String name = requireNonNull(property.getName()); return UNDERSCORE.concat(name); } @@ -402,8 +404,8 @@ public final class TextTemplateUtil { * @return getter for property */ public static String getterMethodName(final GeneratedProperty field) { - final Type type = Preconditions.checkNotNull(field.getReturnType()); - final String name = Preconditions.checkNotNull(field.getName()); + final Type type = requireNonNull(field.getReturnType()); + final String name = requireNonNull(field.getName()); final String prefix = Types.BOOLEAN.equals(type) ? "is" : "get"; return prefix.concat(toFirstUpper(name)); } @@ -458,7 +460,7 @@ public final class TextTemplateUtil { * @return getter name without prefix */ public static String propertyNameFromGetter(final MethodSignature getter) { - final String name = Preconditions.checkNotNull(getter.getName()); + final String name = requireNonNull(getter.getName()); int prefix; if (name.startsWith("is")) { prefix = 2; diff --git a/binding2/mdsal-binding2-maven-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/javav2/maven/api/gen/plugin/CodeGeneratorImpl.java b/binding2/mdsal-binding2-maven-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/javav2/maven/api/gen/plugin/CodeGeneratorImpl.java index c81c5c74fe..937fa9dd00 100644 --- a/binding2/mdsal-binding2-maven-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/javav2/maven/api/gen/plugin/CodeGeneratorImpl.java +++ b/binding2/mdsal-binding2-maven-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/javav2/maven/api/gen/plugin/CodeGeneratorImpl.java @@ -8,12 +8,12 @@ package org.opendaylight.mdsal.binding.javav2.maven.api.gen.plugin; +import static java.util.Objects.requireNonNull; import static org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer.normalizeFullPackageName; import static org.opendaylight.mdsal.binding.javav2.util.BindingMapping.getRootPackageName; import com.google.common.annotations.Beta; import com.google.common.base.Joiner; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; import java.io.BufferedWriter; @@ -106,7 +106,7 @@ public final class CodeGeneratorImpl implements BasicCodeGenerator, BuildContext @Override public void setBuildContext(BuildContext buildContext) { - this.buildContext = Preconditions.checkNotNull(buildContext); + this.buildContext = requireNonNull(buildContext); } @Override diff --git a/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/context/BindingRuntimeContext.java b/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/context/BindingRuntimeContext.java index e89f921d83..8d43e29c30 100755 --- a/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/context/BindingRuntimeContext.java +++ b/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/context/BindingRuntimeContext.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.runtime.context; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.cache.CacheBuilder; @@ -346,10 +348,10 @@ public class BindingRuntimeContext implements Immutable { private Entry getTypeWithSchema(final Type referencedType) { final Object schema = this.typeToDefiningSchema.get(referencedType); - Preconditions.checkNotNull(schema, "Failed to find schema for type %s", referencedType); + requireNonNull(schema, () -> "Failed to find schema for type " + referencedType); final Type definedType = this.typeToDefiningSchema.inverse().get(schema); - Preconditions.checkNotNull(definedType, "Failed to find defined type for %s schema %s", referencedType, schema); + requireNonNull(definedType, () -> "Failed to find defined type for " + referencedType + " schema " + schema); if (definedType instanceof GeneratedTypeBuilder) { return new SimpleEntry<>(((GeneratedTypeBuilder) definedType).toInstance(), schema); diff --git a/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/javassist/JavassistUtils.java b/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/javassist/JavassistUtils.java index f2b0483f47..41bfd6a05f 100644 --- a/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/javassist/JavassistUtils.java +++ b/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/javassist/JavassistUtils.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.binding.javav2.runtime.javassist; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import java.util.Collection; @@ -39,7 +41,7 @@ public final class JavassistUtils { private final ClassPool classPool; private JavassistUtils(final ClassPool pool) { - classPool = Preconditions.checkNotNull(pool); + classPool = requireNonNull(pool); } /** @@ -52,7 +54,7 @@ public final class JavassistUtils { * @return shared utility instance for specified pool */ public static synchronized JavassistUtils forClassPool(final ClassPool pool) { - JavassistUtils ret = INSTANCES.get(Preconditions.checkNotNull(pool)); + JavassistUtils ret = INSTANCES.get(requireNonNull(pool)); if (ret == null) { ret = new JavassistUtils(pool); INSTANCES.put(pool, ret); diff --git a/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/reflection/AugmentationFieldGetter.java b/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/reflection/AugmentationFieldGetter.java index 77fbff5722..008d741d61 100644 --- a/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/reflection/AugmentationFieldGetter.java +++ b/binding2/mdsal-binding2-runtime/src/main/java/org/opendaylight/mdsal/binding/javav2/runtime/reflection/AugmentationFieldGetter.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.runtime.reflection; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -97,7 +98,7 @@ abstract class AugmentationFieldGetter { private final MethodHandle fieldGetter; ReflectionAugmentationFieldGetter(final MethodHandle mh) { - this.fieldGetter = Preconditions.checkNotNull(mh); + this.fieldGetter = requireNonNull(mh); } @Override diff --git a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/IdentifiableItem.java b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/IdentifiableItem.java index 038adb0ce9..9928032175 100644 --- a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/IdentifiableItem.java +++ b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/IdentifiableItem.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.spec.base; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; /** * An IdentifiableItem represents a object that is usually present in a collection and can be @@ -24,8 +25,8 @@ public final class IdentifiableItem extends TreeArgument< private final T key; public IdentifiableItem(final Class type, final T key) { - this.type = Preconditions.checkNotNull(type); - this.key = Preconditions.checkNotNull(key, "Key may not be null."); + this.type = requireNonNull(type); + this.key = requireNonNull(key, "Key may not be null."); } @Override diff --git a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/InstanceIdentifier.java b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/InstanceIdentifier.java index 60e2faaf93..b0fe028e51 100644 --- a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/InstanceIdentifier.java +++ b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/InstanceIdentifier.java @@ -8,6 +8,8 @@ package org.opendaylight.mdsal.binding.javav2.spec.base; +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; @@ -89,8 +91,8 @@ public class InstanceIdentifier implements Path type, final Iterable pathArguments, final boolean wildcarded, final int hash) { - this.pathArguments = Preconditions.checkNotNull(pathArguments); - this.targetType = Preconditions.checkNotNull(type); + this.pathArguments = requireNonNull(pathArguments); + this.targetType = requireNonNull(type); this.wildcarded = wildcarded; this.hash = hash; } @@ -289,7 +291,7 @@ public class InstanceIdentifier implements Path other) { - Preconditions.checkNotNull(other, "other should not be null"); + requireNonNull(other, "other should not be null"); final Iterator lit = pathArguments.iterator(); final Iterator oit = other.pathArguments.iterator(); @@ -316,7 +318,7 @@ public class InstanceIdentifier implements Path other) { - Preconditions.checkNotNull(other, "other should not be null"); + requireNonNull(other, "other should not be null"); final Iterator lit = pathArguments.iterator(); final Iterator oit = other.pathArguments.iterator(); @@ -441,7 +443,7 @@ public class InstanceIdentifier implements Path internalCreate(final Iterable pathArguments) { - final Iterator it = Preconditions.checkNotNull(pathArguments, "pathArguments may not be null").iterator(); + final Iterator it = requireNonNull(pathArguments, "pathArguments may not be null").iterator(); final HashCodeBuilder hashBuilder = new HashCodeBuilder<>(); boolean wildcard = false; TreeArgument a = null; @@ -514,7 +516,7 @@ public class InstanceIdentifier implements Path K keyOf( final InstanceIdentifier id) { - Preconditions.checkNotNull(id); + requireNonNull(id); Preconditions.checkArgument(id instanceof KeyedInstanceIdentifier, "%s does not have a key", id); @SuppressWarnings("unchecked") diff --git a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/Item.java b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/Item.java index eb1e079b75..1e0a12f527 100644 --- a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/Item.java +++ b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/Item.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.spec.base; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; /** * An Item represents an object that probably is only one of it's kind. For example a Nodes object @@ -23,7 +24,7 @@ public final class Item extends TreeArgument { private final Class type; public Item(final Class type) { - this.type = Preconditions.checkNotNull(type); + this.type = requireNonNull(type); } @Override diff --git a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/runtime/BindingNamespaceType.java b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/runtime/BindingNamespaceType.java index 4ca7c6a29d..6ed5cbd8bb 100755 --- a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/runtime/BindingNamespaceType.java +++ b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/runtime/BindingNamespaceType.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.spec.runtime; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; /** * Binding Namespace is structure of Java packages designed to prevent conflicts in YANG Java @@ -29,7 +30,7 @@ public enum BindingNamespaceType { private final String packagePrefix; BindingNamespaceType(String packagePrefix) { - this.packagePrefix = Preconditions.checkNotNull(packagePrefix); + this.packagePrefix = requireNonNull(packagePrefix); } public String getPackagePrefix() { diff --git a/binding2/mdsal-binding2-util/src/main/java/org/opendaylight/mdsal/binding/javav2/util/StringValueObjectFactory.java b/binding2/mdsal-binding2-util/src/main/java/org/opendaylight/mdsal/binding/javav2/util/StringValueObjectFactory.java index 3d450a6e23..76650c03fd 100644 --- a/binding2/mdsal-binding2-util/src/main/java/org/opendaylight/mdsal/binding/javav2/util/StringValueObjectFactory.java +++ b/binding2/mdsal-binding2-util/src/main/java/org/opendaylight/mdsal/binding/javav2/util/StringValueObjectFactory.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.binding.javav2.util; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -46,9 +47,9 @@ public final class StringValueObjectFactory { private final T template; private StringValueObjectFactory(final T template, final MethodHandle constructor, final MethodHandle setter) { - this.template = Preconditions.checkNotNull(template); + this.template = requireNonNull(template); this.constructor = constructor.bindTo(template); - this.setter = Preconditions.checkNotNull(setter); + this.setter = requireNonNull(setter); } public static StringValueObjectFactory create(final Class clazz, final String templateString) { @@ -116,7 +117,7 @@ public final class StringValueObjectFactory { } public T newInstance(final String string) { - Preconditions.checkNotNull(string, "Argument may not be null"); + requireNonNull(string, "Argument may not be null"); try { final T ret = (T) constructor.invokeExact(); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRoutingTable.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRoutingTable.java index dca4a1de7f..914164d62d 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRoutingTable.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRoutingTable.java @@ -7,9 +7,10 @@ */ package org.opendaylight.mdsal.dom.broker; +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.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; @@ -44,7 +45,7 @@ abstract class AbstractDOMRoutingTable operations, final SchemaContext schemaContext) { - this.operations = Preconditions.checkNotNull(operations); + this.operations = requireNonNull(operations); this.schemaContext = schemaContext; } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRoutingTableEntry.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRoutingTableEntry.java index 89cd70de5f..f227b122fd 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRoutingTableEntry.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRoutingTableEntry.java @@ -7,9 +7,10 @@ */ package org.opendaylight.mdsal.dom.broker; +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.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import java.util.ArrayList; @@ -33,8 +34,8 @@ abstract class AbstractDOMRoutingTableEntry { private final SchemaPath type; AbstractDOMRoutingTableEntry(final SchemaPath type, final Map> implementations) { - this.type = Preconditions.checkNotNull(type); - this.implementations = Preconditions.checkNotNull(implementations); + this.type = requireNonNull(type); + this.implementations = requireNonNull(implementations); } SchemaPath getType() { diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRpcRoutingTableEntry.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRpcRoutingTableEntry.java index 527f19a935..a4fab0c762 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRpcRoutingTableEntry.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRpcRoutingTableEntry.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.dom.broker; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.Maps; import java.util.Comparator; import java.util.List; @@ -25,7 +26,7 @@ abstract class AbstractDOMRpcRoutingTableEntry extends AbstractDOMRoutingTableEn AbstractDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId, final Map> implementations) { super(rpcId.getType(), implementations); - this.rpcId = Preconditions.checkNotNull(rpcId); + this.rpcId = requireNonNull(rpcId); } final DOMRpcIdentifier getRpcId() { diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/CommitCoordinationTask.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/CommitCoordinationTask.java index 262b0b35dd..64ebada794 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/CommitCoordinationTask.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/CommitCoordinationTask.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.dom.broker; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Throwables; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -41,8 +42,8 @@ final class CommitCoordinationTask implements Callable { CommitCoordinationTask(final DOMDataTreeWriteTransaction transaction, final Collection cohorts, final DurationStatisticsTracker commitStatTracker) { - 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; } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataBrokerTransactionChainImpl.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataBrokerTransactionChainImpl.java index 2ae90b997f..2421061081 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataBrokerTransactionChainImpl.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataBrokerTransactionChainImpl.java @@ -8,6 +8,8 @@ package org.opendaylight.mdsal.dom.broker; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; @@ -76,8 +78,8 @@ final class DOMDataBrokerTransactionChainImpl extends AbstractDOMForwardedTransa final AbstractDOMDataBroker 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() { diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataTreeShardRegistration.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataTreeShardRegistration.java index f0d002cbe0..608b71d46d 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataTreeShardRegistration.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataTreeShardRegistration.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.dom.broker; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMDataTreeShard; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; @@ -21,8 +22,8 @@ public final class DOMDataTreeShardRegistration exte public DOMDataTreeShardRegistration(final ShardedDOMDataTree tree, final DOMDataTreeIdentifier prefix, final T shard) { super(shard); - this.tree = Preconditions.checkNotNull(tree); - this.prefix = Preconditions.checkNotNull(prefix); + this.tree = requireNonNull(tree); + this.prefix = requireNonNull(prefix); } public DOMDataTreeIdentifier getPrefix() { diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java index ea79cae321..6eafd0696f 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.dom.broker; -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; @@ -34,8 +35,8 @@ final class DOMNotificationRouterEvent { @SuppressWarnings("checkstyle:hiddenField") ListenableFuture initialize(final DOMNotification notification, final Collection> 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; } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/SerializedDOMDataBroker.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/SerializedDOMDataBroker.java index 2f62c7bde0..4053475ccb 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/SerializedDOMDataBroker.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/SerializedDOMDataBroker.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.dom.broker; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.ListeningExecutorService; @@ -53,7 +55,7 @@ public class SerializedDOMDataBroker extends AbstractDOMDataBroker { public SerializedDOMDataBroker(final Map 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() { diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducer.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducer.java index f377c9322f..d02e27cfb4 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducer.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.dom.broker; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Preconditions; import com.google.common.base.Verify; import com.google.common.collect.ImmutableSet; @@ -58,7 +60,7 @@ class ShardedDOMDataTreeProducer implements DOMDataTreeProducer { ShardedDOMDataTreeProducer(final ShardedDOMDataTree dataTree, final Collection subtrees, final Map shardMap) { - this.dataTree = Preconditions.checkNotNull(dataTree); + this.dataTree = requireNonNull(dataTree); this.subtrees = ImmutableSet.copyOf(subtrees); this.layout = ProducerLayout.create(shardMap); } @@ -274,6 +276,6 @@ class ShardedDOMDataTreeProducer implements DOMDataTreeProducer { void bindToListener(final DOMDataTreeListener listener) { final DOMDataTreeListener local = attachedListener; Preconditions.checkState(local == null, "Producer %s is already attached to listener %s", this, local); - this.attachedListener = Preconditions.checkNotNull(listener); + this.attachedListener = requireNonNull(listener); } } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeWriteTransaction.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeWriteTransaction.java index a365290db1..28b91dc141 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeWriteTransaction.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeWriteTransaction.java @@ -7,6 +7,8 @@ */ package org.opendaylight.mdsal.dom.broker; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.FluentFuture; @@ -56,9 +58,9 @@ final class ShardedDOMDataTreeWriteTransaction implements DOMDataTreeCursorAware ShardedDOMDataTreeWriteTransaction(final ShardedDOMDataTreeProducer producer, final Map transactions, final ProducerLayout layout) { - this.producer = Preconditions.checkNotNull(producer); + this.producer = requireNonNull(producer); this.transactions = ImmutableMap.copyOf(transactions); - this.layout = Preconditions.checkNotNull(layout); + this.layout = requireNonNull(layout); this.identifier = "SHARDED-DOM-" + COUNTER.getAndIncrement(); LOG.debug("Created new transaction {}", identifier); } @@ -179,8 +181,8 @@ final class ShardedDOMDataTreeWriteTransaction implements DOMDataTreeCursorAware private final DOMDataTreeIdentifier rootPosition; DelegatingCursor(final DOMDataTreeWriteCursor delegate, final DOMDataTreeIdentifier rootPosition) { - this.delegate = Preconditions.checkNotNull(delegate); - this.rootPosition = Preconditions.checkNotNull(rootPosition); + this.delegate = requireNonNull(delegate); + this.rootPosition = requireNonNull(rootPosition); currentArgs.addAll(rootPosition.getRootIdentifier().getPathArguments()); } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainWriteTransaction.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainWriteTransaction.java index 30b7e5ce81..435067bccb 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainWriteTransaction.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainWriteTransaction.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.dom.broker; -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.FutureCallback; import com.google.common.util.concurrent.MoreExecutors; @@ -26,9 +27,9 @@ public class TransactionChainWriteTransaction implements DOMDataTreeWriteTransac public TransactionChainWriteTransaction(final Object identifier, final DOMDataTreeWriteTransaction delegateTx, final ShardedDOMTransactionChainAdapter txChain) { - this.delegateTx = Preconditions.checkNotNull(delegateTx); - this.identifier = Preconditions.checkNotNull(identifier); - this.txChain = Preconditions.checkNotNull(txChain); + this.delegateTx = requireNonNull(delegateTx); + this.identifier = requireNonNull(identifier); + this.txChain = requireNonNull(txChain); } diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ChainedTransactionCommitImpl.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ChainedTransactionCommitImpl.java index a81ee295cb..2f83695e20 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ChainedTransactionCommitImpl.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ChainedTransactionCommitImpl.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.dom.store.inmemory; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; @@ -21,7 +22,7 @@ final class ChainedTransactionCommitImpl extends InMemoryDOMStoreThreePhaseCommi final DOMStoreTransactionChainImpl txChain, final Exception operationError) { super(store, transaction, modification, operationError); - this.txChain = Preconditions.checkNotNull(txChain); + this.txChain = requireNonNull(txChain); } @Override diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/DOMStoreTransactionChainImpl.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/DOMStoreTransactionChainImpl.java index 0018d0eb90..6f512e2024 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/DOMStoreTransactionChainImpl.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/DOMStoreTransactionChainImpl.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.dom.store.inmemory; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import org.opendaylight.mdsal.dom.spi.store.AbstractSnapshotBackedTransactionChain; import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction; @@ -18,7 +19,7 @@ final class DOMStoreTransactionChainImpl extends AbstractSnapshotBackedTransacti private final InMemoryDOMDataStore store; DOMStoreTransactionChainImpl(final InMemoryDOMDataStore store) { - this.store = Preconditions.checkNotNull(store); + this.store = requireNonNull(store); } @Override diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/DataTreeModificationCursorAdaptor.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/DataTreeModificationCursorAdaptor.java index dbd6cadacd..5c6b55fb19 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/DataTreeModificationCursorAdaptor.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/DataTreeModificationCursorAdaptor.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.dom.store.inmemory; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.ForwardingObject; import java.util.Optional; import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor; @@ -20,7 +21,7 @@ final class DataTreeModificationCursorAdaptor extends ForwardingObject implement private final DataTreeModificationCursor delegate; private DataTreeModificationCursorAdaptor(final DataTreeModificationCursor delegate) { - this.delegate = Preconditions.checkNotNull(delegate); + this.delegate = requireNonNull(delegate); } static DataTreeModificationCursorAdaptor of(final DataTreeModificationCursor dataTreeCursor) { diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ForeignShardThreePhaseCommitCohort.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ForeignShardThreePhaseCommitCohort.java index 324a8be540..30e3c529d4 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ForeignShardThreePhaseCommitCohort.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ForeignShardThreePhaseCommitCohort.java @@ -8,7 +8,8 @@ package org.opendaylight.mdsal.dom.store.inmemory; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; @@ -29,8 +30,8 @@ public class ForeignShardThreePhaseCommitCohort implements DOMStoreThreePhaseCom public ForeignShardThreePhaseCommitCohort(final DOMDataTreeIdentifier prefix, final ForeignShardModificationContext shard) { - this.prefix = Preconditions.checkNotNull(prefix); - this.shard = Preconditions.checkNotNull(shard); + this.prefix = requireNonNull(prefix); + this.shard = requireNonNull(shard); } @Override diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataTreeShardThreePhaseCommitCohort.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataTreeShardThreePhaseCommitCohort.java index 1f8c9cbcd3..e8aab53883 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataTreeShardThreePhaseCommitCohort.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMDataTreeShardThreePhaseCommitCohort.java @@ -8,6 +8,8 @@ package org.opendaylight.mdsal.dom.store.inmemory; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Preconditions; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -34,9 +36,9 @@ class InMemoryDOMDataTreeShardThreePhaseCommitCohort implements DOMStoreThreePha InMemoryDOMDataTreeShardThreePhaseCommitCohort(final DataTree dataTree, final DataTreeModification modification, final InMemoryDOMDataTreeShardChangePublisher changePublisher) { - this.dataTree = Preconditions.checkNotNull(dataTree); - this.modification = Preconditions.checkNotNull(modification); - this.changePublisher = Preconditions.checkNotNull(changePublisher); + this.dataTree = requireNonNull(dataTree); + this.modification = requireNonNull(modification); + this.changePublisher = requireNonNull(changePublisher); } @SuppressWarnings("checkstyle:IllegalCatch") diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMStoreThreePhaseCommitCohort.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMStoreThreePhaseCommitCohort.java index 6f16abb33d..d41981665c 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMStoreThreePhaseCommitCohort.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryDOMStoreThreePhaseCommitCohort.java @@ -9,8 +9,8 @@ package org.opendaylight.mdsal.dom.store.inmemory; 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.Futures; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.mdsal.common.api.OptimisticLockFailedException; @@ -39,9 +39,9 @@ class InMemoryDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommit final SnapshotBackedWriteTransaction writeTransaction, final DataTreeModification modification, final Exception operationError) { - this.transaction = Preconditions.checkNotNull(writeTransaction); - this.modification = Preconditions.checkNotNull(modification); - this.store = Preconditions.checkNotNull(store); + this.transaction = requireNonNull(writeTransaction); + this.modification = requireNonNull(modification); + this.store = requireNonNull(store); this.operationError = operationError; } diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryShardDataModificationCursor.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryShardDataModificationCursor.java index 179e4f8914..483cb34681 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryShardDataModificationCursor.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryShardDataModificationCursor.java @@ -8,7 +8,8 @@ package org.opendaylight.mdsal.dom.store.inmemory; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import org.opendaylight.mdsal.dom.spi.shard.AbstractDataModificationCursor; import org.opendaylight.mdsal.dom.spi.shard.WriteCursorStrategy; @@ -19,7 +20,7 @@ class InMemoryShardDataModificationCursor extends AbstractDataModificationCursor InMemoryShardDataModificationCursor(final ShardDataModification root, final InmemoryDOMDataTreeShardWriteTransaction parent) { super(root); - this.parent = Preconditions.checkNotNull(parent); + this.parent = requireNonNull(parent); } @Override diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryShardDataModificationFactory.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryShardDataModificationFactory.java index c772ee90ed..4a02a01b3f 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryShardDataModificationFactory.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InMemoryShardDataModificationFactory.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.dom.store.inmemory; +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.mdsal.dom.api.DOMDataTreeIdentifier; @@ -27,7 +28,7 @@ final class InMemoryShardDataModificationFactory { final DOMDataTreeIdentifier root, final Map children, final Map childShards) { - this.root = Preconditions.checkNotNull(root); + this.root = requireNonNull(root); this.children = ImmutableMap.copyOf(children); this.childShards = ImmutableMap.copyOf(childShards); } diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InmemoryDOMDataTreeShardWriteTransaction.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InmemoryDOMDataTreeShardWriteTransaction.java index 8b3eddaaac..3472d9c69f 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InmemoryDOMDataTreeShardWriteTransaction.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/InmemoryDOMDataTreeShardWriteTransaction.java @@ -8,6 +8,8 @@ package org.opendaylight.mdsal.dom.store.inmemory; +import static java.util.Objects.requireNonNull; + import com.google.common.base.Preconditions; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; @@ -101,9 +103,9 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT final InMemoryDOMDataTreeShardChangePublisher changePublisher, final ListeningExecutorService executor) { this.producer = producer; - this.modification = Preconditions.checkNotNull(root); - this.rootShardDataTree = Preconditions.checkNotNull(rootShardDataTree); - this.changePublisher = Preconditions.checkNotNull(changePublisher); + this.modification = requireNonNull(root); + this.rootShardDataTree = requireNonNull(rootShardDataTree); + this.changePublisher = requireNonNull(changePublisher); this.identifier = "INMEMORY-SHARD-TX-" + COUNTER.getAndIncrement(); LOG.debug("Shard transaction{} created", identifier); this.executor = executor; @@ -155,7 +157,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT } void cursorClosed() { - Preconditions.checkNotNull(cursor); + requireNonNull(cursor); modification.closeCursor(); cursor = null; } @@ -168,7 +170,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT public void ready() { Preconditions.checkState(!finished, "Attempting to ready an already finished transaction."); Preconditions.checkState(cursor == null, "Attempting to ready a transaction that has an open cursor."); - Preconditions.checkNotNull(modification, "Attempting to ready an empty transaction."); + requireNonNull(modification, "Attempting to ready an empty transaction."); LOG.debug("Readying open transaction on shard {}", modification.getPrefix()); rootModification = modification.seal(); @@ -187,7 +189,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT public ListenableFuture submit() { LOG.debug("Submitting open transaction on shard {}", modification.getPrefix()); - Preconditions.checkNotNull(cohorts); + requireNonNull(cohorts); Preconditions.checkState(!cohorts.isEmpty(), "Transaction was not readied yet."); return executor.submit(new ShardSubmitCoordinationTask(modification.getPrefix(), cohorts, this)); @@ -212,7 +214,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT } DataTreeModification getRootModification() { - Preconditions.checkNotNull(rootModification, "Transaction wasn't sealed yet"); + requireNonNull(rootModification, "Transaction wasn't sealed yet"); return rootModification; } diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCanCommitCoordinationTask.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCanCommitCoordinationTask.java index b46481f73e..633876492e 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCanCommitCoordinationTask.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCanCommitCoordinationTask.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.dom.store.inmemory; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.util.concurrent.ListenableFuture; import java.util.Collection; import java.util.concurrent.Callable; @@ -33,8 +34,8 @@ public class ShardCanCommitCoordinationTask implements Callable { public ShardCanCommitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix, final Collection cohorts) { - this.rootShardPrefix = Preconditions.checkNotNull(rootShardPrefix); - this.cohorts = Preconditions.checkNotNull(cohorts); + this.rootShardPrefix = requireNonNull(rootShardPrefix); + this.cohorts = requireNonNull(cohorts); } @Override diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCommitCoordinationTask.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCommitCoordinationTask.java index a6adbb675f..9480bbbd78 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCommitCoordinationTask.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCommitCoordinationTask.java @@ -8,8 +8,9 @@ package org.opendaylight.mdsal.dom.store.inmemory; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import com.google.common.util.concurrent.ListenableFuture; import java.util.Collection; import java.util.concurrent.Callable; @@ -35,9 +36,9 @@ public class ShardCommitCoordinationTask implements Callable { public ShardCommitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix, final Collection cohorts, final InmemoryDOMDataTreeShardWriteTransaction transaction) { - this.rootShardPrefix = Preconditions.checkNotNull(rootShardPrefix); - this.cohorts = Preconditions.checkNotNull(cohorts); - this.transaction = Preconditions.checkNotNull(transaction); + this.rootShardPrefix = requireNonNull(rootShardPrefix); + this.cohorts = requireNonNull(cohorts); + this.transaction = requireNonNull(transaction); } @Override diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardDataModification.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardDataModification.java index 5999da0a4c..c922ab2ae5 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardDataModification.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardDataModification.java @@ -8,7 +8,8 @@ package org.opendaylight.mdsal.dom.store.inmemory; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.ImmutableMap; import java.util.Map; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; @@ -30,7 +31,7 @@ public final class ShardDataModification extends WriteableNodeWithSubshard { final Map subshards, final Map childShards) { super(subshards); - this.rootContext = Preconditions.checkNotNull(boundary); + this.rootContext = requireNonNull(boundary); this.childShards = ImmutableMap.copyOf(childShards); } diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardDataModificationFactoryBuilder.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardDataModificationFactoryBuilder.java index e2f9caebed..ff7c9724d9 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardDataModificationFactoryBuilder.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardDataModificationFactoryBuilder.java @@ -8,7 +8,8 @@ package org.opendaylight.mdsal.dom.store.inmemory; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -26,7 +27,7 @@ public abstract class ShardDataModificationFactoryBuilder extends Modificatio protected final Map childShards = new HashMap<>(); public ShardDataModificationFactoryBuilder(final DOMDataTreeIdentifier root) { - this.root = Preconditions.checkNotNull(root); + this.root = requireNonNull(root); } public void addSubshard(final ForeignShardModificationContext value) { diff --git a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardRootModificationContext.java b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardRootModificationContext.java index 11f03d993d..f6cc727eb4 100644 --- a/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardRootModificationContext.java +++ b/dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardRootModificationContext.java @@ -8,7 +8,8 @@ package org.opendaylight.mdsal.dom.store.inmemory; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -28,8 +29,8 @@ class ShardRootModificationContext implements Identifiable { public ShardSubmitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix, final Collection cohorts, final InmemoryDOMDataTreeShardWriteTransaction transaction) { - this.rootShardPrefix = Preconditions.checkNotNull(rootShardPrefix); + this.rootShardPrefix = requireNonNull(rootShardPrefix); this.transaction = transaction; canCommitCoordinationTask = new ShardCanCommitCoordinationTask(rootShardPrefix, cohorts); diff --git a/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingEntityOwnershipCandidateRegistration.java b/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingEntityOwnershipCandidateRegistration.java index 871a8616c5..319cc63cef 100644 --- a/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingEntityOwnershipCandidateRegistration.java +++ b/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingEntityOwnershipCandidateRegistration.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.eos.binding.dom.adapter; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import org.opendaylight.mdsal.eos.binding.api.Entity; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipCandidateRegistration; import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration; @@ -26,7 +27,7 @@ class BindingEntityOwnershipCandidateRegistration extends AbstractObjectRegistra BindingEntityOwnershipCandidateRegistration(DOMEntityOwnershipCandidateRegistration domRegistration, Entity entity) { super(entity); - this.domRegistration = Preconditions.checkNotNull(domRegistration); + this.domRegistration = requireNonNull(domRegistration); } @Override diff --git a/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingEntityOwnershipListenerRegistration.java b/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingEntityOwnershipListenerRegistration.java index 800fc7ec60..6d83f19f95 100644 --- a/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingEntityOwnershipListenerRegistration.java +++ b/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingEntityOwnershipListenerRegistration.java @@ -7,7 +7,8 @@ */ package org.opendaylight.mdsal.eos.binding.dom.adapter; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListener; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration; import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration; @@ -27,8 +28,8 @@ class BindingEntityOwnershipListenerRegistration extends AbstractObjectRegistrat BindingEntityOwnershipListenerRegistration(String entityType, EntityOwnershipListener listener, DOMEntityOwnershipListenerRegistration domRegistration) { super(listener); - this.entityType = Preconditions.checkNotNull(entityType); - this.domRegistration = Preconditions.checkNotNull(domRegistration); + this.entityType = requireNonNull(entityType); + this.domRegistration = requireNonNull(domRegistration); } @Override diff --git a/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/Entity.java b/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/Entity.java index 3b1cee14d7..5fc2ff2e03 100644 --- a/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/Entity.java +++ b/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/Entity.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.eos.binding.api; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.eos.common.api.GenericEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.EntityKey; @@ -42,6 +43,6 @@ public class Entity extends GenericEntity> { public Entity(final @NonNull String type, final @NonNull String entityName) { super(type, InstanceIdentifier.builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang .mdsal.core.general.entity.rev150930.Entity.class, - new EntityKey(Preconditions.checkNotNull(entityName, "entityName should not be null"))).build()); + new EntityKey(requireNonNull(entityName, "entityName should not be null"))).build()); } } diff --git a/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntity.java b/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntity.java index feac6315b1..ad8da3740a 100644 --- a/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntity.java +++ b/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntity.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.eos.dom.api; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.eos.common.api.GenericEntity; import org.opendaylight.yangtools.yang.common.QName; @@ -45,6 +46,6 @@ public class DOMEntity extends GenericEntity { */ public DOMEntity(final @NonNull String type, final @NonNull String entityName) { super(type, YangInstanceIdentifier.builder().node(ENTITY).nodeWithKey(ENTITY, ENTITY_NAME, - Preconditions.checkNotNull(entityName, "entityName should not be null")).build()); + requireNonNull(entityName, "entityName should not be null")).build()); } } diff --git a/entityownership/mdsal-eos-dom-simple/src/main/java/org/opendaylight/mdsal/eos/dom/simple/SimpleDOMEntityOwnershipService.java b/entityownership/mdsal-eos-dom-simple/src/main/java/org/opendaylight/mdsal/eos/dom/simple/SimpleDOMEntityOwnershipService.java index 8fc0334bb6..8a9ce266c3 100644 --- a/entityownership/mdsal-eos-dom-simple/src/main/java/org/opendaylight/mdsal/eos/dom/simple/SimpleDOMEntityOwnershipService.java +++ b/entityownership/mdsal-eos-dom-simple/src/main/java/org/opendaylight/mdsal/eos/dom/simple/SimpleDOMEntityOwnershipService.java @@ -7,13 +7,13 @@ */ package org.opendaylight.mdsal.eos.dom.simple; +import static java.util.Objects.requireNonNull; import static org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState.LOCAL_OWNERSHIP_GRANTED; import static org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NO_OWNER; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.HashBasedTable; import com.google.common.collect.ImmutableList; @@ -58,7 +58,7 @@ public final class SimpleDOMEntityOwnershipService implements DOMEntityOwnership @VisibleForTesting SimpleDOMEntityOwnershipService(final UUID uuid) { - this.uuid = Preconditions.checkNotNull(uuid); + this.uuid = requireNonNull(uuid); } public SimpleDOMEntityOwnershipService() { @@ -187,7 +187,7 @@ public final class SimpleDOMEntityOwnershipService implements DOMEntityOwnership ListenerRegistration(final String entityType, final DOMEntityOwnershipListener listener) { super(listener); - this.entityType = Preconditions.checkNotNull(entityType); + this.entityType = requireNonNull(entityType); } @Override diff --git a/model/ietf/ietf-type-util/src/test/java/org/opendaylight/mdsal/model/ietf/util/IpClass.java b/model/ietf/ietf-type-util/src/test/java/org/opendaylight/mdsal/model/ietf/util/IpClass.java index 012fb3231f..21322b375b 100644 --- a/model/ietf/ietf-type-util/src/test/java/org/opendaylight/mdsal/model/ietf/util/IpClass.java +++ b/model/ietf/ietf-type-util/src/test/java/org/opendaylight/mdsal/model/ietf/util/IpClass.java @@ -8,13 +8,13 @@ package org.opendaylight.mdsal.model.ietf.util; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; public class IpClass { private final String _value; public IpClass(final String value) { - this._value = Preconditions.checkNotNull(value); + this._value = requireNonNull(value); } public IpClass(final IpClass template) { -- 2.36.6