Migrate yang-model-util annotations 36/77236/11
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 23 Oct 2018 23:44:52 +0000 (01:44 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 24 Oct 2018 10:05:56 +0000 (12:05 +0200)
This moves over to use JDT annotations instead of JSR305.

Change-Id: I98d70e53a951d41c3533272da016fb8afa223a49
JIRA: YANGTOOLS-907
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
39 files changed:
yang/yang-model-util/pom.xml
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaRepository.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/SchemaSourceTransformer.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/FilteringSchemaContextProxy.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtil.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SchemaNodeUtils.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractLengthRestrictedDerivedType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRangeRestrictedBaseType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRangeRestrictedDerivedType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRangeRestrictedType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRestrictedTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseBinaryType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseBooleanType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseEmptyType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseInstanceIdentifierType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseInt16Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseInt32Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseInt64Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseInt8Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseStringType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseTypes.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseUint16Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseUint32Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseUint64Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseUint8Type.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BitsTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/CompatUtils.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/ConcreteTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/ConcreteTypes.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/DerivedTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/DerivedTypes.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/EnumerationTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/IdentityrefTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/InstanceIdentifierTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/LeafrefTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RestrictedTypes.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/TypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/UnionTypeBuilder.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/repo/util/SchemaSourceTransformerTest.java

index 029c358dff3600ef22817658a697449a715af92c..1f33a616d7a00cfae56b313438750c2e9fff7962 100644 (file)
 
     <build>
         <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <configuration>
-                    <instructions>
-                        <Import-Package>!javax.annotation,*</Import-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-checkstyle-plugin</artifactId>
index e02ac79b5b786f803216e5925d673c791932dda6..92adec75163e9681d6806d9c4ae94afd5148410e 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
-import javax.annotation.Nonnull;
 import javax.annotation.concurrent.GuardedBy;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
@@ -83,8 +82,8 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
     }
 
     @Override
-    public <T extends SchemaSourceRepresentation> ListenableFuture<T> getSchemaSource(
-            @Nonnull final SourceIdentifier id, @Nonnull final Class<T> representation) {
+    public <T extends SchemaSourceRepresentation> ListenableFuture<T> getSchemaSource(final SourceIdentifier id,
+            final Class<T> representation) {
         final ArrayList<AbstractSchemaSourceRegistration<?>> sortedSchemaSourceRegistrations;
 
         synchronized (this) {
@@ -119,7 +118,7 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
 
             @Override
             @SuppressWarnings("checkstyle:parameterName")
-            public void onFailure(@Nonnull final Throwable t) {
+            public void onFailure(final Throwable t) {
                 LOG.trace("Skipping notification for encountered source {}, fetching source failed", id, t);
             }
         }, MoreExecutors.directExecutor());
index 5053c1cf85438b1fb5c66d447ebdd71671fcf690..28539bbfafad36b722c54cc01ab933939b406efc 100644 (file)
@@ -15,7 +15,6 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.HashMap;
 import java.util.Map;
-import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
@@ -32,7 +31,7 @@ public class SchemaSourceTransformer<S extends SchemaSourceRepresentation, D ext
     public interface Transformation<S extends SchemaSourceRepresentation, D extends SchemaSourceRepresentation>
             extends AsyncFunction<S, D> {
         @Override
-        ListenableFuture<D> apply(@Nonnull S input) throws Exception;
+        ListenableFuture<D> apply(S input) throws Exception;
     }
 
     private final Map<PotentialSchemaSource<?>, RefcountedRegistration> availableSources = new HashMap<>();
index 01c38c515e7bce3714b76496e93316389684159b..f9251b00f4683e43fa774ca9f1ed2e2e2ba2e049 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.model.util;
 
 import com.google.common.base.Preconditions;
index 2d2240c38296cf2ee1783688f64358351b66e5e2..7b4140392bdc287c6d3cd3b173b4d7eae9c7aff4 100644 (file)
@@ -7,9 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Iterables;
 import java.util.HashSet;
@@ -19,8 +22,8 @@ import java.util.List;
 import java.util.Optional;
 import java.util.Set;
 import java.util.regex.Pattern;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ActionNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
@@ -51,11 +54,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * The Schema Context Util contains support methods for searching through Schema
- * Context modules for specified schema nodes via Schema Path or Revision Aware
- * XPath. The Schema Context Util is designed as mixin, so it is not
+ * The Schema Context Util contains support methods for searching through Schema Context modules for specified schema
+ * nodes via Schema Path or Revision Aware XPath. The Schema Context Util is designed as mixin, so it is not
  * instantiable.
- *
  */
 public final class SchemaContextUtil {
     private static final Logger LOG = LoggerFactory.getLogger(SchemaContextUtil.class);
@@ -83,8 +84,8 @@ public final class SchemaContextUtil {
      * @throws IllegalArgumentException if context or schemaPath is not correct.
      */
     public static SchemaNode findDataSchemaNode(final SchemaContext context, final SchemaPath schemaPath) {
-        Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
-        Preconditions.checkArgument(schemaPath != null, "Schema Path reference cannot be NULL");
+        checkArgument(context != null, "Schema Context reference cannot be NULL");
+        checkArgument(schemaPath != null, "Schema Path reference cannot be NULL");
 
         final Iterable<QName> prefixedPath = schemaPath.getPathFromRoot();
         if (prefixedPath == null) {
@@ -138,14 +139,13 @@ public final class SchemaContextUtil {
     //        that feels like an overkill.
     public static SchemaNode findDataSchemaNode(final SchemaContext context, final Module module,
             final RevisionAwareXPath nonCondXPath) {
-        Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
-        Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
-        Preconditions.checkArgument(nonCondXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
+        checkArgument(context != null, "Schema Context reference cannot be NULL");
+        checkArgument(module != null, "Module reference cannot be NULL");
+        checkArgument(nonCondXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
 
         final String strXPath = nonCondXPath.toString();
         if (strXPath != null) {
-            Preconditions.checkArgument(strXPath.indexOf('[') == -1,
-                    "Revision Aware XPath may not contain a condition");
+            checkArgument(strXPath.indexOf('[') == -1, "Revision Aware XPath may not contain a condition");
             if (nonCondXPath.isAbsolute()) {
                 final List<QName> path = xpathToQNamePath(context, module, strXPath);
 
@@ -209,13 +209,12 @@ public final class SchemaContextUtil {
     //        that feels like an overkill.
     public static SchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context, final Module module,
             final SchemaNode actualSchemaNode, final RevisionAwareXPath relativeXPath) {
-        Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
-        Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
-        Preconditions.checkArgument(actualSchemaNode != null, "Actual Schema Node reference cannot be NULL");
-        Preconditions.checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
-        Preconditions.checkState(!relativeXPath.isAbsolute(),
-                "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
-                        + "for non relative Revision Aware XPath use findDataSchemaNode method");
+        checkArgument(context != null, "Schema Context reference cannot be NULL");
+        checkArgument(module != null, "Module reference cannot be NULL");
+        checkArgument(actualSchemaNode != null, "Actual Schema Node reference cannot be NULL");
+        checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
+        checkState(!relativeXPath.isAbsolute(), "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
+                + "for non relative Revision Aware XPath use findDataSchemaNode method");
 
         final SchemaPath actualNodePath = actualSchemaNode.getPath();
         if (actualNodePath != null) {
@@ -244,13 +243,13 @@ public final class SchemaContextUtil {
      *         return <code>null</code>
      */
     public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
-        Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL!");
-        Preconditions.checkArgument(schemaNode != null, "Schema Node cannot be NULL!");
-        Preconditions.checkState(schemaNode.getPath() != null, "Schema Path for Schema Node is not "
-                + "set properly (Schema Path is NULL)");
+        checkArgument(context != null, "Schema Context reference cannot be NULL!");
+        checkArgument(schemaNode != null, "Schema Node cannot be NULL!");
+        checkState(schemaNode.getPath() != null, "Schema Path for Schema Node is not set properly (Schema Path is "
+                + "NULL)");
 
         final QName qname = schemaNode.getPath().getLastComponent();
-        Preconditions.checkState(qname != null, "Schema Path contains invalid state of path parts. "
+        checkState(qname != null, "Schema Path contains invalid state of path parts. "
                 + "The Schema Path MUST contain at least ONE QName  which defines namespace and Local name of path.");
         return context.findModule(qname.getModule()).orElse(null);
     }
@@ -276,11 +275,10 @@ public final class SchemaContextUtil {
      * @return Notification schema or null, if notification is not present in schema context.
      */
     @Beta
-    @Nullable
-    public static NotificationDefinition getNotificationSchema(@Nonnull final SchemaContext schema,
-            @Nonnull final SchemaPath path) {
-        Preconditions.checkNotNull(schema, "Schema context must not be null.");
-        Preconditions.checkNotNull(path, "Schema path must not be null.");
+    public static @Nullable NotificationDefinition getNotificationSchema(final @NonNull SchemaContext schema,
+            final @NonNull SchemaPath path) {
+        requireNonNull(schema, "Schema context must not be null.");
+        requireNonNull(path, "Schema path must not be null.");
         for (final NotificationDefinition potential : schema.getNotifications()) {
             if (path.equals(potential.getPath())) {
                 return potential;
@@ -297,15 +295,14 @@ public final class SchemaContextUtil {
      * @return Notification schema or null, if notification is not present in schema context.
      */
     @Beta
-    @Nullable
-    public static ContainerSchemaNode getRpcDataSchema(@Nonnull final SchemaContext schema,
-            @Nonnull final SchemaPath path) {
-        Preconditions.checkNotNull(schema, "Schema context must not be null.");
-        Preconditions.checkNotNull(path, "Schema path must not be null.");
+    public static @Nullable ContainerSchemaNode getRpcDataSchema(final @NonNull SchemaContext schema,
+            final @NonNull SchemaPath path) {
+        requireNonNull(schema, "Schema context must not be null.");
+        requireNonNull(path, "Schema path must not be null.");
         final Iterator<QName> it = path.getPathFromRoot().iterator();
-        Preconditions.checkArgument(it.hasNext(), "Rpc must have QName.");
+        checkArgument(it.hasNext(), "Rpc must have QName.");
         final QName rpcName = it.next();
-        Preconditions.checkArgument(it.hasNext(), "input or output must be part of path.");
+        checkArgument(it.hasNext(), "input or output must be part of path.");
         final QName inOrOut = it.next();
         for (final RpcDefinition potential : schema.getOperations()) {
             if (rpcName.equals(potential.getQName())) {
@@ -340,9 +337,8 @@ public final class SchemaContextUtil {
     }
 
     private static SchemaNode findNodeInModule(final Module module, final Iterable<QName> path) {
-
-        Preconditions.checkArgument(module != null, "Parent reference cannot be NULL");
-        Preconditions.checkArgument(path != null, "Path reference cannot be NULL");
+        checkArgument(module != null, "Parent reference cannot be NULL");
+        checkArgument(path != null, "Path reference cannot be NULL");
 
         if (!path.iterator().hasNext()) {
             LOG.debug("No node matching {} found in node {}", path, module);
@@ -390,9 +386,8 @@ public final class SchemaContextUtil {
     }
 
     private static SchemaNode findNodeIn(final SchemaNode parent, final Iterable<QName> path) {
-
-        Preconditions.checkArgument(parent != null, "Parent reference cannot be NULL");
-        Preconditions.checkArgument(path != null, "Path reference cannot be NULL");
+        checkArgument(parent != null, "Parent reference cannot be NULL");
+        checkArgument(path != null, "Path reference cannot be NULL");
 
         if (!path.iterator().hasNext()) {
             LOG.debug("No node matching {} found in node {}", path, parent);
@@ -549,10 +544,10 @@ public final class SchemaContextUtil {
      */
     private static List<QName> xpathToQNamePath(final SchemaContext context, final Module parentModule,
             final String xpath) {
-        // FIXME: 2.0.0: this should throw NPE, not IAE
-        Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
-        Preconditions.checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
-        Preconditions.checkArgument(xpath != null, "XPath string reference cannot be NULL");
+        // FIXME: 3.0.0: this should throw NPE, not IAE
+        checkArgument(context != null, "Schema Context reference cannot be NULL");
+        checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
+        checkArgument(xpath != null, "XPath string reference cannot be NULL");
 
         final List<QName> path = new LinkedList<>();
         for (final String pathComponent : SLASH_SPLITTER.split(xpath)) {
@@ -574,30 +569,26 @@ public final class SchemaContextUtil {
      * If Schema Context, Parent Module or Prefixed Path Part refers to
      * <code>null</code> the method will throw IllegalArgumentException
      *
-     * @param context
-     *            Schema Context
-     * @param parentModule
-     *            Parent Module
-     * @param prefixedPathPart
-     *            Prefixed Path Part string
+     * @param context Schema Context
+     * @param parentModule Parent Module
+     * @param prefixedPathPart Prefixed Path Part string
      * @return QName from prefixed Path Part String.
      * @throws IllegalArgumentException if any arguments are null
      */
     private static QName stringPathPartToQName(final SchemaContext context, final Module parentModule,
             final String prefixedPathPart) {
-        // FIXME: 2.0.0: this should throw NPE, not IAE
-        Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
-        Preconditions.checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
-        Preconditions.checkArgument(prefixedPathPart != null, "Prefixed Path Part cannot be NULL!");
+        // FIXME: 3.0.0: this should throw NPE, not IAE
+        checkArgument(context != null, "Schema Context reference cannot be NULL");
+        checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
+        checkArgument(prefixedPathPart != null, "Prefixed Path Part cannot be NULL!");
 
         if (prefixedPathPart.indexOf(':') != -1) {
             final Iterator<String> prefixedName = COLON_SPLITTER.split(prefixedPathPart).iterator();
             final String modulePrefix = prefixedName.next();
 
             final Module module = resolveModuleForPrefix(context, parentModule, modulePrefix);
-            Preconditions.checkArgument(module != null,
-                    "Failed to resolve xpath: no module found for prefix %s in module %s", modulePrefix,
-                    parentModule.getName());
+            checkArgument(module != null, "Failed to resolve xpath: no module found for prefix %s in module %s",
+                    modulePrefix, parentModule.getName());
 
             return QName.create(module.getQNameModule(), prefixedName.next());
         }
@@ -606,34 +597,26 @@ public final class SchemaContextUtil {
     }
 
     /**
-     * Method will attempt to resolve and provide Module reference for specified
-     * module prefix. Each Yang module could contains multiple imports which
-     * MUST be associated with corresponding module prefix. The method simply
-     * looks into module imports and returns the module that is bounded with
-     * specified prefix. If the prefix is not present in module or the prefixed
-     * module is not present in specified Schema Context, the method will return
-     * <code>null</code>. <br>
-     * If String prefix is the same as prefix of the specified Module the
-     * reference to this module is returned. <br>
-     * If Schema Context, Module or Prefix are referring to <code>null</code>
-     * the method will return IllegalArgumentException
+     * Method will attempt to resolve and provide Module reference for specified module prefix. Each Yang module could
+     * contains multiple imports which MUST be associated with corresponding module prefix. The method simply looks into
+     * module imports and returns the module that is bounded with specified prefix. If the prefix is not present
+     * in module or the prefixed module is not present in specified Schema Context, the method will return {@code null}.
+     * <br>
+     * If String prefix is the same as prefix of the specified Module the reference to this module is returned.<br>
+     * If Schema Context, Module or Prefix are referring to {@code null} the method will throw IllegalArgumentException.
      *
-     * @param context
-     *            Schema Context
-     * @param module
-     *            Yang Module
-     * @param prefix
-     *            Module Prefix
-     * @return Module for given prefix in specified Schema Context if is
-     *         present, otherwise returns <code>null</code>
+     * @param context Schema Context
+     * @param module Yang Module
+     * @param prefix Module Prefix
+     * @return Module for given prefix in specified Schema Context if is present, otherwise returns <code>null</code>
      * @throws IllegalArgumentException if any arguments are null
      */
     private static Module resolveModuleForPrefix(final SchemaContext context, final Module module,
             final String prefix) {
-        // FIXME: 2.0.0: this should throw NPE, not IAE
-        Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
-        Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
-        Preconditions.checkArgument(prefix != null, "Prefix string cannot be NULL");
+        // FIXME: 3.0.0: this should throw NPE, not IAE
+        checkArgument(context != null, "Schema Context reference cannot be NULL");
+        checkArgument(module != null, "Module reference cannot be NULL");
+        checkArgument(prefix != null, "Prefix string cannot be NULL");
 
         if (prefix.equals(module.getPrefix())) {
             return module;
@@ -664,14 +647,13 @@ public final class SchemaContextUtil {
      */
     private static Iterable<QName> resolveRelativeXPath(final SchemaContext context, final Module module,
             final RevisionAwareXPath relativeXPath, final SchemaNode actualSchemaNode) {
-        // FIXME: 2.0.0: this should throw NPE, not IAE
-        Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
-        Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
-        Preconditions.checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
-        Preconditions.checkState(!relativeXPath.isAbsolute(),
-                "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
-                        + "for non relative Revision Aware XPath use findDataSchemaNode method");
-        Preconditions.checkState(actualSchemaNode.getPath() != null,
+        // FIXME: 3.0.0: this should throw NPE, not IAE
+        checkArgument(context != null, "Schema Context reference cannot be NULL");
+        checkArgument(module != null, "Module reference cannot be NULL");
+        checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
+        checkState(!relativeXPath.isAbsolute(), "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
+                + "for non relative Revision Aware XPath use findDataSchemaNode method");
+        checkState(actualSchemaNode.getPath() != null,
                 "Schema Path reference for Leafref cannot be NULL");
 
         final Iterable<String> xpaths = SLASH_SPLITTER.split(relativeXPath.toString());
@@ -770,7 +752,7 @@ public final class SchemaContextUtil {
         }
 
         final Optional<Module> parentModule = schemaContext.findModule(qname.getModule());
-        Preconditions.checkArgument(parentModule.isPresent(), "Failed to find parent module for %s", qname);
+        checkArgument(parentModule.isPresent(), "Failed to find parent module for %s", qname);
 
         final DataSchemaNode dataSchemaNode = (DataSchemaNode) SchemaContextUtil.findDataSchemaNode(schemaContext,
             parentModule.get(), strippedPathStatement);
@@ -784,8 +766,8 @@ public final class SchemaContextUtil {
 
     private static Module findParentModuleOfReferencingType(final SchemaContext schemaContext,
             final SchemaNode schemaNode) {
-        Preconditions.checkArgument(schemaContext != null, "Schema Context reference cannot be NULL!");
-        Preconditions.checkArgument(schemaNode instanceof TypedDataSchemaNode, "Unsupported node %s", schemaNode);
+        checkArgument(schemaContext != null, "Schema Context reference cannot be NULL!");
+        checkArgument(schemaNode instanceof TypedDataSchemaNode, "Unsupported node %s", schemaNode);
 
         TypeDefinition<?> nodeType = ((TypedDataSchemaNode) schemaNode).getType();
         if (nodeType.getBaseType() != null) {
index 64ae8da3d77b14b1bfb5c8f26f1774774d76acbc..2b21b23c115e066492234379857fedb71bfa8c87 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.yangtools.yang.model.util;
 import static java.util.Objects.requireNonNull;
 
 import java.util.Optional;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
@@ -19,7 +19,6 @@ import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
 public final class SchemaNodeUtils {
-
     private SchemaNodeUtils() {
         throw new UnsupportedOperationException("Utility class");
     }
@@ -50,11 +49,10 @@ public final class SchemaNodeUtils {
      * @param qname input or output QName with namespace same as RPC
      * @return input or output schema. Returns null if RPC does not have input/output specified.
      */
-    @Nullable public static ContainerSchemaNode getRpcDataSchema(@Nonnull final RpcDefinition rpc,
-            @Nonnull final QName qname) {
+    public static @Nullable ContainerSchemaNode getRpcDataSchema(final @NonNull RpcDefinition rpc,
+            final @NonNull QName qname) {
         requireNonNull(rpc, "Rpc Schema must not be null");
-        requireNonNull(qname, "QName must not be null");
-        switch (qname.getLocalName()) {
+        switch (requireNonNull(qname, "QName must not be null").getLocalName()) {
             case "input":
                 return rpc.getInput();
             case "output":
index e263629f68ae361962bf14781b0265871e7a580d..27cfaf785fc475a4e7afd1a114eb2ce458be0e70 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.model.util.type;
 
 import java.util.Collection;
 import java.util.Optional;
-import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
@@ -25,7 +24,6 @@ abstract class AbstractLengthRestrictedDerivedType<T extends LengthRestrictedTyp
         super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
     }
 
-    @Nonnull
     @Override
     public final Optional<LengthConstraint> getLengthConstraint() {
         return baseType().getLengthConstraint();
index 868a0f0d989764ffe6fe89a362f0cc7f19e5ce0f..4d767e6473f2443df74f7bd11de03163f7ee84a7 100644 (file)
@@ -13,7 +13,6 @@ import com.google.common.collect.ImmutableRangeSet;
 import com.google.common.collect.Range;
 import java.util.List;
 import java.util.Optional;
-import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -61,7 +60,6 @@ abstract class AbstractRangeRestrictedBaseType<T extends RangeRestrictedTypeDefi
     }
 
     @Override
-    @Nonnull
     public final Optional<RangeConstraint<N>> getRangeConstraint() {
         return Optional.of(rangeConstraint);
     }
index f0cb11bca30779717014e1ed97a9457f3fc0684f..86674ebd006368b76043313574c811aa436bd0a5 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.model.util.type;
 
 import java.util.Collection;
 import java.util.Optional;
-import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
@@ -26,7 +25,6 @@ abstract class AbstractRangeRestrictedDerivedType<T extends RangeRestrictedTypeD
         super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
     }
 
-    @Nonnull
     @Override
     public final Optional<RangeConstraint<N>> getRangeConstraint() {
         return baseType().getRangeConstraint();
index fc88af6a8fb76cd6d20e627dae103d7fb9ef926b..dcd460951aa200de2419318a5c53c0e259019575 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.model.util.type;
 
 import java.util.Collection;
 import java.util.Optional;
-import javax.annotation.Nonnull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
@@ -28,7 +27,6 @@ abstract class AbstractRangeRestrictedType<T extends RangeRestrictedTypeDefiniti
     }
 
     @Override
-    @Nonnull
     public final Optional<RangeConstraint<N>> getRangeConstraint() {
         return Optional.ofNullable(rangeConstraint);
     }
index 32148793e1e7ef5f37b2abbfc2538f1db06f67c1..cd172c8598967b2e7987da18a1c45c571ce9fb8b 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Verify.verifyNotNull;
+
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -18,7 +20,7 @@ abstract class AbstractRestrictedTypeBuilder<T extends TypeDefinition<T>> extend
     AbstractRestrictedTypeBuilder(final T baseType, final SchemaPath path) {
         super(baseType, path);
         if (baseType != null) {
-            Preconditions.checkArgument(baseType instanceof AbstractBaseType || baseType instanceof AbstractDerivedType,
+            checkArgument(baseType instanceof AbstractBaseType || baseType instanceof AbstractDerivedType,
                 "Restricted type has to be based on either a base or derived type, not %s", baseType);
         } else {
             touched = true;
@@ -33,10 +35,6 @@ abstract class AbstractRestrictedTypeBuilder<T extends TypeDefinition<T>> extend
 
     @Override
     public final T build() {
-        if (!touched) {
-            return getBaseType();
-        }
-
-        return buildType();
+        return touched ? buildType() : verifyNotNull(getBaseType());
     }
 }
index 51f2196706762d3b5b26278e732365ada6483af9..cf38120e7e79d3a4e20e340da4f1301ea96584dc 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseBinaryType extends AbstractLengthRestrictedBaseType<BinaryTypeDefinition>
         implements BinaryTypeDefinition {
-    static final BaseBinaryType INSTANCE = new BaseBinaryType();
+    static final @NonNull BaseBinaryType INSTANCE = new BaseBinaryType();
 
     private BaseBinaryType() {
         super(BaseTypes.BINARY_QNAME);
index 904fd7252b3186fa2ed6003b9ffe42267cd04d05..e3961dd2040fdc1594a0b869b41d2ee2d96f790f 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseBooleanType extends AbstractBaseType<BooleanTypeDefinition> implements BooleanTypeDefinition {
-    static final BaseBooleanType INSTANCE = new BaseBooleanType();
+    static final @NonNull BaseBooleanType INSTANCE = new BaseBooleanType();
 
     private BaseBooleanType() {
         super(BaseTypes.BOOLEAN_QNAME);
index 3727e98d1825f68aa0b5c8a8ada9ee8ae7ce70e9..12fe0ee47fa69a54cb734bc18d526de647f94e74 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseEmptyType extends AbstractBaseType<EmptyTypeDefinition> implements EmptyTypeDefinition {
-    static final BaseEmptyType INSTANCE = new BaseEmptyType();
+    static final @NonNull BaseEmptyType INSTANCE = new BaseEmptyType();
 
     private BaseEmptyType() {
         super(BaseTypes.EMPTY_QNAME);
index da7fabffb72d1d735d75ad3132ffea8bcfeb68a0..10c26002ec6edffd30b02c57b9799a24c2af7f9d 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseInstanceIdentifierType extends AbstractBaseType<InstanceIdentifierTypeDefinition>
         implements InstanceIdentifierTypeDefinition {
-    static final BaseInstanceIdentifierType INSTANCE = new BaseInstanceIdentifierType();
+    static final @NonNull BaseInstanceIdentifierType INSTANCE = new BaseInstanceIdentifierType();
 
     private BaseInstanceIdentifierType() {
         super(BaseTypes.INSTANCE_IDENTIFIER_QNAME);
index d4716f29859785f35dcd1743a459ac044a2145bc..af4d06a7d772a8a976da67399e0f07508050e6bb 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseInt16Type extends AbstractRangeRestrictedBaseType<Int16TypeDefinition, Short>
         implements Int16TypeDefinition {
-    static final BaseInt16Type INSTANCE = new BaseInt16Type();
+    static final @NonNull BaseInt16Type INSTANCE = new BaseInt16Type();
 
     private BaseInt16Type() {
         super(BaseTypes.INT16_QNAME, Short.MIN_VALUE, Short.MAX_VALUE);
index 25ba84a11e00e8dd85a85a48ac8a0ddb8b6bf2dc..08935902f680d151e4a3d6f6e7194a175b9ed485 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseInt32Type extends AbstractRangeRestrictedBaseType<Int32TypeDefinition, Integer>
         implements Int32TypeDefinition {
-    static final BaseInt32Type INSTANCE = new BaseInt32Type();
+    static final @NonNull BaseInt32Type INSTANCE = new BaseInt32Type();
 
     private BaseInt32Type() {
         super(BaseTypes.INT32_QNAME, Integer.MIN_VALUE, Integer.MAX_VALUE);
index 275b2db074d5a078e3b16c8c9f402c6a064b2a08..cf8c033516cb210abd9930df20ebe079d11da45f 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseInt64Type extends AbstractRangeRestrictedBaseType<Int64TypeDefinition, Long>
         implements Int64TypeDefinition {
-    static final BaseInt64Type INSTANCE = new BaseInt64Type();
+    static final @NonNull BaseInt64Type INSTANCE = new BaseInt64Type();
 
     private BaseInt64Type() {
         super(BaseTypes.INT64_QNAME, Long.MIN_VALUE, Long.MAX_VALUE);
index 7aec300e98147fc918905a19d492900149cd6e8d..bc11699ef49b15013822fca3067ce38aae511906 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseInt8Type extends AbstractRangeRestrictedBaseType<Int8TypeDefinition, Byte>
         implements Int8TypeDefinition {
-    static final BaseInt8Type INSTANCE = new BaseInt8Type();
+    static final @NonNull BaseInt8Type INSTANCE = new BaseInt8Type();
 
     private BaseInt8Type() {
         super(BaseTypes.INT8_QNAME, Byte.MIN_VALUE, Byte.MAX_VALUE);
index 6074fb651d07b354f6cf79b09cbd38a267fed8b4..1cb7cfad74fb09f66ddb99d77c673ae947bb50ef 100644 (file)
@@ -9,13 +9,14 @@ package org.opendaylight.yangtools.yang.model.util.type;
 
 import com.google.common.collect.ImmutableList;
 import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseStringType extends AbstractLengthRestrictedBaseType<StringTypeDefinition>
         implements StringTypeDefinition {
-    static final BaseStringType INSTANCE = new BaseStringType();
+    static final @NonNull BaseStringType INSTANCE = new BaseStringType();
 
     private BaseStringType() {
         super(BaseTypes.STRING_QNAME);
index cb3dc5227e0ebaef591ea50602c025b444cd77aa..6deaa150ea76ab1632cf2031baf32a44ceadf609 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.yangtools.yang.model.util.type;
 
 import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
@@ -59,39 +59,39 @@ public final class BaseTypes {
         throw new UnsupportedOperationException();
     }
 
-    public static BinaryTypeDefinition binaryType() {
+    public static @NonNull BinaryTypeDefinition binaryType() {
         return BaseBinaryType.INSTANCE;
     }
 
-    public static BitsTypeBuilder bitsTypeBuilder(final SchemaPath path) {
+    public static @NonNull BitsTypeBuilder bitsTypeBuilder(final SchemaPath path) {
         return new BitsTypeBuilder(path);
     }
 
-    public static BooleanTypeDefinition booleanType() {
+    public static @NonNull BooleanTypeDefinition booleanType() {
         return BaseBooleanType.INSTANCE;
     }
 
-    public static DecimalTypeBuilder decimalTypeBuilder(final SchemaPath path) {
+    public static @NonNull DecimalTypeBuilder decimalTypeBuilder(final SchemaPath path) {
         return new DecimalTypeBuilder(path);
     }
 
-    public static EmptyTypeDefinition emptyType() {
+    public static @NonNull EmptyTypeDefinition emptyType() {
         return BaseEmptyType.INSTANCE;
     }
 
-    public static EnumerationTypeBuilder enumerationTypeBuilder(final SchemaPath path) {
+    public static @NonNull EnumerationTypeBuilder enumerationTypeBuilder(final SchemaPath path) {
         return new EnumerationTypeBuilder(path);
     }
 
-    public static IdentityrefTypeBuilder identityrefTypeBuilder(final SchemaPath path) {
+    public static @NonNull IdentityrefTypeBuilder identityrefTypeBuilder(final SchemaPath path) {
         return new IdentityrefTypeBuilder(path);
     }
 
-    public static InstanceIdentifierTypeDefinition instanceIdentifierType() {
+    public static @NonNull InstanceIdentifierTypeDefinition instanceIdentifierType() {
         return BaseInstanceIdentifierType.INSTANCE;
     }
 
-    public static Int8TypeDefinition int8Type() {
+    public static @NonNull Int8TypeDefinition int8Type() {
         return BaseInt8Type.INSTANCE;
     }
 
@@ -105,7 +105,7 @@ public final class BaseTypes {
         return BaseInt8Type.INSTANCE.getPath().equals(type.getPath());
     }
 
-    public static Int16TypeDefinition int16Type() {
+    public static @NonNull Int16TypeDefinition int16Type() {
         return BaseInt16Type.INSTANCE;
     }
 
@@ -119,7 +119,7 @@ public final class BaseTypes {
         return BaseInt16Type.INSTANCE.getPath().equals(type.getPath());
     }
 
-    public static Int32TypeDefinition int32Type() {
+    public static @NonNull Int32TypeDefinition int32Type() {
         return BaseInt32Type.INSTANCE;
     }
 
@@ -134,7 +134,7 @@ public final class BaseTypes {
         return BaseInt32Type.INSTANCE.getPath().equals(type.getPath());
     }
 
-    public static Int64TypeDefinition int64Type() {
+    public static @NonNull Int64TypeDefinition int64Type() {
         return BaseInt64Type.INSTANCE;
     }
 
@@ -148,11 +148,11 @@ public final class BaseTypes {
         return BaseInt64Type.INSTANCE.getPath().equals(type.getPath());
     }
 
-    public static LeafrefTypeBuilder leafrefTypeBuilder(final SchemaPath path) {
+    public static @NonNull LeafrefTypeBuilder leafrefTypeBuilder(final SchemaPath path) {
         return new LeafrefTypeBuilder(path);
     }
 
-    public static StringTypeDefinition stringType() {
+    public static @NonNull StringTypeDefinition stringType() {
         return BaseStringType.INSTANCE;
     }
 
@@ -160,7 +160,7 @@ public final class BaseTypes {
         return new UnionTypeBuilder(path);
     }
 
-    public static Uint8TypeDefinition uint8Type() {
+    public static @NonNull Uint8TypeDefinition uint8Type() {
         return BaseUint8Type.INSTANCE;
     }
 
@@ -171,11 +171,11 @@ public final class BaseTypes {
      * @return If the type corresponds to the base uint8 type.
      * @throws NullPointerException if type is null
      */
-    public static boolean isUint8(@Nonnull final TypeDefinition<?> type) {
+    public static boolean isUint8(final @NonNull TypeDefinition<?> type) {
         return BaseUint8Type.INSTANCE.getPath().equals(type.getPath());
     }
 
-    public static Uint16TypeDefinition uint16Type() {
+    public static @NonNull Uint16TypeDefinition uint16Type() {
         return BaseUint16Type.INSTANCE;
     }
 
@@ -186,11 +186,11 @@ public final class BaseTypes {
      * @return If the type corresponds to the base uint16 type.
      * @throws NullPointerException if type is null
      */
-    public static boolean isUint16(@Nonnull final TypeDefinition<?> type) {
+    public static boolean isUint16(final @NonNull TypeDefinition<?> type) {
         return BaseUint16Type.INSTANCE.getPath().equals(type.getPath());
     }
 
-    public static Uint32TypeDefinition uint32Type() {
+    public static @NonNull Uint32TypeDefinition uint32Type() {
         return BaseUint32Type.INSTANCE;
     }
 
@@ -201,11 +201,11 @@ public final class BaseTypes {
      * @return If the type corresponds to the base uint32 type.
      * @throws NullPointerException if type is null
      */
-    public static boolean isUint32(@Nonnull final TypeDefinition<?> type) {
+    public static boolean isUint32(final @NonNull TypeDefinition<?> type) {
         return BaseUint32Type.INSTANCE.getPath().equals(type.getPath());
     }
 
-    public static Uint64TypeDefinition uint64Type() {
+    public static @NonNull Uint64TypeDefinition uint64Type() {
         return BaseUint64Type.INSTANCE;
     }
 
@@ -216,7 +216,7 @@ public final class BaseTypes {
      * @return If the type corresponds to the base uint64 type.
      * @throws NullPointerException if type is null
      */
-    public static boolean isUint64(@Nonnull final TypeDefinition<?> type) {
+    public static boolean isUint64(final @NonNull TypeDefinition<?> type) {
         return BaseUint64Type.INSTANCE.getPath().equals(type.getPath());
     }
 
@@ -228,7 +228,7 @@ public final class BaseTypes {
      * @return Base type of specified type
      * @throws NullPointerException if type is null
      */
-    public static TypeDefinition<?> baseTypeOf(@Nonnull final TypeDefinition<?> type) {
+    public static @NonNull TypeDefinition<?> baseTypeOf(final @NonNull TypeDefinition<?> type) {
         TypeDefinition<?> ret = type;
         while (ret.getBaseType() != null) {
             ret = ret.getBaseType();
index cc4ec376f4e1c065e05ee7f7efda4760ac9c5665..41b525927d9202c35f1a823d35077b94748eff2e 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseUint16Type extends AbstractRangeRestrictedBaseType<Uint16TypeDefinition, Integer>
         implements Uint16TypeDefinition {
-    static final BaseUint16Type INSTANCE = new BaseUint16Type();
+    static final @NonNull BaseUint16Type INSTANCE = new BaseUint16Type();
 
     private BaseUint16Type() {
         super(BaseTypes.UINT16_QNAME, 0, 65535);
index 97fdeb097447ee21ebccd3f5fa980b6aa18361b7..692e6eb367d7cfafd3b2d015b0071eaddd2cd97c 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseUint32Type extends AbstractRangeRestrictedBaseType<Uint32TypeDefinition, Long>
         implements Uint32TypeDefinition {
-    static final BaseUint32Type INSTANCE = new BaseUint32Type();
+    static final @NonNull BaseUint32Type INSTANCE = new BaseUint32Type();
 
     private BaseUint32Type() {
         super(BaseTypes.UINT32_QNAME, 0L, 4294967295L);
index 0c982a6a08bc1f8d835afc4db956864e2ea98b69..9de402b7c78b3bee2b7239e99acbbe6bc2248099 100644 (file)
@@ -8,12 +8,13 @@
 package org.opendaylight.yangtools.yang.model.util.type;
 
 import java.math.BigInteger;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseUint64Type extends AbstractRangeRestrictedBaseType<Uint64TypeDefinition, BigInteger>
         implements Uint64TypeDefinition {
-    static final BaseUint64Type INSTANCE = new BaseUint64Type();
+    static final @NonNull BaseUint64Type INSTANCE = new BaseUint64Type();
 
     private BaseUint64Type() {
         super(BaseTypes.UINT64_QNAME, BigInteger.ZERO, new BigInteger("18446744073709551615"));
index b952600bc5f00d69a791b2fd4a1d3109bb3066a8..c65293e17a0715d6c90933e06a9e47dc8a3238da 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 
 final class BaseUint8Type extends AbstractRangeRestrictedBaseType<Uint8TypeDefinition, Short>
         implements Uint8TypeDefinition {
-    static final BaseUint8Type INSTANCE = new BaseUint8Type();
+    static final @NonNull BaseUint8Type INSTANCE = new BaseUint8Type();
 
     private BaseUint8Type() {
         super(BaseTypes.UINT8_QNAME, (short)0, (short)255);
index 5c301bdafd89aff59fc0b6eb21b300d274141c01..11e0bedef887577c5cb5c9372e7e5ae09605fb61 100644 (file)
@@ -11,7 +11,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import java.util.Map;
 import java.util.TreeMap;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
@@ -27,7 +27,7 @@ public final class BitsTypeBuilder extends AbstractRestrictedTypeBuilder<BitsTyp
         super(baseType, path);
     }
 
-    public BitsTypeBuilder addBit(@Nonnull final Bit item) {
+    public BitsTypeBuilder addBit(final @NonNull Bit item) {
         // in case we are dealing with a restricted bits type, validate if the bit is a subset of its base type
         if (getBaseType() != null) {
             validateRestrictedBit(item);
@@ -38,7 +38,7 @@ public final class BitsTypeBuilder extends AbstractRestrictedTypeBuilder<BitsTyp
         return this;
     }
 
-    private void validateRestrictedBit(@Nonnull final Bit item) {
+    private void validateRestrictedBit(final @NonNull Bit item) {
         boolean isASubsetOfBaseBits = false;
         for (Bit baseTypeBit : getBaseType().getBits()) {
             if (item.getName().equals(baseTypeBit.getName())) {
index 552fc93b383c8df5bd45b003e459f3a560b5f93c..9a1f251b3457f8d7442cb545aaa8f159bd7056c5 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
 import java.util.List;
 import java.util.Optional;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
@@ -119,9 +121,8 @@ public final class CompatUtils {
      * @param leaf Leaf for which we are acquiring the type
      * @return Potentially base type of the leaf type.
      */
-    @Nonnull public static TypeDefinition<?> compatType(@Nonnull final TypedDataSchemaNode leaf) {
-        final TypeDefinition<?> leafType = leaf.getType();
-        Preconditions.checkNotNull(leafType);
+    public static @NonNull TypeDefinition<?> compatType(final @NonNull TypedDataSchemaNode leaf) {
+        final TypeDefinition<?> leafType = requireNonNull(leaf.getType());
 
         if (!leaf.getPath().equals(leafType.getPath())) {
             // Old parser semantics, or no new default/units defined for this leaf
@@ -130,7 +131,7 @@ public final class CompatUtils {
 
         // We are dealing with a type generated for the leaf itself
         final TypeDefinition<?> baseType = leafType.getBaseType();
-        Preconditions.checkArgument(baseType != null, "Leaf %s has type for leaf, but no base type", leaf);
+        checkArgument(baseType != null, "Leaf %s has type for leaf, but no base type", leaf);
 
         if (leaf.getPath().equals(baseType.getPath().getParent())) {
             // Internal instantiation of a base YANG type (decimal64 and similar)
@@ -170,24 +171,24 @@ public final class CompatUtils {
     }
 
     // FIXME: 3.0.0: remove this method
-    @Nonnull public static TypeDefinition<?> compatLeafType(@Nonnull final LeafSchemaNode leaf) {
+    public static @NonNull TypeDefinition<?> compatLeafType(final @NonNull LeafSchemaNode leaf) {
         return compatType(leaf);
     }
 
-    private static BinaryTypeDefinition baseTypeIfNotConstrained(final BinaryTypeDefinition type) {
+    private static BinaryTypeDefinition baseTypeIfNotConstrained(final @NonNull BinaryTypeDefinition type) {
         return baseTypeIfNotConstrained(type, type.getBaseType());
     }
 
-    private static TypeDefinition<?> baseTypeIfNotConstrained(final DecimalTypeDefinition type) {
+    private static TypeDefinition<?> baseTypeIfNotConstrained(final @NonNull DecimalTypeDefinition type) {
         return baseTypeIfNotConstrained(type, type.getBaseType());
     }
 
-    private static TypeDefinition<?> baseTypeIfNotConstrained(final InstanceIdentifierTypeDefinition type) {
+    private static TypeDefinition<?> baseTypeIfNotConstrained(final @NonNull InstanceIdentifierTypeDefinition type) {
         final InstanceIdentifierTypeDefinition base = type.getBaseType();
         return type.requireInstance() == base.requireInstance() ? base : type;
     }
 
-    private static TypeDefinition<?> baseTypeIfNotConstrained(final StringTypeDefinition type) {
+    private static TypeDefinition<?> baseTypeIfNotConstrained(final @NonNull StringTypeDefinition type) {
         final StringTypeDefinition base = type.getBaseType();
         final List<PatternConstraint> patterns = type.getPatternConstraints();
         final Optional<LengthConstraint> optLengths = type.getLengthConstraint();
@@ -200,11 +201,11 @@ public final class CompatUtils {
         return type;
     }
 
-    private static <T extends RangeRestrictedTypeDefinition<T, ?>> T baseTypeIfNotConstrained(final T type) {
+    private static <T extends RangeRestrictedTypeDefinition<T, ?>> T baseTypeIfNotConstrained(final @NonNull T type) {
         return baseTypeIfNotConstrained(type, type.getBaseType());
     }
 
-    private static <T extends RangeRestrictedTypeDefinition<T, ?>> T baseTypeIfNotConstrained(final T type,
+    private static <T extends RangeRestrictedTypeDefinition<T, ?>> T baseTypeIfNotConstrained(final @NonNull T type,
             final T base) {
         final Optional<?> optConstraint = type.getRangeConstraint();
         if (!optConstraint.isPresent()) {
@@ -213,7 +214,7 @@ public final class CompatUtils {
         return optConstraint.equals(base.getRangeConstraint()) ? base : type;
     }
 
-    private static <T extends LengthRestrictedTypeDefinition<T>> T baseTypeIfNotConstrained(final T type,
+    private static <T extends LengthRestrictedTypeDefinition<T>> T baseTypeIfNotConstrained(final @NonNull T type,
             final T base) {
         final Optional<LengthConstraint> optConstraint = type.getLengthConstraint();
         if (!optConstraint.isPresent()) {
index 06408daf3dbeed815f714e4e234a01a58be3d078..4a9d9ac230a60f43247bfc7e583fad378cb0f1e5 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import static com.google.common.base.Verify.verifyNotNull;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.Verify;
 import java.util.Objects;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
@@ -36,7 +37,7 @@ public abstract class ConcreteTypeBuilder<T extends TypeDefinition<T>> extends D
      *
      * @return A new type instance
      */
-    @Nonnull abstract T buildType();
+    abstract @NonNull T buildType();
 
     @Override
     public final T build() {
@@ -46,6 +47,6 @@ public abstract class ConcreteTypeBuilder<T extends TypeDefinition<T>> extends D
             return base;
         }
 
-        return Verify.verifyNotNull(buildType());
+        return verifyNotNull(buildType());
     }
 }
index 1f43830e590240ab74ed3637a392346d0da106ab..a1fd2cdd1d34d6f6d4f0148fe843612a4c69b05e 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.yangtools.yang.model.util.type;
 
 import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
@@ -35,13 +35,13 @@ import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
  * Support for creating {@link TypeDefinition} instances defined by leaf and leaf-list statements.
  */
 @Beta
+@NonNullByDefault
 public final class ConcreteTypes {
     private ConcreteTypes() {
         throw new UnsupportedOperationException();
     }
 
-    public static ConcreteTypeBuilder<?> concreteTypeBuilder(@Nonnull final TypeDefinition<?> baseType,
-            @Nonnull final SchemaPath path) {
+    public static ConcreteTypeBuilder<?> concreteTypeBuilder(final TypeDefinition<?> baseType, final SchemaPath path) {
         if (baseType instanceof BinaryTypeDefinition) {
             return concreteBinaryBuilder((BinaryTypeDefinition) baseType, path);
         } else if (baseType instanceof BitsTypeDefinition) {
@@ -86,9 +86,8 @@ public final class ConcreteTypes {
     }
 
     private static ConcreteTypeBuilder<BinaryTypeDefinition> concreteBinaryBuilder(
-            @Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
+            final BinaryTypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<BinaryTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public BinaryTypeDefinition buildType() {
                 return new DerivedBinaryType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -100,7 +99,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<BitsTypeDefinition> concreteBitsBuilder(final BitsTypeDefinition baseType,
             final SchemaPath path) {
         return new ConcreteTypeBuilder<BitsTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public BitsTypeDefinition buildType() {
                 return new DerivedBitsType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -110,9 +108,8 @@ public final class ConcreteTypes {
     }
 
     private static ConcreteTypeBuilder<BooleanTypeDefinition> concreteBooleanBuilder(
-            @Nonnull final BooleanTypeDefinition baseType, @Nonnull final SchemaPath path) {
+            final BooleanTypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<BooleanTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public BooleanTypeDefinition buildType() {
                 return new DerivedBooleanType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -124,7 +121,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<DecimalTypeDefinition> concreteDecimalBuilder(
             final DecimalTypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<DecimalTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public DecimalTypeDefinition buildType() {
                 return new DerivedDecimalType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -136,7 +132,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<EmptyTypeDefinition> concreteEmptyBuilder(final EmptyTypeDefinition baseType,
             final SchemaPath path) {
         return new ConcreteTypeBuilder<EmptyTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public EmptyTypeDefinition buildType() {
                 return new DerivedEmptyType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -148,7 +143,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<EnumTypeDefinition> concreteEnumerationBuilder(
             final EnumTypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<EnumTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public EnumTypeDefinition buildType() {
                 return new DerivedEnumerationType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -160,7 +154,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<IdentityrefTypeDefinition> concreteIdentityrefBuilder(
             final IdentityrefTypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<IdentityrefTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public IdentityrefTypeDefinition buildType() {
                 return new DerivedIdentityrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -172,7 +165,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<InstanceIdentifierTypeDefinition> concreteInstanceIdentifierBuilder(
             final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<InstanceIdentifierTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public InstanceIdentifierTypeDefinition buildType() {
                 return new DerivedInstanceIdentifierType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -184,7 +176,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<Int8TypeDefinition> concreteInt8Builder(
             final Int8TypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<Int8TypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public Int8TypeDefinition buildType() {
                 return new DerivedInt8Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -196,7 +187,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<Int16TypeDefinition> concreteInt16Builder(
             final Int16TypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<Int16TypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public Int16TypeDefinition buildType() {
                 return new DerivedInt16Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -208,7 +198,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<Int32TypeDefinition> concreteInt32Builder(
             final Int32TypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<Int32TypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public Int32TypeDefinition buildType() {
                 return new DerivedInt32Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -220,7 +209,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<Int64TypeDefinition> concreteInt64Builder(
             final Int64TypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<Int64TypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public Int64TypeDefinition buildType() {
                 return new DerivedInt64Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -232,7 +220,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<LeafrefTypeDefinition> concreteLeafrefBuilder(
             final LeafrefTypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<LeafrefTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public LeafrefTypeDefinition buildType() {
                 return new DerivedLeafrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -244,7 +231,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<StringTypeDefinition> concreteStringBuilder(final StringTypeDefinition baseType,
             final SchemaPath path) {
         return new ConcreteTypeBuilder<StringTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public StringTypeDefinition buildType() {
                 return new DerivedStringType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -256,7 +242,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<UnionTypeDefinition> concreteUnionBuilder(final UnionTypeDefinition baseType,
             final SchemaPath path) {
         return new ConcreteTypeBuilder<UnionTypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public DerivedUnionType buildType() {
                 return new DerivedUnionType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -268,7 +253,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<Uint8TypeDefinition> concreteUint8Builder(
             final Uint8TypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<Uint8TypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public Uint8TypeDefinition buildType() {
                 return new DerivedUint8Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -280,7 +264,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<Uint16TypeDefinition> concreteUint16Builder(
             final Uint16TypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<Uint16TypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public Uint16TypeDefinition buildType() {
                 return new DerivedUint16Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -292,7 +275,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<Uint32TypeDefinition> concreteUint32Builder(
             final Uint32TypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<Uint32TypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public Uint32TypeDefinition buildType() {
                 return new DerivedUint32Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
@@ -304,7 +286,6 @@ public final class ConcreteTypes {
     private static ConcreteTypeBuilder<Uint64TypeDefinition> concreteUint64Builder(
             final Uint64TypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<Uint64TypeDefinition>(baseType, path) {
-            @Nonnull
             @Override
             public Uint64TypeDefinition buildType() {
                 return new DerivedUint64Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
index cd7fffd2831137c5dc0e0f30493ab6a2502fe5f4..811c6ae316a137f1e4682bc7bdcd283535688669 100644 (file)
@@ -11,7 +11,7 @@ import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
 import java.util.Optional;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -45,19 +45,19 @@ public abstract class DerivedTypeBuilder<T extends TypeDefinition<T>> extends Ty
         units = baseType.getUnits().orElse(null);
     }
 
-    public void setDefaultValue(@Nonnull final Object defaultValue) {
+    public void setDefaultValue(final @NonNull Object defaultValue) {
         this.defaultValue = requireNonNull(defaultValue);
     }
 
-    public final void setDescription(@Nonnull final String description) {
+    public final void setDescription(final @NonNull String description) {
         this.description = requireNonNull(description);
     }
 
-    public final void setReference(@Nonnull final String reference) {
+    public final void setReference(final @NonNull String reference) {
         this.reference = requireNonNull(reference);
     }
 
-    public final void setStatus(@Nonnull final Status status) {
+    public final void setStatus(final @NonNull Status status) {
         this.status = requireNonNull(status);
     }
 
index f38aa37b056a8cc38b9a2a16ab365c780ca59a15..e098c418b859becc0e4ae32a97c4f66b31db39bc 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.yangtools.yang.model.util.type;
 
 import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
@@ -47,8 +47,8 @@ public final class DerivedTypes {
         throw new UnsupportedOperationException();
     }
 
-    public static DerivedTypeBuilder<?> derivedTypeBuilder(@Nonnull final TypeDefinition<?> baseType,
-            @Nonnull final SchemaPath path) {
+    public static @NonNull DerivedTypeBuilder<?> derivedTypeBuilder(final @NonNull TypeDefinition<?> baseType,
+            final @NonNull SchemaPath path) {
         if (baseType instanceof BinaryTypeDefinition) {
             return derivedBinaryBuilder((BinaryTypeDefinition) baseType, path);
         } else if (baseType instanceof BitsTypeDefinition) {
@@ -92,8 +92,8 @@ public final class DerivedTypes {
         }
     }
 
-    public static DerivedTypeBuilder<BinaryTypeDefinition> derivedBinaryBuilder(
-            @Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
+    public static @NonNull DerivedTypeBuilder<BinaryTypeDefinition> derivedBinaryBuilder(
+            final @NonNull BinaryTypeDefinition baseType, final @NonNull SchemaPath path) {
         return new DerivedTypeBuilder<BinaryTypeDefinition>(baseType, path) {
             @Override
             public BinaryTypeDefinition build() {
@@ -103,7 +103,7 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<BitsTypeDefinition> derivedBitsBuilder(final BitsTypeDefinition baseType,
+    public static @NonNull DerivedTypeBuilder<BitsTypeDefinition> derivedBitsBuilder(final BitsTypeDefinition baseType,
             final SchemaPath path) {
         return new DerivedTypeBuilder<BitsTypeDefinition>(baseType, path) {
             @Override
@@ -114,8 +114,8 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<BooleanTypeDefinition> derivedBooleanBuilder(
-            @Nonnull final BooleanTypeDefinition baseType, @Nonnull final SchemaPath path) {
+    public static @NonNull DerivedTypeBuilder<BooleanTypeDefinition> derivedBooleanBuilder(
+            final @NonNull BooleanTypeDefinition baseType, final @NonNull SchemaPath path) {
         return new DerivedTypeBuilder<BooleanTypeDefinition>(baseType, path) {
             @Override
             public BooleanTypeDefinition build() {
@@ -125,8 +125,8 @@ public final class DerivedTypes {
         };
     }
 
-    private static DerivedTypeBuilder<DecimalTypeDefinition> derivedDecimalBuilder(final DecimalTypeDefinition baseType,
-            final SchemaPath path) {
+    private static @NonNull DerivedTypeBuilder<DecimalTypeDefinition> derivedDecimalBuilder(
+            final DecimalTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<DecimalTypeDefinition>(baseType, path) {
             @Override
             public DecimalTypeDefinition build() {
@@ -136,8 +136,8 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<EmptyTypeDefinition> derivedEmptyBuilder(final EmptyTypeDefinition baseType,
-            final SchemaPath path) {
+    public static @NonNull DerivedTypeBuilder<EmptyTypeDefinition> derivedEmptyBuilder(
+            final EmptyTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<EmptyTypeDefinition>(baseType, path) {
             @Override
             public EmptyTypeDefinition build() {
@@ -147,8 +147,8 @@ public final class DerivedTypes {
         };
     }
 
-    private static DerivedTypeBuilder<EnumTypeDefinition> derivedEnumerationBuilder(final EnumTypeDefinition baseType,
-            final SchemaPath path) {
+    private static @NonNull DerivedTypeBuilder<EnumTypeDefinition> derivedEnumerationBuilder(
+            final EnumTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<EnumTypeDefinition>(baseType, path) {
             @Override
             public EnumTypeDefinition build() {
@@ -158,7 +158,7 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<IdentityrefTypeDefinition> derivedIdentityrefBuilder(
+    public static @NonNull DerivedTypeBuilder<IdentityrefTypeDefinition> derivedIdentityrefBuilder(
             final IdentityrefTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<IdentityrefTypeDefinition>(baseType, path) {
             @Override
@@ -169,7 +169,7 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<InstanceIdentifierTypeDefinition> derivedInstanceIdentifierBuilder(
+    public static @NonNull DerivedTypeBuilder<InstanceIdentifierTypeDefinition> derivedInstanceIdentifierBuilder(
             final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<InstanceIdentifierTypeDefinition>(baseType, path) {
             @Override
@@ -180,7 +180,7 @@ public final class DerivedTypes {
         };
     }
 
-    private static DerivedTypeBuilder<Int8TypeDefinition> derivedInt8Builder(final Int8TypeDefinition baseType,
+    private static @NonNull DerivedTypeBuilder<Int8TypeDefinition> derivedInt8Builder(final Int8TypeDefinition baseType,
             final SchemaPath path) {
         return new DerivedTypeBuilder<Int8TypeDefinition>(baseType, path) {
             @Override
@@ -191,8 +191,8 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<Int16TypeDefinition> derivedInt16Builder(final Int16TypeDefinition baseType,
-            final SchemaPath path) {
+    public static @NonNull DerivedTypeBuilder<Int16TypeDefinition> derivedInt16Builder(
+            final Int16TypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<Int16TypeDefinition>(baseType, path) {
             @Override
             public Int16TypeDefinition build() {
@@ -202,8 +202,8 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<Int32TypeDefinition> derivedInt32Builder(final Int32TypeDefinition baseType,
-            final SchemaPath path) {
+    public static @NonNull DerivedTypeBuilder<Int32TypeDefinition> derivedInt32Builder(
+            final Int32TypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<Int32TypeDefinition>(baseType, path) {
             @Override
             public Int32TypeDefinition build() {
@@ -213,8 +213,8 @@ public final class DerivedTypes {
         };
     }
 
-    private static DerivedTypeBuilder<Int64TypeDefinition> derivedInt64Builder(final Int64TypeDefinition baseType,
-            final SchemaPath path) {
+    private static @NonNull DerivedTypeBuilder<Int64TypeDefinition> derivedInt64Builder(
+            final Int64TypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<Int64TypeDefinition>(baseType, path) {
             @Override
             public Int64TypeDefinition build() {
@@ -224,8 +224,8 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<LeafrefTypeDefinition> derivedLeafrefBuilder(final LeafrefTypeDefinition baseType,
-            final SchemaPath path) {
+    public static @NonNull DerivedTypeBuilder<LeafrefTypeDefinition> derivedLeafrefBuilder(
+            final LeafrefTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<LeafrefTypeDefinition>(baseType, path) {
             @Override
             public LeafrefTypeDefinition build() {
@@ -235,8 +235,8 @@ public final class DerivedTypes {
         };
     }
 
-    private static DerivedTypeBuilder<StringTypeDefinition> derivedStringBuilder(final StringTypeDefinition baseType,
-            final SchemaPath path) {
+    private static @NonNull DerivedTypeBuilder<StringTypeDefinition> derivedStringBuilder(
+            final StringTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<StringTypeDefinition>(baseType, path) {
             @Override
             public StringTypeDefinition build() {
@@ -246,8 +246,8 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<UnionTypeDefinition> derivedUnionBuilder(final UnionTypeDefinition baseType,
-            final SchemaPath path) {
+    public static @NonNull DerivedTypeBuilder<UnionTypeDefinition> derivedUnionBuilder(
+            final UnionTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<UnionTypeDefinition>(baseType, path) {
             @Override
             public DerivedUnionType build() {
@@ -257,7 +257,7 @@ public final class DerivedTypes {
         };
     }
 
-    private static DerivedTypeBuilder<Uint8TypeDefinition> derivedUint8Builder(
+    private static @NonNull DerivedTypeBuilder<Uint8TypeDefinition> derivedUint8Builder(
             final Uint8TypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<Uint8TypeDefinition>(baseType, path) {
             @Override
@@ -268,7 +268,7 @@ public final class DerivedTypes {
         };
     }
 
-    private static DerivedTypeBuilder<Uint16TypeDefinition> derivedUint16Builder(
+    private static @NonNull DerivedTypeBuilder<Uint16TypeDefinition> derivedUint16Builder(
             final Uint16TypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<Uint16TypeDefinition>(baseType, path) {
             @Override
@@ -279,7 +279,7 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<Uint32TypeDefinition> derivedUint32Builder(
+    public static @NonNull DerivedTypeBuilder<Uint32TypeDefinition> derivedUint32Builder(
             final Uint32TypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<Uint32TypeDefinition>(baseType, path) {
             @Override
@@ -290,7 +290,7 @@ public final class DerivedTypes {
         };
     }
 
-    public static DerivedTypeBuilder<Uint64TypeDefinition> derivedUint64Builder(
+    public static @NonNull DerivedTypeBuilder<Uint64TypeDefinition> derivedUint64Builder(
             final Uint64TypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<Uint64TypeDefinition>(baseType, path) {
             @Override
index f8e3e119e97eea8dbcf180fc4176323e0c9948d0..bb95d6ed66797c5ddb495633c5b324bc3043d4c8 100644 (file)
@@ -11,7 +11,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import java.util.HashMap;
 import java.util.Map;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
@@ -27,10 +27,11 @@ public final class EnumerationTypeBuilder extends AbstractRestrictedTypeBuilder<
         super(baseType, path);
     }
 
-    public EnumerationTypeBuilder addEnum(@Nonnull final EnumPair item) {
+    public EnumerationTypeBuilder addEnum(final @NonNull EnumPair item) {
         // in case we are dealing with a restricted enumeration type, validate if the enum is a subset of its base type
-        if (getBaseType() != null) {
-            validateRestrictedEnum(item);
+        final EnumTypeDefinition base = getBaseType();
+        if (base != null) {
+            validateRestrictedEnum(item, base);
         }
 
         builder.put(item.getName(), item);
@@ -38,14 +39,14 @@ public final class EnumerationTypeBuilder extends AbstractRestrictedTypeBuilder<
         return this;
     }
 
-    private void validateRestrictedEnum(@Nonnull final EnumPair item) {
+    private static void validateRestrictedEnum(final @NonNull EnumPair item, final @NonNull EnumTypeDefinition base) {
         boolean isASubsetOfBaseEnums = false;
-        for (EnumPair baseTypeEnumPair : getBaseType().getValues()) {
+        for (EnumPair baseTypeEnumPair : base.getValues()) {
             if (item.getName().equals(baseTypeEnumPair.getName())) {
                 if (item.getValue() != baseTypeEnumPair.getValue()) {
                     throw new InvalidEnumDefinitionException(item, "Value of enum '%s' must be the same as the value"
                             + " of corresponding enum in the base enumeration type %s.", item.getName(),
-                            getBaseType().getQName());
+                            base.getQName());
                 }
                 isASubsetOfBaseEnums = true;
                 break;
@@ -54,7 +55,7 @@ public final class EnumerationTypeBuilder extends AbstractRestrictedTypeBuilder<
 
         if (!isASubsetOfBaseEnums) {
             throw new InvalidEnumDefinitionException(item, "Enum '%s' is not a subset of its base enumeration type %s.",
-                    item.getName(), getBaseType().getQName());
+                    item.getName(), base.getQName());
         }
     }
 
@@ -70,10 +71,7 @@ public final class EnumerationTypeBuilder extends AbstractRestrictedTypeBuilder<
             }
         }
 
-        if (getBaseType() == null) {
-            return new BaseEnumerationType(getPath(), getUnknownSchemaNodes(), map.values());
-        } else {
-            return new RestrictedEnumerationType(getBaseType(), getPath(), getUnknownSchemaNodes(), map.values());
-        }
+        return getBaseType() == null ? new BaseEnumerationType(getPath(), getUnknownSchemaNodes(), map.values())
+                : new RestrictedEnumerationType(getBaseType(), getPath(), getUnknownSchemaNodes(), map.values());
     }
 }
index d71b30819f9e4837c196ffdfbf84990b0756f87f..23d63bda4b3c2864a853b332f45d3a525a4f361d 100644 (file)
@@ -12,7 +12,7 @@ import static com.google.common.base.Preconditions.checkState;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSet.Builder;
 import java.util.Set;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
@@ -24,7 +24,7 @@ public final class IdentityrefTypeBuilder extends TypeBuilder<IdentityrefTypeDef
         super(null, path);
     }
 
-    public IdentityrefTypeBuilder addIdentity(@Nonnull final IdentitySchemaNode identity) {
+    public IdentityrefTypeBuilder addIdentity(final @NonNull IdentitySchemaNode identity) {
         builder.add(identity);
         return this;
     }
index e6b2e8104176ffec92d0cf437d357523cb525683..5c99a0675e106b992d21b6def5f462300a365c85 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
 
@@ -16,16 +17,16 @@ public final class InstanceIdentifierTypeBuilder
 
     InstanceIdentifierTypeBuilder(final InstanceIdentifierTypeDefinition baseType,
             final SchemaPath path) {
-        super(Preconditions.checkNotNull(baseType), path);
+        super(requireNonNull(baseType), path);
     }
 
     @Override
     InstanceIdentifierTypeDefinition buildType() {
-        if (getRequireInstance() == getBaseType().requireInstance()) {
-            return getBaseType();
+        final InstanceIdentifierTypeDefinition base = getBaseType();
+        if (getRequireInstance() == base.requireInstance()) {
+            return base;
         }
 
-        return new RestrictedInstanceIdentifierType(getBaseType(), getPath(), getUnknownSchemaNodes(),
-                getRequireInstance());
+        return new RestrictedInstanceIdentifierType(base, getPath(), getUnknownSchemaNodes(), getRequireInstance());
     }
 }
index 03dabd7b0d62a463d28330afa45efff40c0e1bba..785924cbe667b9ed5c873ea3e84449d7d6111e59 100644 (file)
@@ -7,8 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
-import com.google.common.base.Preconditions;
-import javax.annotation.Nonnull;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
@@ -20,9 +22,9 @@ public final class LeafrefTypeBuilder extends RequireInstanceRestrictedTypeBuild
         super(null, path);
     }
 
-    public LeafrefTypeBuilder setPathStatement(@Nonnull final RevisionAwareXPath pathStatement) {
-        Preconditions.checkState(this.pathStatement == null, "Path statement already set to %s", this.pathStatement);
-        this.pathStatement = Preconditions.checkNotNull(pathStatement);
+    public LeafrefTypeBuilder setPathStatement(final @NonNull RevisionAwareXPath pathStatement) {
+        checkState(this.pathStatement == null, "Path statement already set to %s", this.pathStatement);
+        this.pathStatement = requireNonNull(pathStatement);
         return this;
     }
 
index 456d9fa3627bc8ab612e5ff7da9a66d16b109c28..0fe45fb681889918ddd787370a080d817f26eb1e 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import com.google.common.annotations.Beta;
 import java.math.BigDecimal;
 import java.math.BigInteger;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
@@ -74,8 +74,8 @@ public final class RestrictedTypes {
         throw new UnsupportedOperationException();
     }
 
-    public static LengthRestrictedTypeBuilder<BinaryTypeDefinition> newBinaryBuilder(
-            @Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
+    public static @NonNull LengthRestrictedTypeBuilder<BinaryTypeDefinition> newBinaryBuilder(
+            final @NonNull BinaryTypeDefinition baseType, final @NonNull SchemaPath path) {
         return new LengthRestrictedTypeBuilder<BinaryTypeDefinition>(baseType, path) {
             @Override
             BinaryTypeDefinition buildType(final @Nullable LengthConstraint constraint) {
@@ -93,12 +93,13 @@ public final class RestrictedTypes {
         };
     }
 
-    public static BitsTypeBuilder newBitsBuilder(final BitsTypeDefinition baseType, final SchemaPath path) {
+    public static @NonNull BitsTypeBuilder newBitsBuilder(final BitsTypeDefinition baseType,
+            final SchemaPath path) {
         return new BitsTypeBuilder(baseType, path);
     }
 
-    public static TypeBuilder<BooleanTypeDefinition> newBooleanBuilder(@Nonnull final BooleanTypeDefinition baseType,
-            @Nonnull final SchemaPath path) {
+    public static @NonNull TypeBuilder<BooleanTypeDefinition> newBooleanBuilder(
+            final @NonNull BooleanTypeDefinition baseType, final @NonNull SchemaPath path) {
         return new AbstractRestrictedTypeBuilder<BooleanTypeDefinition>(baseType, path) {
             @Override
             BooleanTypeDefinition buildType() {
@@ -107,7 +108,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<DecimalTypeDefinition, BigDecimal> newDecima64Builder(
+    public static @NonNull RangeRestrictedTypeBuilder<DecimalTypeDefinition, BigDecimal> newDecima64Builder(
             final DecimalTypeDefinition baseType, final SchemaPath path) {
         return new RangeRestrictedTypeBuilderWithBase<DecimalTypeDefinition, BigDecimal>(baseType, path) {
             @Override
@@ -117,7 +118,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static TypeBuilder<EmptyTypeDefinition> newEmptyBuilder(final EmptyTypeDefinition baseType,
+    public static @NonNull TypeBuilder<EmptyTypeDefinition> newEmptyBuilder(final EmptyTypeDefinition baseType,
             final SchemaPath path) {
         return new AbstractRestrictedTypeBuilder<EmptyTypeDefinition>(baseType, path) {
             @Override
@@ -127,13 +128,13 @@ public final class RestrictedTypes {
         };
     }
 
-    public static EnumerationTypeBuilder newEnumerationBuilder(final EnumTypeDefinition baseType,
+    public static @NonNull EnumerationTypeBuilder newEnumerationBuilder(final EnumTypeDefinition baseType,
             final SchemaPath path) {
         return new EnumerationTypeBuilder(baseType, path);
     }
 
-    public static TypeBuilder<IdentityrefTypeDefinition> newIdentityrefBuilder(final IdentityrefTypeDefinition baseType,
-            final SchemaPath path) {
+    public static @NonNull TypeBuilder<IdentityrefTypeDefinition> newIdentityrefBuilder(
+            final IdentityrefTypeDefinition baseType, final SchemaPath path) {
         return new AbstractRestrictedTypeBuilder<IdentityrefTypeDefinition>(baseType, path) {
             @Override
             IdentityrefTypeDefinition buildType() {
@@ -142,18 +143,19 @@ public final class RestrictedTypes {
         };
     }
 
-    public static InstanceIdentifierTypeBuilder newInstanceIdentifierBuilder(
+    public static @NonNull InstanceIdentifierTypeBuilder newInstanceIdentifierBuilder(
             final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
         return new InstanceIdentifierTypeBuilder(baseType, path);
     }
 
-    public static RequireInstanceRestrictedTypeBuilder<LeafrefTypeDefinition> newLeafrefBuilder(
+    public static @NonNull RequireInstanceRestrictedTypeBuilder<LeafrefTypeDefinition> newLeafrefBuilder(
             final LeafrefTypeDefinition baseType, final SchemaPath path) {
         return new RequireInstanceRestrictedTypeBuilder<LeafrefTypeDefinition>(baseType, path) {
             @Override
             LeafrefTypeDefinition buildType() {
-                if (getRequireInstance() == getBaseType().requireInstance()) {
-                    return getBaseType();
+                final LeafrefTypeDefinition base = getBaseType();
+                if (getRequireInstance() == base.requireInstance()) {
+                    return base;
                 }
                 return new RestrictedLeafrefType(getBaseType(), getPath(), getUnknownSchemaNodes(),
                         getRequireInstance());
@@ -161,7 +163,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<Int8TypeDefinition, Byte> newInt8Builder(
+    public static @NonNull RangeRestrictedTypeBuilder<Int8TypeDefinition, Byte> newInt8Builder(
             final Int8TypeDefinition baseType, final SchemaPath path) {
         return new RangeRestrictedTypeBuilderWithBase<Int8TypeDefinition, Byte>(baseType, path) {
             @Override
@@ -171,7 +173,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<Int16TypeDefinition, Short> newInt16Builder(
+    public static @NonNull RangeRestrictedTypeBuilder<Int16TypeDefinition, Short> newInt16Builder(
             final Int16TypeDefinition baseType, final SchemaPath path) {
         return new RangeRestrictedTypeBuilderWithBase<Int16TypeDefinition, Short>(baseType, path) {
             @Override
@@ -181,7 +183,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<Int32TypeDefinition, Integer> newInt32Builder(
+    public static @NonNull RangeRestrictedTypeBuilder<Int32TypeDefinition, Integer> newInt32Builder(
             final Int32TypeDefinition baseType, final SchemaPath path) {
         return new RangeRestrictedTypeBuilderWithBase<Int32TypeDefinition, Integer>(baseType, path) {
             @Override
@@ -191,7 +193,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<Int64TypeDefinition, Long> newInt64Builder(
+    public static @NonNull RangeRestrictedTypeBuilder<Int64TypeDefinition, Long> newInt64Builder(
             final Int64TypeDefinition baseType, final SchemaPath path) {
         return new RangeRestrictedTypeBuilderWithBase<Int64TypeDefinition, Long>(baseType, path) {
             @Override
@@ -201,11 +203,12 @@ public final class RestrictedTypes {
         };
     }
 
-    public static StringTypeBuilder newStringBuilder(final StringTypeDefinition baseType, final SchemaPath path) {
+    public static @NonNull StringTypeBuilder newStringBuilder(final StringTypeDefinition baseType,
+            final SchemaPath path) {
         return new StringTypeBuilder(baseType, path);
     }
 
-    public static TypeBuilder<UnionTypeDefinition> newUnionBuilder(final UnionTypeDefinition baseType,
+    public static @NonNull TypeBuilder<UnionTypeDefinition> newUnionBuilder(final UnionTypeDefinition baseType,
             final SchemaPath path) {
         return new AbstractRestrictedTypeBuilder<UnionTypeDefinition>(baseType, path) {
             @Override
@@ -215,7 +218,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<Uint8TypeDefinition, Short> newUint8Builder(
+    public static @NonNull RangeRestrictedTypeBuilder<Uint8TypeDefinition, Short> newUint8Builder(
             final Uint8TypeDefinition baseType, final SchemaPath path) {
         return new RangeRestrictedTypeBuilderWithBase<Uint8TypeDefinition, Short>(baseType, path) {
             @Override
@@ -225,7 +228,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<Uint16TypeDefinition, Integer> newUint16Builder(
+    public static @NonNull RangeRestrictedTypeBuilder<Uint16TypeDefinition, Integer> newUint16Builder(
             final Uint16TypeDefinition baseType, final SchemaPath path) {
         return new RangeRestrictedTypeBuilderWithBase<Uint16TypeDefinition, Integer>(baseType, path) {
             @Override
@@ -235,7 +238,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<Uint32TypeDefinition, Long> newUint32Builder(
+    public static @NonNull RangeRestrictedTypeBuilder<Uint32TypeDefinition, Long> newUint32Builder(
             final Uint32TypeDefinition baseType, final SchemaPath path) {
         return new RangeRestrictedTypeBuilderWithBase<Uint32TypeDefinition, Long>(baseType, path) {
             @Override
@@ -245,7 +248,7 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<Uint64TypeDefinition, BigInteger> newUint64Builder(
+    public static @NonNull RangeRestrictedTypeBuilder<Uint64TypeDefinition, BigInteger> newUint64Builder(
             final Uint64TypeDefinition baseType, final SchemaPath path) {
         return new RangeRestrictedTypeBuilderWithBase<Uint64TypeDefinition, BigInteger>(baseType, path) {
             @Override
index 5920a36c07c28b325462a0993837bf660d08a86f..ef54193ed753d773454294abe2bb022fa7273882 100644 (file)
@@ -7,9 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableList;
 import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -17,27 +20,27 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 
 public abstract class TypeBuilder<T extends TypeDefinition<T>> implements Builder<T> {
     private final ImmutableList.Builder<UnknownSchemaNode> unknownSchemaNodes = ImmutableList.builder();
-    private final SchemaPath path;
-    private final T baseType;
+    private final @NonNull SchemaPath path;
+    private final @Nullable T baseType;
 
-    TypeBuilder(final T baseType, final SchemaPath path) {
-        this.path = Preconditions.checkNotNull(path);
+    TypeBuilder(final @Nullable T baseType, final SchemaPath path) {
+        this.path = requireNonNull(path);
         this.baseType = baseType;
     }
 
-    final T getBaseType() {
+    final @Nullable T getBaseType() {
         return baseType;
     }
 
-    final SchemaPath getPath() {
+    final @NonNull SchemaPath getPath() {
         return path;
     }
 
-    final List<UnknownSchemaNode> getUnknownSchemaNodes() {
+    final @NonNull List<UnknownSchemaNode> getUnknownSchemaNodes() {
         return unknownSchemaNodes.build();
     }
 
-    public final void addUnknownSchemaNode(final UnknownSchemaNode node) {
+    public final void addUnknownSchemaNode(final @NonNull UnknownSchemaNode node) {
         unknownSchemaNodes.add(node);
     }
 }
index 4f8440e31a5df269dabec40c1a8c766945027178..18923aefc09b325b984536ca47ece45db0be9130 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.yangtools.yang.model.util.type;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableList.Builder;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
@@ -21,7 +21,7 @@ public final class UnionTypeBuilder extends TypeBuilder<UnionTypeDefinition> {
         super(null, path);
     }
 
-    public UnionTypeBuilder addType(@Nonnull final TypeDefinition<?> type) {
+    public UnionTypeBuilder addType(final @NonNull TypeDefinition<?> type) {
         builder.add(type);
         return this;
     }
index adb7b5b532383af969274693634ea990a74a63ee..3fd64d131b089ea112126fa70fa4cd3c8f2a8bbb 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.Arrays;
 import java.util.concurrent.Future;
-import javax.annotation.Nonnull;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -142,13 +141,12 @@ public class SchemaSourceTransformerTest {
     private class Provider extends AbstractSchemaRepository {
         @Deprecated
         @Override
-        public SchemaContextFactory createSchemaContextFactory(@Nonnull final SchemaSourceFilter filter) {
+        public SchemaContextFactory createSchemaContextFactory(final SchemaSourceFilter filter) {
             return null;
         }
 
         @Override
-        public SchemaContextFactory createSchemaContextFactory(
-                @Nonnull final SchemaContextFactoryConfiguration config) {
+        public SchemaContextFactory createSchemaContextFactory(final SchemaContextFactoryConfiguration config) {
             return null;
         }
 
@@ -157,13 +155,12 @@ public class SchemaSourceTransformerTest {
     private class Consumer extends AbstractSchemaRepository {
         @Deprecated
         @Override
-        public SchemaContextFactory createSchemaContextFactory(@Nonnull final SchemaSourceFilter filter) {
+        public SchemaContextFactory createSchemaContextFactory(final SchemaSourceFilter filter) {
             return null;
         }
 
         @Override
-        public SchemaContextFactory createSchemaContextFactory(
-                @Nonnull final SchemaContextFactoryConfiguration config) {
+        public SchemaContextFactory createSchemaContextFactory(final SchemaContextFactoryConfiguration config) {
             return null;
         }
     }