Enable checkstyle in yang-model-util 13/58713/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 12 Jun 2017 07:57:55 +0000 (09:57 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 12 Jun 2017 16:49:49 +0000 (16:49 +0000)
Change-Id: I52d97ddfb88eaedd168a373e55ab06e0f21b8f46
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
70 files changed:
yang/yang-model-util/pom.xml
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaListenerRegistration.java
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/AbstractSchemaSourceCache.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaSourceRegistration.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/FilesystemSchemaSourceCache.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/InMemorySchemaSourceCache.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/AbstractSchemaContext.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseConstraints.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseTypes.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/DataNodeIterator.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.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/LengthConstraintImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/ModuleIdentifierImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RegexUtils.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/UnresolvedNumber.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractDerivedType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractIntegerBaseType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRestrictedType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseDecimalType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseEnumerationType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BaseIdentityrefType.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/BaseUnionType.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/ConcreteTypes.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/DerivedIdentityrefType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/DerivedInstanceIdentifierType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/DerivedIntegerType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/DerivedStringType.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/InstanceIdentifierTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/LengthRestrictedTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/NumberUtil.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RangeRestrictedTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RestrictedBinaryType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RestrictedBooleanType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RestrictedIdentityrefType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RestrictedIntegerType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RestrictedLeafrefType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RestrictedStringType.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/TypeDefinitions.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/repo/util/InMemorySchemaSourceCacheTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/repo/util/SchemaSourceTransformerTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BaseConstraintsTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BaseTypesTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BinaryTypeTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BitsTypeTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BooleanTypeTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/Bug4969Test.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/DataNodeIteratorTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/EmptyTypeTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/Int8Test.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/LeafrefTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImplTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextProxyTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtilTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaNodeUtilsTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/BitImplTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/TypeTest.java

index dda350105620fd59f59543474943a82727602e0f..d7cd67e50aa2b01600e021f759194a0cc35f4ab6 100644 (file)
         </dependency>
     </dependencies>
 
-  <!--
-      Maven Site Configuration
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 
-      The following configuration is necessary for maven-site-plugin to
-      correctly identify the correct deployment path for OpenDaylight Maven
-      sites.
-  -->
-  <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+    <!--
+        Maven Site Configuration
 
-  <distributionManagement>
-    <site>
-      <id>opendaylight-site</id>
-      <url>${nexus.site.url}/${project.artifactId}/</url>
-    </site>
-  </distributionManagement>
+        The following configuration is necessary for maven-site-plugin to
+        correctly identify the correct deployment path for OpenDaylight Maven
+        sites.
+    -->
+    <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+
+    <distributionManagement>
+        <site>
+            <id>opendaylight-site</id>
+            <url>${nexus.site.url}/${project.artifactId}/</url>
+        </site>
+    </distributionManagement>
 </project>
index c8cc2f0799ba31f71d274f8cf351eea69937ffd4..336f63440c7f0a11904aea9e73de177d6f560bc3 100644 (file)
@@ -11,7 +11,8 @@ import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaListenerRegistration;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceListener;
 
-public abstract class AbstractSchemaListenerRegistration extends AbstractListenerRegistration<SchemaSourceListener> implements SchemaListenerRegistration {
+public abstract class AbstractSchemaListenerRegistration extends AbstractListenerRegistration<SchemaSourceListener>
+        implements SchemaListenerRegistration {
     protected AbstractSchemaListenerRegistration(final SchemaSourceListener listener) {
         super(listener);
     }
index e059265d4d21d83b9095bc675076a22c94864867..b887c2d95a50150bd696aeb34a0eeafc0ec3ed06 100644 (file)
@@ -51,14 +51,16 @@ import org.slf4j.LoggerFactory;
 @Beta
 public abstract class AbstractSchemaRepository implements SchemaRepository, SchemaSourceRegistry {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractSchemaRepository.class);
-    private static final ExceptionMapper<SchemaSourceException> FETCH_MAPPER = ReflectiveExceptionMapper.create("Schema source fetch", SchemaSourceException.class);
+    private static final ExceptionMapper<SchemaSourceException> FETCH_MAPPER = ReflectiveExceptionMapper.create(
+            "Schema source fetch", SchemaSourceException.class);
 
     /*
      * Source identifier -> representation -> provider map. We usually are looking for
      * a specific representation of a source.
      */
     @GuardedBy("this")
-    private final Map<SourceIdentifier, ListMultimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>>> sources = new HashMap<>();
+    private final Map<SourceIdentifier, ListMultimap<Class<? extends SchemaSourceRepresentation>,
+            AbstractSchemaSourceRegistration<?>>> sources = new HashMap<>();
 
     /*
      * Schema source listeners.
@@ -66,34 +68,39 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
     @GuardedBy("this")
     private final Collection<SchemaListenerRegistration> listeners = new ArrayList<>();
 
-    private static <T extends SchemaSourceRepresentation> CheckedFuture<T, SchemaSourceException> fetchSource(final SourceIdentifier id, final Iterator<AbstractSchemaSourceRegistration<?>> it) {
+    private static <T extends SchemaSourceRepresentation> CheckedFuture<T, SchemaSourceException> fetchSource(
+            final SourceIdentifier id, final Iterator<AbstractSchemaSourceRegistration<?>> it) {
         final AbstractSchemaSourceRegistration<?> reg = it.next();
 
         @SuppressWarnings("unchecked")
-        final CheckedFuture<? extends T, SchemaSourceException> f = ((SchemaSourceProvider<T>)reg.getProvider()).getSource(id);
+        final CheckedFuture<? extends T, SchemaSourceException> f =
+            ((SchemaSourceProvider<T>)reg.getProvider()).getSource(id);
 
         return Futures.makeChecked(Futures.withFallback(f, new FutureFallback<T>() {
             @Override
-            public ListenableFuture<T> create(@Nonnull final Throwable t) throws SchemaSourceException {
-                LOG.debug("Failed to acquire source from {}", reg, t);
+            public ListenableFuture<T> create(@Nonnull final Throwable cause) throws SchemaSourceException {
+                LOG.debug("Failed to acquire source from {}", reg, cause);
 
                 if (it.hasNext()) {
                     return fetchSource(id, it);
                 }
 
-                throw new MissingSchemaSourceException("All available providers exhausted", id, t);
+                throw new MissingSchemaSourceException("All available providers exhausted", id, cause);
             }
         }), FETCH_MAPPER);
     }
 
     @Override
-    public <T extends SchemaSourceRepresentation> CheckedFuture<T, SchemaSourceException> getSchemaSource(@Nonnull final SourceIdentifier id, @Nonnull final Class<T> representation) {
+    public <T extends SchemaSourceRepresentation> CheckedFuture<T, SchemaSourceException> getSchemaSource(
+            @Nonnull final SourceIdentifier id, @Nonnull final Class<T> representation) {
         final ArrayList<AbstractSchemaSourceRegistration<?>> sortedSchemaSourceRegistrations;
 
         synchronized (this) {
-            final ListMultimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> srcs = sources.get(id);
+            final ListMultimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> srcs =
+                sources.get(id);
             if (srcs == null) {
-                return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("No providers registered for source" + id, id));
+                return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException(
+                            "No providers registered for source" + id, id));
             }
 
             sortedSchemaSourceRegistrations = Lists.newArrayList(srcs.get(representation));
@@ -104,8 +111,8 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
 
         final Iterator<AbstractSchemaSourceRegistration<?>> regs = sortedSchemaSourceRegistrations.iterator();
         if (!regs.hasNext()) {
-            return Futures.immediateFailedCheckedFuture(
-                    new MissingSchemaSourceException("No providers for source " + id + " representation " + representation + " available", id));
+            return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException(
+                        "No providers for source " + id + " representation " + representation + " available", id));
         }
 
         CheckedFuture<T, SchemaSourceException> fetchSourceFuture = fetchSource(id, regs);
@@ -119,6 +126,7 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
             }
 
             @Override
+            @SuppressWarnings("checkstyle:parameterName")
             public void onFailure(@Nonnull final Throwable t) {
                 LOG.trace("Skipping notification for encountered source {}, fetching source failed", id, t);
             }
@@ -127,14 +135,16 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
         return fetchSourceFuture;
     }
 
-    private synchronized <T extends SchemaSourceRepresentation> void addSource(final PotentialSchemaSource<T> source, final AbstractSchemaSourceRegistration<T> reg) {
-        ListMultimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> m = sources.get(source.getSourceIdentifier());
-        if (m == null) {
-            m = ArrayListMultimap.create();
-            sources.put(source.getSourceIdentifier(), m);
+    private synchronized <T extends SchemaSourceRepresentation> void addSource(final PotentialSchemaSource<T> source,
+            final AbstractSchemaSourceRegistration<T> reg) {
+        ListMultimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> map =
+            sources.get(source.getSourceIdentifier());
+        if (map == null) {
+            map = ArrayListMultimap.create();
+            sources.put(source.getSourceIdentifier(), map);
         }
 
-        m.put(source.getRepresentation(), reg);
+        map.put(source.getRepresentation(), reg);
 
         final Collection<PotentialSchemaSource<?>> reps = Collections.singleton(source);
         for (SchemaListenerRegistration l : listeners) {
@@ -142,8 +152,10 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
         }
     }
 
-    private synchronized <T extends SchemaSourceRepresentation> void removeSource(final PotentialSchemaSource<?> source, final SchemaSourceRegistration<?> reg) {
-        final Multimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> m = sources.get(source.getSourceIdentifier());
+    private synchronized <T extends SchemaSourceRepresentation> void removeSource(final PotentialSchemaSource<?> source,
+            final SchemaSourceRegistration<?> reg) {
+        final Multimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> m =
+            sources.get(source.getSourceIdentifier());
         if (m != null) {
             m.remove(source.getRepresentation(), reg);
 
@@ -158,7 +170,8 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
     }
 
     @Override
-    public <T extends SchemaSourceRepresentation> SchemaSourceRegistration<T> registerSchemaSource(final SchemaSourceProvider<? super T> provider, final PotentialSchemaSource<T> source) {
+    public <T extends SchemaSourceRepresentation> SchemaSourceRegistration<T> registerSchemaSource(
+            final SchemaSourceProvider<? super T> provider, final PotentialSchemaSource<T> source) {
         final PotentialSchemaSource<T> src = source.cachedReference();
 
         final AbstractSchemaSourceRegistration<T> ret = new AbstractSchemaSourceRegistration<T>(provider, src) {
@@ -183,7 +196,8 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche
 
         synchronized (this) {
             final Collection<PotentialSchemaSource<?>> col = new ArrayList<>();
-            for (Multimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> m : sources.values()) {
+            for (Multimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> m
+                    : sources.values()) {
                 for (AbstractSchemaSourceRegistration<?> r : m.values()) {
                     col.add(r.getInstance());
                 }
index b665f43c58d0c86fdd832444a561beeb5df4bdfc..4816e8f28a82118bb715b263c8456854294817c0 100644 (file)
@@ -26,12 +26,14 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
  *
  * @param <T> Cached schema source type.
  */
-public abstract class AbstractSchemaSourceCache<T extends SchemaSourceRepresentation> implements SchemaSourceListener, SchemaSourceProvider<T> {
+public abstract class AbstractSchemaSourceCache<T extends SchemaSourceRepresentation>
+        implements SchemaSourceListener, SchemaSourceProvider<T> {
     private final SchemaSourceRegistry consumer;
     private final Class<T> representation;
     private final Costs cost;
 
-    protected AbstractSchemaSourceCache(final SchemaSourceRegistry consumer, final Class<T> representation, final Costs cost) {
+    protected AbstractSchemaSourceCache(final SchemaSourceRegistry consumer, final Class<T> representation,
+            final Costs cost) {
         this.consumer = Preconditions.checkNotNull(consumer);
         this.representation = Preconditions.checkNotNull(representation);
         this.cost = Preconditions.checkNotNull(cost);
@@ -58,7 +60,8 @@ public abstract class AbstractSchemaSourceCache<T extends SchemaSourceRepresenta
      *         from the cache.
      */
     protected final SchemaSourceRegistration<T> register(final SourceIdentifier sourceIdentifier) {
-        final PotentialSchemaSource<T> src = PotentialSchemaSource.create(sourceIdentifier, representation, cost.getValue());
+        final PotentialSchemaSource<T> src = PotentialSchemaSource.create(sourceIdentifier, representation,
+                cost.getValue());
         return consumer.registerSchemaSource(this, src);
     }
 
index fd4c1acf7981b1a476a5b5f86bdaba34cd15c623..7c1c4ce65875874d27ba11e0904918a561c730e1 100644 (file)
@@ -15,10 +15,12 @@ import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
 
-public abstract class AbstractSchemaSourceRegistration<T extends SchemaSourceRepresentation> extends AbstractObjectRegistration<PotentialSchemaSource<T>> implements SchemaSourceRegistration<T> {
+public abstract class AbstractSchemaSourceRegistration<T extends SchemaSourceRepresentation>
+        extends AbstractObjectRegistration<PotentialSchemaSource<T>> implements SchemaSourceRegistration<T> {
     private final SchemaSourceProvider<?> provider;
 
-    protected AbstractSchemaSourceRegistration(final SchemaSourceProvider<?> provider, final PotentialSchemaSource<T> source) {
+    protected AbstractSchemaSourceRegistration(final SchemaSourceProvider<?> provider,
+            final PotentialSchemaSource<T> source) {
         super(source);
         this.provider = Preconditions.checkNotNull(provider);
     }
index 0eb7fc00138c7f556d0d8b0cd8c0bc6fab9f2095..9f8e798fc45291e5b4ba29adf71c2f9106d43528 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.model.repo.util;
 
-import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
@@ -46,21 +46,20 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Cache implementation that stores schemas in form of files under provided folder
+ * Cache implementation that stores schemas in form of files under provided folder.
  */
-public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentation> extends AbstractSchemaSourceCache<T> {
+public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentation>
+        extends AbstractSchemaSourceCache<T> {
 
     private static final Logger LOG = LoggerFactory.getLogger(FilesystemSchemaSourceCache.class);
 
     // Init storage adapters
-    private static final Map<Class<? extends SchemaSourceRepresentation>, StorageAdapter<? extends SchemaSourceRepresentation>> STORAGE_ADAPTERS =
-            Collections.singletonMap(
+    private static final Map<Class<? extends SchemaSourceRepresentation>,
+            StorageAdapter<? extends SchemaSourceRepresentation>> STORAGE_ADAPTERS = Collections.singletonMap(
                     YangTextSchemaSource.class, new YangTextSchemaStorageAdapter());
 
     private static final Pattern CACHED_FILE_PATTERN =
-            Pattern.compile(
-                    "(?<moduleName>[^@]+)" +
-                    "(@(?<revision>" + SourceIdentifier.REVISION_PATTERN + "))?");
+            Pattern.compile("(?<moduleName>[^@]+)" + "(@(?<revision>" + SourceIdentifier.REVISION_PATTERN + "))?");
 
     private final Class<T> representation;
     private final File storageDirectory;
@@ -74,7 +73,8 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
         checkSupportedRepresentation(representation);
 
         if (!storageDirectory.exists()) {
-            Preconditions.checkArgument(storageDirectory.mkdirs(), "Unable to create cache directory at %s", storageDirectory);
+            Preconditions.checkArgument(storageDirectory.mkdirs(), "Unable to create cache directory at %s",
+                    storageDirectory);
         }
         Preconditions.checkArgument(storageDirectory.exists());
         Preconditions.checkArgument(storageDirectory.isDirectory());
@@ -91,12 +91,13 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
             }
         }
 
-       throw new IllegalArgumentException(String.format(
-                "This cache does not support representation: %s, supported representations are: %s", representation, STORAGE_ADAPTERS.keySet()));
+        throw new IllegalArgumentException(String.format(
+                   "This cache does not support representation: %s, supported representations are: %s",
+                   representation, STORAGE_ADAPTERS.keySet()));
     }
 
     /**
-     * Restore cache state
+     * Restore cache state.
      */
     private void init() {
 
@@ -114,16 +115,19 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
     }
 
     @Override
-    public synchronized CheckedFuture<? extends T, SchemaSourceException> getSource(final SourceIdentifier sourceIdentifier) {
+    public synchronized CheckedFuture<? extends T, SchemaSourceException> getSource(
+            final SourceIdentifier sourceIdentifier) {
         final File file = sourceIdToFile(sourceIdentifier, storageDirectory);
         if (file.exists() && file.canRead()) {
             LOG.trace("Source {} found in cache as {}", sourceIdentifier, file);
-            final SchemaSourceRepresentation restored = STORAGE_ADAPTERS.get(representation).restore(sourceIdentifier, file);
+            final SchemaSourceRepresentation restored = STORAGE_ADAPTERS.get(representation).restore(sourceIdentifier,
+                    file);
             return Futures.immediateCheckedFuture(representation.cast(restored));
         }
 
         LOG.debug("Source {} not found in cache as {}", sourceIdentifier, file);
-        return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("Source not found", sourceIdentifier));
+        return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("Source not found",
+                    sourceIdentifier));
     }
 
     @Override
@@ -157,11 +161,12 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
 
     private static File findFileWithNewestRev(final SourceIdentifier identifier, final File storageDirectory) {
         File[] files = storageDirectory.listFiles(new FilenameFilter() {
-            final Pattern p = Pattern.compile(Pattern.quote(identifier.getName()) + "(\\.yang|@\\d\\d\\d\\d-\\d\\d-\\d\\d.yang)");
+            final Pattern pat = Pattern.compile(Pattern.quote(identifier.getName())
+                    + "(\\.yang|@\\d\\d\\d\\d-\\d\\d-\\d\\d.yang)");
 
             @Override
             public boolean accept(final File dir, final String name) {
-                return p.matcher(name).matches();
+                return pat.matcher(name).matches();
             }
         });
 
@@ -176,9 +181,9 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
         TreeMap<Date, File> map = new TreeMap<>();
         for (File sorted : files) {
             String fileName = sorted.getName();
-            Matcher m = SourceIdentifier.REVISION_PATTERN.matcher(fileName);
-            if (m.find()) {
-                String revStr = m.group();
+            Matcher match = SourceIdentifier.REVISION_PATTERN.matcher(fileName);
+            if (match.find()) {
+                String revStr = match.group();
                 /*
                  * FIXME: Consider using string for comparison.
                  * String is comparable, pattern check tested format
@@ -186,8 +191,8 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
                  */
                 DateFormat df = SimpleDateFormatUtil.getRevisionFormat();
                 try {
-                    Date d = df.parse(revStr);
-                    map.put(d, sorted);
+                    Date date = df.parse(revStr);
+                    map.put(date, sorted);
                 } catch (final ParseException e) {
                     LOG.info("Unable to parse date from yang file name {}", fileName);
                     map.put(new Date(0L), sorted);
@@ -206,7 +211,7 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
         STORAGE_ADAPTERS.get(representation).store(file, schemaRepresentation);
     }
 
-    private static abstract class StorageAdapter<T extends SchemaSourceRepresentation> {
+    private abstract static class StorageAdapter<T extends SchemaSourceRepresentation> {
 
         private final Class<T> supportedType;
 
@@ -216,10 +221,10 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
 
         void store(final File file, final SchemaSourceRepresentation schemaSourceRepresentation) {
             Preconditions.checkArgument(supportedType.isAssignableFrom(schemaSourceRepresentation.getClass()),
-                    "Cannot store schema source %s, this adapter only supports %s", schemaSourceRepresentation, supportedType);
+                    "Cannot store schema source %s, this adapter only supports %s", schemaSourceRepresentation,
+                    supportedType);
 
             storeAsType(file, supportedType.cast(schemaSourceRepresentation));
-
         }
 
         protected abstract void storeAsType(final File file, final T cast);
@@ -245,7 +250,8 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
             try (final InputStream castStream = cast.openStream()) {
                 Files.copy(castStream, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
             } catch (final IOException e) {
-                throw new IllegalStateException("Cannot store schema source " + cast.getIdentifier() + " to " + file, e);
+                throw new IllegalStateException("Cannot store schema source " + cast.getIdentifier() + " to " + file,
+                        e);
             }
         }
 
@@ -254,7 +260,7 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
             return new YangTextSchemaSource(sourceIdentifier) {
 
                 @Override
-                protected MoreObjects.ToStringHelper addToStringAttributes(final MoreObjects.ToStringHelper toStringHelper) {
+                protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
                     return toStringHelper;
                 }
 
@@ -280,7 +286,8 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
                 LOG.trace("Restoring cached file {} as {}", file, si.get());
                 cachedSchemas.add(si.get());
             } else {
-                LOG.debug("Skipping cached file {}, cannot restore source identifier from filename: {}, does not match {}", file, fileName, CACHED_FILE_PATTERN);
+                LOG.debug("Skipping cached file {}, cannot restore source identifier from filename: {},"
+                        + " does not match {}", file, fileName, CACHED_FILE_PATTERN);
             }
             return fileVisitResult;
         }
index 141cdb52bbe0c8a02806d1073d8aef6d099f090c..6f510457ff887d1ab51287d5951b4f32d1a83e93 100644 (file)
@@ -27,22 +27,26 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 
 @Beta
-public class InMemorySchemaSourceCache<T extends SchemaSourceRepresentation> extends AbstractSchemaSourceCache<T> implements AutoCloseable {
+public class InMemorySchemaSourceCache<T extends SchemaSourceRepresentation> extends AbstractSchemaSourceCache<T>
+        implements AutoCloseable {
     private final List<FinalizablePhantomReference<T>> regs = Collections.synchronizedList(new ArrayList<>());
     private final FinalizableReferenceQueue queue = new FinalizableReferenceQueue();
     private final Cache<SourceIdentifier, T> cache;
 
-    protected InMemorySchemaSourceCache(final SchemaSourceRegistry consumer, final Class<T> representation, final CacheBuilder<Object, Object> builder) {
+    protected InMemorySchemaSourceCache(final SchemaSourceRegistry consumer, final Class<T> representation,
+            final CacheBuilder<Object, Object> builder) {
         super(consumer, representation, Costs.IMMEDIATE);
         cache = builder.build();
     }
 
-    public static <R extends SchemaSourceRepresentation> InMemorySchemaSourceCache<R> createSoftCache(final SchemaSourceRegistry consumer, final Class<R> representation) {
+    public static <R extends SchemaSourceRepresentation> InMemorySchemaSourceCache<R> createSoftCache(
+            final SchemaSourceRegistry consumer, final Class<R> representation) {
         return new InMemorySchemaSourceCache<>(consumer, representation, CacheBuilder.newBuilder().softValues());
     }
 
     public static <R extends SchemaSourceRepresentation> InMemorySchemaSourceCache<R> createSoftCache(
-            final SchemaSourceRegistry consumer, final Class<R> representation, final long lifetime, final TimeUnit units) {
+            final SchemaSourceRegistry consumer, final Class<R> representation, final long lifetime,
+            final TimeUnit units) {
         return new InMemorySchemaSourceCache<>(consumer, representation, CacheBuilder.newBuilder().softValues()
                 .expireAfterAccess(lifetime, units));
     }
@@ -54,7 +58,8 @@ public class InMemorySchemaSourceCache<T extends SchemaSourceRepresentation> ext
             return Futures.immediateCheckedFuture(present);
         }
 
-        return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("Source not found", sourceIdentifier));
+        return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("Source not found",
+                    sourceIdentifier));
     }
 
     @Override
index 24a4826983cfb7f225f787f776483d7dfb7ede69..ec2df4571b314d0c2353125253757d9c7d9e1f40 100644 (file)
@@ -26,11 +26,14 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 
-public class SchemaSourceTransformer<S extends SchemaSourceRepresentation, D extends SchemaSourceRepresentation> implements SchemaSourceListener, SchemaSourceProvider<D> {
-    private static final ExceptionMapper<SchemaSourceException> MAPPER = ReflectiveExceptionMapper.create("Source transformation", SchemaSourceException.class);
+public class SchemaSourceTransformer<S extends SchemaSourceRepresentation, D extends SchemaSourceRepresentation>
+        implements SchemaSourceListener, SchemaSourceProvider<D> {
+    private static final ExceptionMapper<SchemaSourceException> MAPPER = ReflectiveExceptionMapper.create(
+            "Source transformation", SchemaSourceException.class);
 
     @FunctionalInterface
-    public interface Transformation<S extends SchemaSourceRepresentation, D extends SchemaSourceRepresentation> extends AsyncFunction<S, D> {
+    public interface Transformation<S extends SchemaSourceRepresentation, D extends SchemaSourceRepresentation>
+            extends AsyncFunction<S, D> {
         @Override
         CheckedFuture<D, SchemaSourceException> apply(@Nonnull final S input) throws Exception;
     }
index aabe4817245c473ce8098968cfe23df443f4aef4..87c112b50066087860cf8fab1b0a3806abace2f5 100644 (file)
@@ -53,16 +53,22 @@ public abstract class AbstractSchemaContext implements SchemaContext {
     protected static final Supplier<TreeSet<Module>> MODULE_SET_SUPPLIER = () -> new TreeSet<>(REVISION_COMPARATOR);
 
     /**
+     * Returns the ModuleIdentifier-to-YANG source mapping.
+     *
      * @return yang sources where key is ModuleIdentifier
      */
     protected abstract Map<ModuleIdentifier, String> getIdentifiersToSources();
 
     /**
+     * Returns the namespace-to-module mapping.
+     *
      * @return Map of modules where key is namespace
      */
     protected abstract SetMultimap<URI, Module> getNamespaceToModules();
 
     /**
+     * Returns the module name-to-module mapping.
+     *
      * @return Map of modules where key is name of module
      */
     protected abstract SetMultimap<String, Module> getNameToModules();
index cef542935edc1e227e42319756b5fbbc26e857a7..3116132b0220a71a3cef823a7c2bc1dbe94e53bb 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 /**
  * Utility class which provides factory methods to construct Constraints.
  *
+ * <p>
  * Provides static factory methods which constructs instances of
  * <ul>
  * <li>{@link LengthConstraint} - {@link #newLengthConstraint(Number, Number, Optional, Optional)}
@@ -31,12 +32,13 @@ public final class BaseConstraints {
     /**
      * Creates a {@link LengthConstraint}.
      *
+     * <p>
      * Creates an instance of Length constraint based on supplied parameters
      * with additional behaviour:
-     *
      * <ul>
      * <li>{@link LengthConstraint#getErrorAppTag()} returns <code>length-out-of-specified-bounds</code>
-     * <li>{@link LengthConstraint#getErrorMessage()} returns <code>The argument is out of bounds &lt;<i>min</i>, <i>max</i> &gt;</code>
+     * <li>{@link LengthConstraint#getErrorMessage()} returns <code>The argument is out of bounds
+     *     &lt;<i>min</i>, <i>max</i> &gt;</code>
      * </ul>
      *
      * @see LengthConstraint
@@ -47,20 +49,21 @@ public final class BaseConstraints {
      * @param reference Reference associated with constraint. {@link Optional#absent()} if reference is undefined.
      * @return Instance of {@link LengthConstraint}
      */
-    public static LengthConstraint newLengthConstraint(final Number min, final Number max, final Optional<String> description,
-            final Optional<String> reference) {
+    public static LengthConstraint newLengthConstraint(final Number min, final Number max,
+            final Optional<String> description, final Optional<String> reference) {
         return new LengthConstraintImpl(min, max, description, reference);
     }
 
     /**
      * Creates a {@link LengthConstraint}.
      *
+     * <p>
      * Creates an instance of Length constraint based on supplied parameters
      * with additional behaviour:
-     *
      * <ul>
      * <li>{@link LengthConstraint#getErrorAppTag()} returns <code>length-out-of-specified-bounds</code>
-     * <li>{@link LengthConstraint#getErrorMessage()} returns <code>The argument is out of bounds &lt;<i>min</i>, <i>max</i> &gt;</code>
+     * <li>{@link LengthConstraint#getErrorMessage()} returns <code>The argument is out of bounds
+     *     &lt;<i>min</i>, <i>max</i> &gt;</code>
      * </ul>
      *
      * @see LengthConstraint
@@ -82,15 +85,15 @@ public final class BaseConstraints {
     /**
      * Creates a {@link RangeConstraint}.
      *
+     * <p>
      * Creates an instance of Range constraint based on supplied parameters
      * with additional behaviour:
-     *
      * <ul>
      * <li>{@link RangeConstraint#getErrorAppTag()} returns <code>range-out-of-specified-bounds</code>
-     * <li>{@link RangeConstraint#getErrorMessage()} returns <code>The argument is out of bounds &lt;<i>min</i>, <i>max</i> &gt;</code>
+     * <li>{@link RangeConstraint#getErrorMessage()} returns <code>The argument is out of bounds
+     *     &lt;<i>min</i>, <i>max</i> &gt;</code>
      * </ul>
      *
-     *
      * @see RangeConstraint
      *
      * @param <T> Type of constraint
@@ -100,23 +103,23 @@ public final class BaseConstraints {
      * @param reference Reference associated with constraint. {@link Optional#absent()} if reference is undefined.
      * @return Instance of {@link RangeConstraint}
      */
-    public static <T extends Number> RangeConstraint newRangeConstraint(final T min, final T max, final Optional<String> description,
-            final Optional<String> reference) {
+    public static <T extends Number> RangeConstraint newRangeConstraint(final T min, final T max,
+            final Optional<String> description, final Optional<String> reference) {
         return new RangeConstraintImpl(min, max, description, reference);
     }
 
     /**
      * Creates a {@link RangeConstraint}.
      *
+     * <p>
      * Creates an instance of Range constraint based on supplied parameters
      * with additional behaviour:
-     *
      * <ul>
      * <li>{@link RangeConstraint#getErrorAppTag()} returns <code>range-out-of-specified-bounds</code>
-     * <li>{@link RangeConstraint#getErrorMessage()} returns <code>The argument is out of bounds &lt;<i>min</i>, <i>max</i> &gt;</code>
+     * <li>{@link RangeConstraint#getErrorMessage()} returns <code>The argument is out of bounds
+     *     &lt;<i>min</i>, <i>max</i> &gt;</code>
      * </ul>
      *
-     *
      * @see RangeConstraint
      *
      * @param <T> Type of constraint
@@ -137,9 +140,9 @@ public final class BaseConstraints {
     /**
      * Creates a {@link PatternConstraint}.
      *
+     * <p>
      * Creates an instance of Pattern constraint based on supplied parameters
      * with additional behaviour:
-     *
      * <ul>
      * <li>{@link PatternConstraint#getErrorAppTag()} returns
      * <code>invalid-regular-expression</code>
@@ -163,9 +166,9 @@ public final class BaseConstraints {
     /**
      * Creates a {@link PatternConstraint}.
      *
+     * <p>
      * Creates an instance of Pattern constraint based on supplied parameters
      * with additional behaviour:
-     *
      * <ul>
      * <li>{@link PatternConstraint#getErrorAppTag()} returns
      * <code>invalid-regular-expression</code>
index 27ca7a90b3be03ad87c0609336101b2505d9a016..e3a5284f8971eb990782be13e1440c08d837791b 100644 (file)
@@ -15,9 +15,7 @@ import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
 /**
- * Utility methods and constants to work with built-in YANG types
- *
- *
+ * Utility methods and constants to work with built-in YANG types.
  */
 public final class BaseTypes {
 
@@ -82,9 +80,10 @@ public final class BaseTypes {
      * Returns true if supplied type is representation of built-in YANG type as
      * per RFC 6020.
      *
+     * <p>
      * See package documentation for description of base types.
      *
-     * @param type
+     * @param type A type name
      * @return true if type is built-in YANG Types.
      */
     public static boolean isYangBuildInType(final String type) {
@@ -96,9 +95,10 @@ public final class BaseTypes {
      * Returns true if supplied type is representation of built-in YANG type as
      * per RFC 6020.
      *
+     * <p>
      * See package documentation for description of base types.
      *
-     * @param type
+     * @param type Type definition
      * @return true if type is built-in YANG Types.
      */
     public static boolean isYangBuildInType(final TypeDefinition<?> type) {
index 02b81df296394f04a7dbdd73cdba81340ca5db75..1c7543cf322d7e286cd00828b635ca54180d4334 100644 (file)
@@ -28,10 +28,8 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
  * DataNodeIterator is iterator, which walks down whole YANG DataNodeContainer
  * and walks all instances of {@link DataSchemaNode} present in subtree.
  *
- * Iterator instance is eagerly created, walking happens on initialization.
- *
- * Iteration is not ordered.
- *
+ * <p>
+ * Iterator instance is eagerly created, walking happens on initialization. Iteration is not ordered.
  */
 public class DataNodeIterator implements Iterator<DataSchemaNode> {
 
index 7e22270712e772c27e5b5163159fac6ecdd472c9..fecb62294524050219adff94592d89ab7781a5f8 100644 (file)
@@ -35,11 +35,12 @@ public final class EffectiveAugmentationSchema implements AugmentationSchema {
     private final Set<DataSchemaNode> realChildSchemas;
     private final Map<QName, DataSchemaNode> mappedChildSchemas;
 
-    public EffectiveAugmentationSchema(final AugmentationSchema augmentSchema, final Set<DataSchemaNode> realChildSchemas) {
+    public EffectiveAugmentationSchema(final AugmentationSchema augmentSchema,
+            final Set<DataSchemaNode> realChildSchemas) {
         this.delegate = Preconditions.checkNotNull(augmentSchema);
         this.realChildSchemas = ImmutableSet.copyOf(realChildSchemas);
 
-        final Map<QName, DataSchemaNode> m = new HashMap<>(realChildSchemas.size());;
+        final Map<QName, DataSchemaNode> m = new HashMap<>(realChildSchemas.size());
         for (DataSchemaNode realChildSchema : realChildSchemas) {
             m.put(realChildSchema.getQName(), realChildSchema);
         }
index 95016a1719f3e8ad372d2d3d00aece92c62c0af2..7c3c7abc951e2f08dd97edf79fdf0f7ee8880f56 100644 (file)
@@ -47,20 +47,19 @@ public final class FilteringSchemaContextProxy extends AbstractSchemaContext {
     private final SetMultimap<String, Module> nameToModules;
 
     /**
-     * Filters SchemaContext for yang modules
+     * Filters SchemaContext for yang modules.
      *
      * @param delegate original SchemaContext
-     * @param rootModules modules (yang schemas) to be available and all their dependencies (modules importing rootModule and whole chain of their imports)
+     * @param rootModules modules (yang schemas) to be available and all their dependencies (modules importing
+     *                    rootModule and whole chain of their imports)
      * @param additionalModuleIds (additional) modules (yang schemas) to be available and whole chain of their imports
-     *
      */
-    public FilteringSchemaContextProxy(final SchemaContext delegate, final Collection<ModuleId> rootModules, final Set<ModuleId> additionalModuleIds) {
-
-        Preconditions.checkArgument(rootModules!=null,"Base modules cannot be null.");
-        Preconditions.checkArgument(additionalModuleIds!=null,"Additional modules cannot be null.");
+    public FilteringSchemaContextProxy(final SchemaContext delegate, final Collection<ModuleId> rootModules,
+            final Set<ModuleId> additionalModuleIds) {
+        Preconditions.checkNotNull(rootModules, "Base modules cannot be null.");
+        Preconditions.checkNotNull(additionalModuleIds, "Additional modules cannot be null.");
 
         final Builder<Module> filteredModulesBuilder = new Builder<>();
-
         final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(new TreeMap<>(), MODULE_SET_SUPPLIER);
         final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(new TreeMap<>(), MODULE_SET_SUPPLIER);
 
@@ -79,7 +78,8 @@ public final class FilteringSchemaContextProxy extends AbstractSchemaContext {
         processForAdditionalModules(delegate, additionalModuleIds, filteredModulesBuilder);
 
         filteredModulesBuilder.addAll(getImportedModules(
-                Maps.uniqueIndex(delegate.getModules(), ModuleId.MODULE_TO_MODULE_ID::apply), filteredModulesBuilder.build(), nameToModulesAll));
+                Maps.uniqueIndex(delegate.getModules(), ModuleId.MODULE_TO_MODULE_ID::apply),
+                filteredModulesBuilder.build(), nameToModulesAll));
 
         /**
          * Instead of doing this on each invocation of getModules(), pre-compute
@@ -119,25 +119,29 @@ public final class FilteringSchemaContextProxy extends AbstractSchemaContext {
     }
 
     //dealing with imported module other than root and directly importing root
-    private static Collection<Module> getImportedModules(final Map<ModuleId, Module> allModules, final Set<Module> baseModules, final TreeMultimap<String, Module> nameToModulesAll) {
+    private static Collection<Module> getImportedModules(final Map<ModuleId, Module> allModules,
+            final Set<Module> baseModules, final TreeMultimap<String, Module> nameToModulesAll) {
 
         List<Module> relatedModules = Lists.newLinkedList();
 
         for (Module module : baseModules) {
             for (ModuleImport moduleImport : module.getImports()) {
 
-                Date revisionDate = moduleImport.getRevision() == null ?
-                        nameToModulesAll.get(moduleImport.getModuleName()).first().getRevision() : moduleImport.getRevision();
+                Date revisionDate = moduleImport.getRevision() == null
+                    ? nameToModulesAll.get(moduleImport.getModuleName()).first().getRevision()
+                    : moduleImport.getRevision();
 
                 ModuleId key = new ModuleId(moduleImport.getModuleName(),revisionDate);
                 Module importedModule = allModules.get(key);
 
-                Preconditions.checkArgument(importedModule != null,  "Invalid schema, cannot find imported module: %s from module: %s, %s, modules:%s", key, module.getQNameModule(), module.getName() );
+                Preconditions.checkArgument(importedModule != null,
+                        "Invalid schema, cannot find imported module: %s from module: %s, %s, modules:%s", key,
+                        module.getQNameModule(), module.getName());
                 relatedModules.add(importedModule);
 
                 //calling imports recursive
-                relatedModules.addAll(getImportedModules(allModules, Collections.singleton(importedModule), nameToModulesAll));
-
+                relatedModules.addAll(getImportedModules(allModules, Collections.singleton(importedModule),
+                            nameToModulesAll));
             }
         }
 
@@ -164,7 +168,7 @@ public final class FilteringSchemaContextProxy extends AbstractSchemaContext {
         return nameToModules;
     }
 
-    private static boolean selectAdditionalModules(final Module module, final Set<ModuleId> additionalModules){
+    private static boolean selectAdditionalModules(final Module module, final Set<ModuleId> additionalModules) {
         return additionalModules.contains(new ModuleId(module.getName(), module.getRevision()));
     }
 
@@ -209,7 +213,8 @@ public final class FilteringSchemaContextProxy extends AbstractSchemaContext {
         private final Date rev;
 
         public ModuleId(final String name, final Date rev) {
-            Preconditions.checkArgument(!Strings.isNullOrEmpty(name), "No module dependency name given. Nothing to do.");
+            Preconditions.checkArgument(!Strings.isNullOrEmpty(name),
+                    "No module dependency name given. Nothing to do.");
             this.name = name;
             this.rev = Preconditions.checkNotNull(rev, "No revision date given. Nothing to do.");
         }
@@ -226,15 +231,15 @@ public final class FilteringSchemaContextProxy extends AbstractSchemaContext {
             input.getRevision());
 
         @Override
-        public boolean equals(final Object o) {
-            if (this == o) {
+        public boolean equals(final Object obj) {
+            if (this == obj) {
                 return true;
             }
-            if (!(o instanceof ModuleId)) {
+            if (!(obj instanceof ModuleId)) {
                 return false;
             }
 
-            ModuleId moduleId = (ModuleId) o;
+            ModuleId moduleId = (ModuleId) obj;
             if (name != null ? !name.equals(moduleId.name) : moduleId.name != null) {
                 return false;
             }
index 5e8f43fd54aacbe983197d94341eec57e95338fb..feca985796763c8c220fd31cc764e660f788eba2 100644 (file)
@@ -15,7 +15,6 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 
 /**
  * {@link Immutable} implementation of {@link LengthConstraint}.
- *
  * Length constraint based on supplied parameters with additional behaviour:
  *
  * <ul>
@@ -23,7 +22,7 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
  * <code>length-out-of-specified-bounds</code>
  * <li>{@link LengthConstraint#getErrorMessage()} returns <code>The argument is
  * out of bounds &lt;<i>min</i>, <i>max</i> &gt;</code>
- * </ul
+ * </ul>
  */
 final class LengthConstraintImpl implements LengthConstraint, Immutable {
 
@@ -131,18 +130,12 @@ final class LengthConstraintImpl implements LengthConstraint, Immutable {
 
     @Override
     public String toString() {
-        return "LengthConstraintImpl [min=" +
-                min +
-                ", max=" +
-                max +
-                ", description=" +
-                description +
-                ", errorAppTag=" +
-                errorAppTag +
-                ", reference=" +
-                reference +
-                ", errorMessage=" +
-                errorMessage +
-                "]";
+        return "LengthConstraintImpl [min=" + min
+            + ", max=" + max
+            + ", description=" + description
+            + ", errorAppTag=" + errorAppTag
+            + ", reference=" + reference
+            + ", errorMessage=" + errorMessage
+            + "]";
     }
-}
\ No newline at end of file
+}
index cb59566eea26eaa3e99b553ffa2421f508176e6c..af5c18c82c6952ea9a051b35deb41edc30e92642 100644 (file)
@@ -74,24 +74,24 @@ public final class ModuleIdentifierImpl implements ModuleIdentifier {
 
     @Override
     public String toString() {
-        return "ModuleIdentifierImpl{" +
-                "name='" + name + '\'' +
-                ", namespace=" + getNamespace() +
-                ", revision=" + qnameModule.getFormattedRevision() +
-                ", semantic version=" + semVer +
-                '}';
+        return "ModuleIdentifierImpl{"
+            + "name='" + name + '\''
+            + ", namespace=" + getNamespace()
+            + ", revision=" + qnameModule.getFormattedRevision()
+            + ", semantic version=" + semVer
+            + '}';
     }
 
     @Override
-    public boolean equals(final Object o) {
-        if (this == o) {
+    public boolean equals(final Object obj) {
+        if (this == obj) {
             return true;
         }
-        if (!(o instanceof ModuleIdentifier)) {
+        if (!(obj instanceof ModuleIdentifier)) {
             return false;
         }
 
-        ModuleIdentifier other = (ModuleIdentifier) o;
+        ModuleIdentifier other = (ModuleIdentifier) obj;
 
         if (!name.equals(other.getName())) {
             return false;
index 3aafa348fa9a73b8cbd61cf0588b53087d279a2c..6dd0414cba915c978437d7280fecd626397c437b 100644 (file)
@@ -16,16 +16,15 @@ import org.opendaylight.yangtools.yang.model.api.type.ModifierKind;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 
 /**
- * {@link Immutable} implementation of {@link PatternConstraint}
+ * {@link Immutable} implementation of {@link PatternConstraint}.
  *
+ * <p>
  * Creates an instance of Range constraint based on supplied parameters with
  * additional behaviour:
- *
  * <ul>
  * <li>{@link PatternConstraint#getErrorAppTag()} returns
  * <code>invalid-regular-expression</code>
  * </ul>
- *
  */
 final class PatternConstraintImpl implements PatternConstraint, Immutable {
 
@@ -102,4 +101,4 @@ final class PatternConstraintImpl implements PatternConstraint, Immutable {
                 .add("reference", reference).add("errorAppTag", errorAppTag).add("errorMessage", errorMessage)
                 .add("modifier", modifier).toString();
     }
-}
\ No newline at end of file
+}
index 2b8d6321d539c85ea6c7385774c8536c9d6f946e..f1e76b14e7ffb438ebd5540b753d98b20cea01ac 100644 (file)
@@ -16,8 +16,8 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 /**
  * {@link Immutable} implementation of {@link RangeConstraint}.
  *
+ * <p>
  * Range constraint based on supplied parameters with additional behavior:
- *
  * <ul>
  * <li>{@link RangeConstraint#getErrorAppTag()} returns
  * <code>range-out-of-specified-bounds</code>
index 862d7e54591b2c6b96dac289cf9c83a959bdbb71..0991750e6ca55ec6f282c582cf8196f762f439c5 100644 (file)
@@ -17,7 +17,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Utilities for converting YANG XSD regexes into Java-compatible regexes
+ * Utilities for converting YANG XSD regexes into Java-compatible regexes.
  */
 public final class RegexUtils {
     private static final Logger LOG = LoggerFactory.getLogger(RegexUtils.class);
@@ -240,7 +240,7 @@ public final class RegexUtils {
     }
 
     /**
-     * Converts XSD regex to Java-compatible regex
+     * Converts XSD regex to Java-compatible regex.
      *
      * @param xsdRegex XSD regex pattern as it is defined in a YANG source
      * @return Java-compatible regex
@@ -301,7 +301,7 @@ public final class RegexUtils {
             try {
                 Pattern.compile(rawPattern);
                 return rawPattern;
-            } catch(final PatternSyntaxException ex) {
+            } catch (final PatternSyntaxException ex) {
                 LOG.debug("Invalid regex pattern syntax in: {}", rawPattern, ex);
                 if (ex.getMessage().contains("Unknown character script name")) {
                     rawPattern = fixUnknownScripts(ex.getMessage(), rawPattern);
@@ -327,4 +327,4 @@ public final class RegexUtils {
         }
         return result.toString();
     }
-}
\ No newline at end of file
+}
index 21d2d28113fcb2ef6d68c402a97a8f6a5fb800d0..8e390ba7bee45fbbe26bf9fa0b2f18c02884fb5c 100644 (file)
@@ -66,7 +66,7 @@ public final class SchemaContextUtil {
      * the end of the SchemaPath. If the DataSchemaNode is not present in the
      * Schema Context the method will return <code>null</code>. <br>
      * In case that Schema Context or Schema Path are not specified correctly
-     * (i.e. contains <code>null</code> values) the method will return
+     * (i.e. contains <code>null</code> values) the method will throw
      * IllegalArgumentException.
      *
      * @param context
@@ -75,8 +75,7 @@ public final class SchemaContextUtil {
      *            Schema Path to search for
      * @return SchemaNode from the end of the Schema Path or <code>null</code>
      *         if the Node is not present.
-     *
-     * @throws IllegalArgumentException
+     * @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");
@@ -119,7 +118,6 @@ public final class SchemaContextUtil {
      * @return Returns Data Schema Node for specified Schema Context for given
      *         Non-conditional Revision Aware XPath, or <code>null</code> if the
      *         DataSchemaNode is not present in Schema Context.
-     * @throws IllegalArgumentException
      */
     public static SchemaNode findDataSchemaNode(final SchemaContext context, final Module module,
             final RevisionAwareXPath nonCondXPath) {
@@ -177,8 +175,6 @@ public final class SchemaContextUtil {
      * @return DataSchemaNode if is present in specified Schema Context for
      *         given relative Revision Aware XPath, otherwise will return
      *         <code>null</code>.
-     *
-     * @throws IllegalArgumentException
      */
     public static SchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context, final Module module,
             final SchemaNode actualSchemaNode, final RevisionAwareXPath relativeXPath) {
@@ -214,8 +210,6 @@ public final class SchemaContextUtil {
      *            Schema Node
      * @return Yang Module for specified Schema Context and Schema Node, if Schema Node is NOT present, the method will
      *         return <code>null</code>
-     *
-     * @throws IllegalArgumentException
      */
     public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL!");
@@ -243,20 +237,21 @@ public final class SchemaContextUtil {
     }
 
     /**
-     * Returns NotificationDefinition from Schema Context
+     * Returns NotificationDefinition from Schema Context.
      *
      * @param schema SchemaContext in which lookup should be performed.
      * @param path Schema Path of notification
      * @return Notification schema or null, if notification is not present in schema context.
      */
     @Beta
-    @Nullable public static NotificationDefinition getNotificationSchema(@Nonnull final SchemaContext schema,
+    @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.");
         for (final NotificationDefinition potential : schema.getNotifications()) {
             if (path.equals(potential.getPath())) {
-               return potential;
+                return potential;
             }
         }
         return null;
@@ -270,7 +265,8 @@ 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,
+    @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.");
@@ -281,7 +277,7 @@ public final class SchemaContextUtil {
         final QName inOrOut = it.next();
         for (final RpcDefinition potential : schema.getOperations()) {
             if (rpcName.equals(potential.getQName())) {
-               return SchemaNodeUtils.getRpcDataSchema(potential, inOrOut);
+                return SchemaNodeUtils.getRpcDataSchema(potential, inOrOut);
             }
         }
         return null;
@@ -476,10 +472,12 @@ public final class SchemaContextUtil {
      *            XPath String
      * @return return a list of QName
      *
-     * @throws IllegalArgumentException
+     * @throws IllegalArgumentException if any arguments are null
+     *
      */
     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");
@@ -511,11 +509,11 @@ public final class SchemaContextUtil {
      * @param prefixedPathPart
      *            Prefixed Path Part string
      * @return QName from prefixed Path Part String.
-     *
-     * @throws IllegalArgumentException
+     * @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!");
@@ -556,11 +554,11 @@ public final class SchemaContextUtil {
      *            Module Prefix
      * @return Module for given prefix in specified Schema Context if is
      *         present, otherwise returns <code>null</code>
-     *
-     * @throws IllegalArgumentException
+     * @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");
@@ -579,6 +577,8 @@ public final class SchemaContextUtil {
     }
 
     /**
+     * Resolve a relative XPath into a set of QNames.
+     *
      * @param context
      *            Schema Context
      * @param module
@@ -588,11 +588,11 @@ public final class SchemaContextUtil {
      * @param actualSchemaNode
      *            actual schema node
      * @return list of QName
-     *
-     * @throws IllegalArgumentException
+     * @throws IllegalArgumentException if any arguments are null
      */
     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");
@@ -680,38 +680,16 @@ public final class SchemaContextUtil {
         return targetTypeDefinition;
     }
 
-    private static Module findParentModuleOfReferencingType(final SchemaContext schemaContext,
-            final SchemaNode schemaNode) {
-        Preconditions.checkArgument(schemaContext != null, "Schema Context reference cannot be NULL!");
-        Preconditions.checkArgument(schemaNode instanceof TypedSchemaNode, "Unsupported node %s", schemaNode);
-
-        TypeDefinition<?> nodeType = ((TypedSchemaNode) schemaNode).getType();
-        if (nodeType.getBaseType() != null) {
-            while (nodeType.getBaseType() != null) {
-                nodeType = nodeType.getBaseType();
-            }
-
-            final QNameModule typeDefModuleQname = nodeType.getQName().getModule();
-            return schemaContext.findModuleByNamespaceAndRevision(typeDefModuleQname.getNamespace(),
-                    typeDefModuleQname.getRevision());
-        }
-
-        return SchemaContextUtil.findParentModule(schemaContext, schemaNode);
-    }
-
     /**
-     * Returns base type for {@code typeDefinition} which belongs to module specified via {@code qName}. This handle
+     * Returns base type for {@code typeDefinition} which belongs to module specified via {@code qname}. This handle
      * the case when leafref type isn't specified as type substatement of leaf or leaf-list but is defined in other
      * module as typedef which is then imported to referenced module.
      *
+     * <p>
      * Because {@code typeDefinition} is definied via typedef statement, only absolute path is meaningful.
-     *
-     * @param typeDefinition
-     * @param schemaContext
-     * @param qName
      */
     public static TypeDefinition<?> getBaseTypeForLeafRef(final LeafrefTypeDefinition typeDefinition,
-            final SchemaContext schemaContext, final QName qName) {
+            final SchemaContext schemaContext, final QName qname) {
         final RevisionAwareXPath pathStatement = typeDefinition.getPathStatement();
         final RevisionAwareXPath strippedPathStatement = new RevisionAwareXPathImpl(
             stripConditionsFromXPathString(pathStatement), pathStatement.isAbsolute());
@@ -719,8 +697,8 @@ public final class SchemaContextUtil {
             return null;
         }
 
-        final Module parentModule = schemaContext.findModuleByNamespaceAndRevision(qName.getNamespace()
-            ,qName.getRevision());
+        final Module parentModule = schemaContext.findModuleByNamespaceAndRevision(qname.getNamespace(),
+                qname.getRevision());
         final DataSchemaNode dataSchemaNode = (DataSchemaNode) SchemaContextUtil.findDataSchemaNode(schemaContext,
             parentModule, strippedPathStatement);
         final TypeDefinition<?> targetTypeDefinition = typeDefinition(dataSchemaNode);
@@ -731,6 +709,25 @@ public final class SchemaContextUtil {
         return targetTypeDefinition;
     }
 
+    private static Module findParentModuleOfReferencingType(final SchemaContext schemaContext,
+            final SchemaNode schemaNode) {
+        Preconditions.checkArgument(schemaContext != null, "Schema Context reference cannot be NULL!");
+        Preconditions.checkArgument(schemaNode instanceof TypedSchemaNode, "Unsupported node %s", schemaNode);
+
+        TypeDefinition<?> nodeType = ((TypedSchemaNode) schemaNode).getType();
+        if (nodeType.getBaseType() != null) {
+            while (nodeType.getBaseType() != null) {
+                nodeType = nodeType.getBaseType();
+            }
+
+            final QNameModule typeDefModuleQname = nodeType.getQName().getModule();
+            return schemaContext.findModuleByNamespaceAndRevision(typeDefModuleQname.getNamespace(),
+                    typeDefModuleQname.getRevision());
+        }
+
+        return SchemaContextUtil.findParentModule(schemaContext, schemaNode);
+    }
+
     private static final Pattern STRIP_PATTERN = Pattern.compile("\\[[^\\[\\]]*\\]");
 
     /**
@@ -739,7 +736,6 @@ public final class SchemaContextUtil {
      * @param pathStatement
      *            xPath to target node
      * @return string representation of xPath without conditions
-     *
      */
     @VisibleForTesting
     static String stripConditionsFromXPathString(final RevisionAwareXPath pathStatement) {
index 5121da0ec7d75ce02d776572b0567ce16903b1fd..1ad31d4812c761af2b6ea8807c452af912f42800 100644 (file)
@@ -43,22 +43,24 @@ public class SchemaNodeUtils {
     }
 
     /**
-     * Returns RPC input or output schema based on supplied QName
+     * Returns RPC input or output schema based on supplied QName.
      *
      * @param rpc RPC Definition
      * @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) {
+    @Nullable public static ContainerSchemaNode getRpcDataSchema(@Nonnull final RpcDefinition rpc,
+            @Nonnull final QName qname) {
         Preconditions.checkNotNull(rpc, "Rpc Schema must not be null");
         Preconditions.checkNotNull(qname,"QName must not be null");
         switch (qname.getLocalName()) {
-           case "input":
-               return rpc.getInput();
-           case "output":
-               return rpc.getOutput();
-           default:
-               throw new IllegalArgumentException("Supplied qname " + qname + " does not represent rpc input or output.");
-           }
-       }
+            case "input":
+                return rpc.getInput();
+            case "output":
+                return rpc.getOutput();
+            default:
+                throw new IllegalArgumentException("Supplied qname " + qname
+                        + " does not represent rpc input or output.");
+        }
+    }
 }
index 5cfd9960edc5c1ebf9af718472d4a35e5db4fa82..67b10767bd0e79ae02bc5909f56284b54f84df89 100644 (file)
@@ -39,6 +39,7 @@ public abstract class UnresolvedNumber extends Number implements Immutable {
             return MAX;
         }
     };
+
     private static final UnresolvedNumber MIN = new UnresolvedNumber() {
         private static final long serialVersionUID = 1L;
 
@@ -96,6 +97,7 @@ public abstract class UnresolvedNumber extends Number implements Immutable {
     }
 
     public abstract Number resolveLength(List<LengthConstraint> constraints);
+
     public abstract Number resolveRange(List<RangeConstraint> constraints);
 
     @Override
index f28e62fa7e57e0c91a6b1439d491613f4277cab4..c195878b710b892f918641e14c2ebac031daf5ff 100644 (file)
@@ -25,7 +25,8 @@ abstract class AbstractDerivedType<T extends TypeDefinition<T>> extends Abstract
     private final String units;
 
     AbstractDerivedType(final T baseType, final SchemaPath path, final Object defaultValue, final String description,
-            final String reference, final Status status, final String units, final Collection<UnknownSchemaNode> unknownSchemNodes) {
+            final String reference, final Status status, final String units,
+            final Collection<UnknownSchemaNode> unknownSchemNodes) {
         super(path, unknownSchemNodes);
         this.baseType = Preconditions.checkNotNull(baseType);
         this.status = Preconditions.checkNotNull(status);
@@ -42,8 +43,6 @@ abstract class AbstractDerivedType<T extends TypeDefinition<T>> extends Abstract
 
     /**
      * Return the stored base type. Unlike {@link #getBaseType()}, this method returns the underlying restricted type.
-     *
-     * @return
      */
     final T baseType() {
         return baseType;
index ddcb015c036f0b640374f1b68be974d5d8dda213..4d0db4a29f7f1abaab6f7227180508f64ff3a3a9 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
-abstract class AbstractIntegerBaseType extends AbstractRangedBaseType<IntegerTypeDefinition> implements IntegerTypeDefinition {
+abstract class AbstractIntegerBaseType extends AbstractRangedBaseType<IntegerTypeDefinition>
+        implements IntegerTypeDefinition {
     AbstractIntegerBaseType(final QName qname, final Number minValue, final Number maxValue) {
         super(qname, minValue, maxValue);
     }
index 8020ef584fe43d0676022586c9f2c37225353dcf..d40fdd657715e98087bce98eb822a7174e1d66a6 100644 (file)
@@ -18,7 +18,8 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 abstract class AbstractRestrictedType<T extends TypeDefinition<T>> extends AbstractTypeDefinition<T> {
     private final T baseType;
 
-    AbstractRestrictedType(final T baseType, final SchemaPath path, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
+    AbstractRestrictedType(final T baseType, final SchemaPath path,
+            final Collection<UnknownSchemaNode> unknownSchemaNodes) {
         super(path, unknownSchemaNodes);
         this.baseType = Preconditions.checkNotNull(baseType);
     }
index ad0c5b62ee88d3c7c7443bafaafd478071db3530..22d185f30c59d021385563b7468d6104baa5b7f9 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
 
 final class BaseDecimalType extends AbstractRangedBaseType<DecimalTypeDefinition> implements DecimalTypeDefinition {
     private static final List<List<RangeConstraint>> IMPLICIT_RANGE_STATEMENTS;
+
     static {
         final Builder<List<RangeConstraint>> b = ImmutableList.builder();
         b.add(createRangeConstraint("-922337203685477580.8", "922337203685477580.7"));
@@ -55,8 +56,8 @@ final class BaseDecimalType extends AbstractRangedBaseType<DecimalTypeDefinition
 
     private final Integer fractionDigits;
 
-    BaseDecimalType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes, final Integer fractionDigits,
-        final List<RangeConstraint> rangeConstraints) {
+    BaseDecimalType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes,
+            final Integer fractionDigits, final List<RangeConstraint> rangeConstraints) {
         super(path, unknownSchemaNodes, rangeConstraints);
         this.fractionDigits = fractionDigits;
     }
index b17d2b9f5a66b8efe2a00fdf06fda146a6ad4845..c4e9ade89f3f64385e84883ecc29b575add67f74 100644 (file)
@@ -18,7 +18,8 @@ import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 final class BaseEnumerationType extends AbstractBaseType<EnumTypeDefinition> implements EnumTypeDefinition {
     private final List<EnumPair> values;
 
-    BaseEnumerationType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes, final Collection<EnumPair> values) {
+    BaseEnumerationType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes,
+            final Collection<EnumPair> values) {
         super(path, unknownSchemaNodes);
         this.values = ImmutableList.copyOf(values);
     }
index b2628f31294ff91e86b44c0fd0a9b3dc2c76b194..44064abaea8d2d1fb03f4cd19650e8fc45d07f3f 100644 (file)
@@ -15,7 +15,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 
-final class BaseIdentityrefType extends AbstractBaseType<IdentityrefTypeDefinition> implements IdentityrefTypeDefinition {
+final class BaseIdentityrefType extends AbstractBaseType<IdentityrefTypeDefinition>
+        implements IdentityrefTypeDefinition {
     private final IdentitySchemaNode identity;
     private final Set<IdentitySchemaNode> identities;
 
index a59e637334839ba8a0b78a0ae7346c36914af7e7..a6f64a70ccabb76518f6894a25effe65f02acba7 100644 (file)
@@ -23,7 +23,9 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  * Utility access methods for creating and accessing YANG base type definitions. YANG types come in two basic variants,
  * depending on whether they fully define their base instance or model input is required to fully-form the type.
  *
- * The following types have their base type fully specified and are exposed as appropriate TypeDefinition sub-interfaces:
+ * <p>
+ * The following types have their base type fully specified and are exposed as appropriate TypeDefinition
+ * sub-interfaces:
  * <ul>
  *     <li>boolean</li>
  *     <li>empty</li>
@@ -33,6 +35,7 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  *     <li>uint{8,16,32,64}</li>
  * </ul>
  *
+ * <p>
  * The following types require additional specification in the model and are exposed by means of a specialized
  * {@link TypeBuilder}s for each type:
  * <ul>
index bbbe6ba8a8a2a4a699e937d235d5bd09a92fb574..0b68bc62e3ce34513e4aea0a0661f26aaa91a644 100644 (file)
@@ -18,7 +18,8 @@ import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 final class BaseUnionType extends AbstractBaseType<UnionTypeDefinition> implements UnionTypeDefinition {
     private final List<TypeDefinition<?>> types;
 
-    BaseUnionType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes, final Collection<TypeDefinition<?>> types) {
+    BaseUnionType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes,
+            final Collection<TypeDefinition<?>> types) {
         super(path, unknownSchemaNodes);
         this.types = ImmutableList.copyOf(types);
     }
index 362f2b8681cfa47d6e8e87a0fd8cde7073aa4a1c..c4ac7be534058cabe06aae53e52e17861004f9da 100644 (file)
@@ -43,8 +43,8 @@ public final class BitsTypeBuilder extends AbstractRestrictedTypeBuilder<BitsTyp
         for (Bit baseTypeBit : getBaseType().getBits()) {
             if (item.getName().equals(baseTypeBit.getName())) {
                 if (item.getPosition() != baseTypeBit.getPosition()) {
-                    throw new InvalidBitDefinitionException(item, "Position of bit '%s' must be the same as the " +
-                            "position of corresponding bit in the base bits type %s.", item.getName(),
+                    throw new InvalidBitDefinitionException(item, "Position of bit '%s' must be the same as the "
+                            "position of corresponding bit in the base bits type %s.", item.getName(),
                             getBaseType().getQName());
                 }
                 isASubsetOfBaseBits = true;
index 70f9572fbc93d9a940f93df946e5219b2b630fd6..83af46d85f9e229465c71b57d8c5bbc7670efc28 100644 (file)
@@ -41,6 +41,7 @@ public final class CompatUtils {
      * declaration has not restricted the type further -- which is not something available via
      * {@link TypeDefinition#getBaseType()}.
      *
+     * <p>
      * Here are the possible scenarios:
      *
      * <pre>
@@ -80,6 +81,7 @@ public final class CompatUtils {
      * </pre>
      * The leaf type's schema path will not match the schema path of the leaf. We do NOT want to strip it.
      *
+     * <p>
      * The situation is different for types which do not have a default instantiation in YANG: leafref, enumeration,
      * identityref, decimal64, bits and union. If these types are defined within this leaf's statement, a base type
      * will be instantiated. If the leaf defines a default statement, this base type will be visible via getBaseType().
@@ -170,8 +172,8 @@ public final class CompatUtils {
         final List<PatternConstraint> patterns = type.getPatternConstraints();
         final List<LengthConstraint> lengths = type.getLengthConstraints();
 
-        if ((patterns.isEmpty() || patterns.equals(base.getPatternConstraints())) &&
-                (lengths.isEmpty() || lengths.equals(base.getLengthConstraints()))) {
+        if ((patterns.isEmpty() || patterns.equals(base.getPatternConstraints()))
+                && (lengths.isEmpty() || lengths.equals(base.getLengthConstraints()))) {
             return base;
         }
 
index cacc6cff715255607aa766098b704e48b6454bff..b9ac813d606fb86ceff31696bc99dcddf0c98f90 100644 (file)
@@ -67,145 +67,158 @@ public final class ConcreteTypes {
         }
     }
 
-    private static ConcreteTypeBuilder<BinaryTypeDefinition> concreteBinaryBuilder(@Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
+    private static ConcreteTypeBuilder<BinaryTypeDefinition> concreteBinaryBuilder(
+            @Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
         return new ConcreteTypeBuilder<BinaryTypeDefinition>(baseType, path) {
             @Nonnull
             @Override
             public BinaryTypeDefinition buildType() {
-                return new DerivedBinaryType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedBinaryType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<BitsTypeDefinition> concreteBitsBuilder(final BitsTypeDefinition baseType, final SchemaPath path) {
+    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(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedBitsType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<BooleanTypeDefinition> concreteBooleanBuilder(@Nonnull final BooleanTypeDefinition baseType, @Nonnull final SchemaPath path) {
+    private static ConcreteTypeBuilder<BooleanTypeDefinition> concreteBooleanBuilder(
+            @Nonnull final BooleanTypeDefinition baseType, @Nonnull final SchemaPath path) {
         return new ConcreteTypeBuilder<BooleanTypeDefinition>(baseType, path) {
             @Nonnull
             @Override
             public BooleanTypeDefinition buildType() {
-                return new DerivedBooleanType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedBooleanType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<DecimalTypeDefinition> concreteDecimalBuilder(final DecimalTypeDefinition baseType, final SchemaPath path) {
+    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(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedDecimalType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<EmptyTypeDefinition> concreteEmptyBuilder(final EmptyTypeDefinition baseType, final SchemaPath path) {
+    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(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedEmptyType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<EnumTypeDefinition> concreteEnumerationBuilder(final EnumTypeDefinition baseType, final SchemaPath path) {
+    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(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedEnumerationType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<IdentityrefTypeDefinition> concreteIdentityrefBuilder(final IdentityrefTypeDefinition baseType, final SchemaPath path) {
+    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(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedIdentityrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<InstanceIdentifierTypeDefinition> concreteInstanceIdentifierBuilder(final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
+    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(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes(), baseType.requireInstance());
+                return new DerivedInstanceIdentifierType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes(), baseType.requireInstance());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<IntegerTypeDefinition> concreteIntegerBuilder(final IntegerTypeDefinition baseType, final SchemaPath path) {
+    private static ConcreteTypeBuilder<IntegerTypeDefinition> concreteIntegerBuilder(
+            final IntegerTypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<IntegerTypeDefinition>(baseType, path) {
             @Nonnull
             @Override
             public IntegerTypeDefinition buildType() {
-                return new DerivedIntegerType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedIntegerType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<LeafrefTypeDefinition> concreteLeafrefBuilder(final LeafrefTypeDefinition baseType, final SchemaPath path) {
+    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(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedLeafrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<StringTypeDefinition> concreteStringBuilder(final StringTypeDefinition baseType, final SchemaPath path) {
+    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(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedStringType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<UnionTypeDefinition> concreteUnionBuilder(final UnionTypeDefinition baseType, final SchemaPath path) {
+    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(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedUnionType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static ConcreteTypeBuilder<UnsignedIntegerTypeDefinition> concreteUnsignedBuilder(final UnsignedIntegerTypeDefinition baseType, final SchemaPath path) {
+    private static ConcreteTypeBuilder<UnsignedIntegerTypeDefinition> concreteUnsignedBuilder(
+            final UnsignedIntegerTypeDefinition baseType, final SchemaPath path) {
         return new ConcreteTypeBuilder<UnsignedIntegerTypeDefinition>(baseType, path) {
             @Nonnull
             @Override
             public UnsignedIntegerTypeDefinition buildType() {
-                return new DerivedUnsignedType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedUnsignedType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
index 7aedf3344e241717cb0e6d112a25cb9742ed255e..919c1c3fa67a69ad445bc114b653998140a42012 100644 (file)
@@ -15,7 +15,8 @@ import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 
-final class DerivedIdentityrefType extends AbstractDerivedType<IdentityrefTypeDefinition> implements IdentityrefTypeDefinition {
+final class DerivedIdentityrefType extends AbstractDerivedType<IdentityrefTypeDefinition>
+        implements IdentityrefTypeDefinition {
     DerivedIdentityrefType(final IdentityrefTypeDefinition baseType, final SchemaPath path, final Object defaultValue,
         final String description, final String reference, final Status status, final String units,
         final Collection<UnknownSchemaNode> unknownSchemaNodes) {
index f63f84fab75a59adfb99fba6da5c17d8e6158b85..b646c22394e42645ed7a1c14833ed09c5c72516c 100644 (file)
@@ -13,12 +13,14 @@ import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
 
-final class DerivedInstanceIdentifierType extends AbstractDerivedType<InstanceIdentifierTypeDefinition> implements InstanceIdentifierTypeDefinition {
+final class DerivedInstanceIdentifierType extends AbstractDerivedType<InstanceIdentifierTypeDefinition>
+        implements InstanceIdentifierTypeDefinition {
     private final boolean requireInstance;
 
-    DerivedInstanceIdentifierType(final InstanceIdentifierTypeDefinition baseType, final SchemaPath path, final Object defaultValue,
-        final String description, final String reference, final Status status, final String units,
-        final Collection<UnknownSchemaNode> unknownSchemaNodes,  final boolean requireInstance) {
+    DerivedInstanceIdentifierType(final InstanceIdentifierTypeDefinition baseType, final SchemaPath path,
+            final Object defaultValue, final String description, final String reference, final Status status,
+            final String units, final Collection<UnknownSchemaNode> unknownSchemaNodes,
+            final boolean requireInstance) {
         super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
         this.requireInstance = requireInstance;
     }
index ef4998a81ec51f946a349d9530b6fcc0eaeba959..ebe9b959a47d356a7d117b260ca705b834949e50 100644 (file)
@@ -17,8 +17,9 @@ import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 
 final class DerivedIntegerType extends AbstractDerivedType<IntegerTypeDefinition> implements IntegerTypeDefinition {
-    DerivedIntegerType(final IntegerTypeDefinition baseType, final SchemaPath path, final Object defaultValue, final String description,
-            final String reference, final Status status, final String units, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
+    DerivedIntegerType(final IntegerTypeDefinition baseType, final SchemaPath path, final Object defaultValue,
+            final String description, final String reference, final Status status, final String units,
+            final Collection<UnknownSchemaNode> unknownSchemaNodes) {
         super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
     }
 
index 31802bcf6dbf85f46ff2cafbff4939c3edb368fe..13171011f5e6dbee281e2eff5cc84223e188d5d5 100644 (file)
@@ -17,8 +17,9 @@ import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 
 final class DerivedStringType extends AbstractDerivedType<StringTypeDefinition> implements StringTypeDefinition {
-    DerivedStringType(final StringTypeDefinition baseType, final SchemaPath path, final Object defaultValue, final String description,
-            final String reference, final Status status, final String units, final Collection<UnknownSchemaNode> unknownSchemaNodes) {
+    DerivedStringType(final StringTypeDefinition baseType, final SchemaPath path, final Object defaultValue,
+            final String description, final String reference, final Status status, final String units,
+            final Collection<UnknownSchemaNode> unknownSchemaNodes) {
         super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
     }
 
index a843a93eaab13e580e775dc14b36c8fc51ee10fa..e946992c843af96af77ca704f7253aa2b68008d1 100644 (file)
@@ -31,8 +31,8 @@ public abstract class DerivedTypeBuilder<T extends TypeDefinition<T>> extends Ty
     DerivedTypeBuilder(final T baseType, final SchemaPath path) {
         super(Preconditions.checkNotNull(baseType), path);
 
-        Preconditions.checkArgument(baseType instanceof AbstractBaseType ||
-            baseType instanceof AbstractDerivedType || baseType instanceof AbstractRestrictedType,
+        Preconditions.checkArgument(baseType instanceof AbstractBaseType
+                || baseType instanceof AbstractDerivedType || baseType instanceof AbstractRestrictedType,
             "Derived type can be built only from a base, derived, or restricted type, not %s", baseType);
 
         // http://tools.ietf.org/html/rfc6020#section-7.3.4
index 31d80d83239b0706eef02d0895ec9a19c8713313..2c762c113a0da1fadff647fbbc95f7dd3d1fc207 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  * YANG defines 'derived type' as a type created through a 'typedef' statement. These types are exposed in the
  * hierarchical namespace and can be looked up.
  *
+ * <p>
  * A derived type can redefine the default value, description, status and reference of a particular type definition.
  * It can only refine the units attribute, as that attribute is tied to the semantics of the value. The default value,
  * and units attributes are inherited from the super (base or restricted) type, others are left undefined if not
@@ -169,132 +170,145 @@ public final class DerivedTypes {
         return BaseTypes.isUint64(BaseTypes.baseTypeOf(type));
     }
 
-    private static DerivedTypeBuilder<BinaryTypeDefinition> derivedBinaryBuilder(@Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
+    private static DerivedTypeBuilder<BinaryTypeDefinition> derivedBinaryBuilder(
+            @Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
         return new DerivedTypeBuilder<BinaryTypeDefinition>(baseType, path) {
             @Override
             public BinaryTypeDefinition build() {
-                return new DerivedBinaryType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedBinaryType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<BitsTypeDefinition> derivedBitsBuilder(final BitsTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<BitsTypeDefinition> derivedBitsBuilder(final BitsTypeDefinition baseType,
+            final SchemaPath path) {
         return new DerivedTypeBuilder<BitsTypeDefinition>(baseType, path) {
             @Override
             public BitsTypeDefinition build() {
-                return new DerivedBitsType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedBitsType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<BooleanTypeDefinition> derivedBooleanBuilder(@Nonnull final BooleanTypeDefinition baseType, @Nonnull final SchemaPath path) {
+    private static DerivedTypeBuilder<BooleanTypeDefinition> derivedBooleanBuilder(
+            @Nonnull final BooleanTypeDefinition baseType, @Nonnull final SchemaPath path) {
         return new DerivedTypeBuilder<BooleanTypeDefinition>(baseType, path) {
             @Override
             public BooleanTypeDefinition build() {
-                return new DerivedBooleanType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedBooleanType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<DecimalTypeDefinition> derivedDecimalBuilder(final DecimalTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<DecimalTypeDefinition> derivedDecimalBuilder(final DecimalTypeDefinition baseType,
+            final SchemaPath path) {
         return new DerivedTypeBuilder<DecimalTypeDefinition>(baseType, path) {
             @Override
             public DecimalTypeDefinition build() {
-                return new DerivedDecimalType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedDecimalType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<EmptyTypeDefinition> derivedEmptyBuilder(final EmptyTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<EmptyTypeDefinition> derivedEmptyBuilder(final EmptyTypeDefinition baseType,
+            final SchemaPath path) {
         return new DerivedTypeBuilder<EmptyTypeDefinition>(baseType, path) {
             @Override
             public EmptyTypeDefinition build() {
-                return new DerivedEmptyType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedEmptyType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<EnumTypeDefinition> derivedEnumerationBuilder(final EnumTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<EnumTypeDefinition> derivedEnumerationBuilder(final EnumTypeDefinition baseType,
+            final SchemaPath path) {
         return new DerivedTypeBuilder<EnumTypeDefinition>(baseType, path) {
             @Override
             public EnumTypeDefinition build() {
-                return new DerivedEnumerationType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedEnumerationType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<IdentityrefTypeDefinition> derivedIdentityrefBuilder(final IdentityrefTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<IdentityrefTypeDefinition> derivedIdentityrefBuilder(
+            final IdentityrefTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<IdentityrefTypeDefinition>(baseType, path) {
             @Override
             public IdentityrefTypeDefinition build() {
-                return new DerivedIdentityrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedIdentityrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<InstanceIdentifierTypeDefinition> derivedInstanceIdentifierBuilder(final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<InstanceIdentifierTypeDefinition> derivedInstanceIdentifierBuilder(
+            final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<InstanceIdentifierTypeDefinition>(baseType, path) {
             @Override
             public InstanceIdentifierTypeDefinition build() {
-                return new DerivedInstanceIdentifierType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes(), baseType.requireInstance());
+                return new DerivedInstanceIdentifierType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes(), baseType.requireInstance());
             }
         };
     }
 
-    private static DerivedTypeBuilder<IntegerTypeDefinition> derivedIntegerBuilder(final IntegerTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<IntegerTypeDefinition> derivedIntegerBuilder(final IntegerTypeDefinition baseType,
+            final SchemaPath path) {
         return new DerivedTypeBuilder<IntegerTypeDefinition>(baseType, path) {
             @Override
             public IntegerTypeDefinition build() {
-                return new DerivedIntegerType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedIntegerType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<LeafrefTypeDefinition> derivedLeafrefBuilder(final LeafrefTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<LeafrefTypeDefinition> derivedLeafrefBuilder(final LeafrefTypeDefinition baseType,
+            final SchemaPath path) {
         return new DerivedTypeBuilder<LeafrefTypeDefinition>(baseType, path) {
             @Override
             public LeafrefTypeDefinition build() {
-                return new DerivedLeafrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedLeafrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<StringTypeDefinition> derivedStringBuilder(final StringTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<StringTypeDefinition> derivedStringBuilder(final StringTypeDefinition baseType,
+            final SchemaPath path) {
         return new DerivedTypeBuilder<StringTypeDefinition>(baseType, path) {
             @Override
             public StringTypeDefinition build() {
-                return new DerivedStringType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedStringType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<UnionTypeDefinition> derivedUnionBuilder(final UnionTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<UnionTypeDefinition> derivedUnionBuilder(final UnionTypeDefinition baseType,
+            final SchemaPath path) {
         return new DerivedTypeBuilder<UnionTypeDefinition>(baseType, path) {
             @Override
             public DerivedUnionType build() {
-                return new DerivedUnionType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedUnionType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
 
-    private static DerivedTypeBuilder<UnsignedIntegerTypeDefinition> derivedUnsignedBuilder(final UnsignedIntegerTypeDefinition baseType, final SchemaPath path) {
+    private static DerivedTypeBuilder<UnsignedIntegerTypeDefinition> derivedUnsignedBuilder(
+            final UnsignedIntegerTypeDefinition baseType, final SchemaPath path) {
         return new DerivedTypeBuilder<UnsignedIntegerTypeDefinition>(baseType, path) {
             @Override
             public UnsignedIntegerTypeDefinition build() {
-                return new DerivedUnsignedType(getBaseType(), getPath(), getDefaultValue(), getDescription(), getReference(),
-                    getStatus(), getUnits(), getUnknownSchemaNodes());
+                return new DerivedUnsignedType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
+                        getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
             }
         };
     }
index c0d368ed23617a967071d78ed257566fd7cadbce..03d077c5ce6de082caa076ff954dc7c28a2518db 100644 (file)
@@ -43,8 +43,8 @@ public final class EnumerationTypeBuilder extends AbstractRestrictedTypeBuilder<
         for (EnumPair baseTypeEnumPair : getBaseType().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(),
+                    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());
                 }
                 isASubsetOfBaseEnums = true;
index 8143a24448cde5d71d85d353d9d107f9ebb0741e..e6b2e8104176ffec92d0cf437d357523cb525683 100644 (file)
@@ -11,9 +11,11 @@ import com.google.common.base.Preconditions;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
 
-public final class InstanceIdentifierTypeBuilder extends RequireInstanceRestrictedTypeBuilder<InstanceIdentifierTypeDefinition> {
+public final class InstanceIdentifierTypeBuilder
+        extends RequireInstanceRestrictedTypeBuilder<InstanceIdentifierTypeDefinition> {
 
-    InstanceIdentifierTypeBuilder(final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
+    InstanceIdentifierTypeBuilder(final InstanceIdentifierTypeDefinition baseType,
+            final SchemaPath path) {
         super(Preconditions.checkNotNull(baseType), path);
     }
 
@@ -23,6 +25,7 @@ public final class InstanceIdentifierTypeBuilder extends RequireInstanceRestrict
             return getBaseType();
         }
 
-        return new RestrictedInstanceIdentifierType(getBaseType(), getPath(), getUnknownSchemaNodes(), getRequireInstance());
+        return new RestrictedInstanceIdentifierType(getBaseType(), getPath(), getUnknownSchemaNodes(),
+                getRequireInstance());
     }
 }
index 0d803ce34b2dd8b2f5423b22d87ee3415f2e71d9..35d1336a443097788d6c0dde5870033cabaaa3a2 100644 (file)
@@ -21,7 +21,8 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
 import org.opendaylight.yangtools.yang.model.util.UnresolvedNumber;
 
-public abstract class LengthRestrictedTypeBuilder<T extends TypeDefinition<T>> extends AbstractRestrictedTypeBuilder<T> {
+public abstract class LengthRestrictedTypeBuilder<T extends TypeDefinition<T>>
+        extends AbstractRestrictedTypeBuilder<T> {
     private List<LengthConstraint> lengthAlternatives;
 
     LengthRestrictedTypeBuilder(final T baseType, final SchemaPath path) {
@@ -57,10 +58,10 @@ public abstract class LengthRestrictedTypeBuilder<T extends TypeDefinition<T>> e
             final Number min = c.getMin();
 
             if (max instanceof UnresolvedNumber || min instanceof UnresolvedNumber) {
-                final Number rMax = max instanceof UnresolvedNumber ?
-                        ((UnresolvedNumber)max).resolveLength(baseLengthConstraints) : max;
-                final Number rMin = min instanceof UnresolvedNumber ?
-                        ((UnresolvedNumber)min).resolveLength(baseLengthConstraints) : min;
+                final Number rMax = max instanceof UnresolvedNumber
+                    ? ((UnresolvedNumber)max).resolveLength(baseLengthConstraints) : max;
+                final Number rMin = min instanceof UnresolvedNumber
+                    ? ((UnresolvedNumber)min).resolveLength(baseLengthConstraints) : min;
 
                 builder.add(BaseConstraints.newLengthConstraint(rMin, rMax, Optional.fromNullable(c.getDescription()),
                     Optional.fromNullable(c.getReference()), c.getErrorAppTag(), c.getErrorMessage()));
@@ -83,7 +84,8 @@ public abstract class LengthRestrictedTypeBuilder<T extends TypeDefinition<T>> e
         return lengths;
     }
 
-    private static List<LengthConstraint> typedLengths(final List<LengthConstraint> lengths, final Class<? extends Number> clazz) {
+    private static List<LengthConstraint> typedLengths(final List<LengthConstraint> lengths,
+            final Class<? extends Number> clazz) {
         final Function<Number, Number> function = NumberUtil.converterTo(clazz);
         Preconditions.checkArgument(function != null, "Unsupported range class %s", clazz);
 
@@ -91,7 +93,8 @@ public abstract class LengthRestrictedTypeBuilder<T extends TypeDefinition<T>> e
 
         for (LengthConstraint c : lengths) {
             if (!clazz.isInstance(c.getMin()) || !clazz.isInstance(c.getMax())) {
-                final Number min, max;
+                final Number min;
+                final Number max;
 
                 try {
                     min = function.apply(c.getMin());
@@ -121,21 +124,6 @@ public abstract class LengthRestrictedTypeBuilder<T extends TypeDefinition<T>> e
         return false;
     }
 
-    abstract T buildType(List<LengthConstraint> lengthConstraints);
-    abstract List<LengthConstraint> getLengthConstraints(T type);
-    abstract List<LengthConstraint> typeLengthConstraints();
-
-    private List<LengthConstraint> findLenghts() {
-        List<LengthConstraint> ret = ImmutableList.of();
-        T wlk = getBaseType();
-        while (wlk != null && ret.isEmpty()) {
-            ret = getLengthConstraints(wlk);
-            wlk = wlk.getBaseType();
-        }
-
-        return ret.isEmpty() ? typeLengthConstraints() : ret;
-    }
-
     @Override
     final T buildType() {
         final List<LengthConstraint> baseLengths = findLenghts();
@@ -154,11 +142,28 @@ public abstract class LengthRestrictedTypeBuilder<T extends TypeDefinition<T>> e
         // Now verify if new ranges are strict subset of base ranges
         for (LengthConstraint c : typedLengths) {
             if (!lengthCovered(baseLengths, c)) {
-                throw new InvalidLengthConstraintException(c, "Length constraint %s is not a subset of parent constraints %s",
-                c, baseLengths);
+                throw new InvalidLengthConstraintException(c,
+                        "Length constraint %s is not a subset of parent constraints %s", c, baseLengths);
             }
         }
 
         return buildType(typedLengths);
     }
+
+    abstract T buildType(List<LengthConstraint> lengthConstraints);
+
+    abstract List<LengthConstraint> getLengthConstraints(T type);
+
+    abstract List<LengthConstraint> typeLengthConstraints();
+
+    private List<LengthConstraint> findLenghts() {
+        List<LengthConstraint> ret = ImmutableList.of();
+        T wlk = getBaseType();
+        while (wlk != null && ret.isEmpty()) {
+            ret = getLengthConstraints(wlk);
+            wlk = wlk.getBaseType();
+        }
+
+        return ret.isEmpty() ? typeLengthConstraints() : ret;
+    }
 }
index 424d416a95601a935faaeef3291183478bd7bff5..0899ed9abad53366689de63505e6a3a9e6a97da4 100644 (file)
@@ -38,6 +38,7 @@ final class NumberUtil {
     };
 
     private static final Map<Class<? extends Number>, Function<Number, Number>> CONVERTERS;
+
     static {
         final ImmutableMap.Builder<Class<? extends Number>, Function<Number, Number>> b = ImmutableMap.builder();
         b.put(Byte.class, input -> {
@@ -48,14 +49,14 @@ final class NumberUtil {
             return Byte.valueOf(input.toString());
         });
         b.put(Short.class, input -> {
-                if (input instanceof Short) {
-                    return input;
-                }
-                if (input instanceof Byte) {
-                    return input.shortValue();
-                }
+            if (input instanceof Short) {
+                return input;
+            }
+            if (input instanceof Byte) {
+                return input.shortValue();
+            }
 
-                return Short.valueOf(input.toString());
+            return Short.valueOf(input.toString());
         });
         b.put(Integer.class, input -> {
             if (input instanceof Integer) {
@@ -81,8 +82,7 @@ final class NumberUtil {
             if (input instanceof BigDecimal) {
                 return input;
             }
-            if (input instanceof Byte || input instanceof Short ||
-                    input instanceof Integer || input instanceof Long) {
+            if (input instanceof Byte || input instanceof Short || input instanceof Integer || input instanceof Long) {
                 return BigDecimal.valueOf(input.longValue());
             }
 
@@ -92,8 +92,7 @@ final class NumberUtil {
             if (input instanceof BigInteger) {
                 return input;
             }
-            if (input instanceof Byte || input instanceof Short ||
-                    input instanceof Integer || input instanceof Long) {
+            if (input instanceof Byte || input instanceof Short || input instanceof Integer || input instanceof Long) {
                 return BigInteger.valueOf(input.longValue());
             }
 
@@ -111,7 +110,7 @@ final class NumberUtil {
     }
 
     static boolean isRangeCovered(final Number min, final Number max, final Number superMin, final Number superMax) {
-        return NumberUtil.NUMBER_COMPARATOR.compare(min, superMin) >= 0 &&
-                NumberUtil.NUMBER_COMPARATOR.compare(max, superMax) <= 0;
+        return NumberUtil.NUMBER_COMPARATOR.compare(min, superMin) >= 0
+            && NumberUtil.NUMBER_COMPARATOR.compare(max, superMax) <= 0;
     }
 }
index 434b4adbacb33acdc898bedb166be0bb569d3e73..92c2117ffc3530c72b7fcfa759b926245e0b01ee 100644 (file)
@@ -58,10 +58,10 @@ public abstract class RangeRestrictedTypeBuilder<T extends TypeDefinition<T>> ex
             final Number min = c.getMin();
 
             if (max instanceof UnresolvedNumber || min instanceof UnresolvedNumber) {
-                final Number rMax = max instanceof UnresolvedNumber ?
-                        ((UnresolvedNumber)max).resolveRange(baseRangeConstraints) : max;
-                final Number rMin = min instanceof UnresolvedNumber ?
-                        ((UnresolvedNumber)min).resolveRange(baseRangeConstraints) : min;
+                final Number rMax = max instanceof UnresolvedNumber
+                    ?  ((UnresolvedNumber)max).resolveRange(baseRangeConstraints) : max;
+                final Number rMin = min instanceof UnresolvedNumber
+                    ?  ((UnresolvedNumber)min).resolveRange(baseRangeConstraints) : min;
 
                 builder.add(BaseConstraints.newRangeConstraint(rMin, rMax, Optional.fromNullable(c.getDescription()),
                     Optional.fromNullable(c.getReference()), c.getErrorAppTag(), c.getErrorMessage()));
@@ -85,7 +85,8 @@ public abstract class RangeRestrictedTypeBuilder<T extends TypeDefinition<T>> ex
         return ranges;
     }
 
-    private static List<RangeConstraint> typedRanges(final List<RangeConstraint> ranges, final Class<? extends Number> clazz) {
+    private static List<RangeConstraint> typedRanges(final List<RangeConstraint> ranges,
+            final Class<? extends Number> clazz) {
         final Function<Number, Number> function = NumberUtil.converterTo(clazz);
         Preconditions.checkArgument(function != null, "Unsupported range class %s", clazz);
 
@@ -93,7 +94,8 @@ public abstract class RangeRestrictedTypeBuilder<T extends TypeDefinition<T>> ex
 
         for (RangeConstraint c : ranges) {
             if (!clazz.isInstance(c.getMin()) || !clazz.isInstance(c.getMax())) {
-                final Number min, max;
+                final Number min;
+                final Number max;
 
                 try {
                     min = function.apply(c.getMin());
@@ -139,8 +141,8 @@ public abstract class RangeRestrictedTypeBuilder<T extends TypeDefinition<T>> ex
         // Now verify if new ranges are strict subset of base ranges
         for (RangeConstraint c : typedRanges) {
             if (!rangeCovered(baseRangeConstraints, c)) {
-                throw new InvalidRangeConstraintException(c, "Range constraint %s is not a subset of parent constraints %s",
-                    c, baseRangeConstraints);
+                throw new InvalidRangeConstraintException(c,
+                        "Range constraint %s is not a subset of parent constraints %s", c, baseRangeConstraints);
             }
         }
 
index 930f5654a7323d5611610192342ca54bbe3c7323..2e24640fc2c5c3b5f6a22c868e2671f625da903a 100644 (file)
@@ -13,7 +13,8 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 
-final class RestrictedBinaryType extends AbstractLengthRestrictedType<BinaryTypeDefinition> implements BinaryTypeDefinition {
+final class RestrictedBinaryType extends AbstractLengthRestrictedType<BinaryTypeDefinition>
+        implements BinaryTypeDefinition {
     RestrictedBinaryType(final BinaryTypeDefinition baseType, final SchemaPath path,
             final Collection<UnknownSchemaNode> unknownSchemaNodes,
             final Collection<LengthConstraint> lengthConstraints) {
index 41bdc1c7ba925213a6a5436380a9edeb4dd453ae..b71652f9bf2a38608b0201a55ee8e1f66abd9caa 100644 (file)
@@ -12,7 +12,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
 
-final class RestrictedBooleanType extends AbstractRestrictedType<BooleanTypeDefinition> implements BooleanTypeDefinition {
+final class RestrictedBooleanType extends AbstractRestrictedType<BooleanTypeDefinition>
+        implements BooleanTypeDefinition {
     RestrictedBooleanType(final BooleanTypeDefinition baseType, final SchemaPath path,
             final Collection<UnknownSchemaNode> unknownSchemaNodes) {
         super(baseType, path, unknownSchemaNodes);
index 13751e4b6db9f1fd372b0279fb5cbadf8c2b64c4..701403a98ecef19034eebb760eb40c1100018eb4 100644 (file)
@@ -14,7 +14,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 
-final class RestrictedIdentityrefType extends AbstractRestrictedType<IdentityrefTypeDefinition> implements IdentityrefTypeDefinition {
+final class RestrictedIdentityrefType extends AbstractRestrictedType<IdentityrefTypeDefinition>
+        implements IdentityrefTypeDefinition {
     RestrictedIdentityrefType(final IdentityrefTypeDefinition baseType, final SchemaPath path,
             final Collection<UnknownSchemaNode> unknownSchemaNodes) {
         super(baseType, path, unknownSchemaNodes);
index 9935f24bb26e90da10a130a76afa7371b3e6b2a2..5e92d0ad6724c7ad7705f06a292703d8218e9d8c 100644 (file)
@@ -13,19 +13,20 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 
-final class RestrictedIntegerType extends AbstractRangeRestrictedType<IntegerTypeDefinition> implements IntegerTypeDefinition {
+final class RestrictedIntegerType extends AbstractRangeRestrictedType<IntegerTypeDefinition>
+        implements IntegerTypeDefinition {
     RestrictedIntegerType(final IntegerTypeDefinition baseType, final SchemaPath path,
         final Collection<UnknownSchemaNode> unknownSchemaNodes, final Collection<RangeConstraint> rangeConstraints) {
         super(baseType, path, unknownSchemaNodes, rangeConstraints);
     }
 
     @Override
-    public final int hashCode() {
+    public int hashCode() {
         return TypeDefinitions.hashCode(this);
     }
 
     @Override
-    public final boolean equals(final Object obj) {
+    public boolean equals(final Object obj) {
         return TypeDefinitions.equals(this, obj);
     }
 
index b589b20297de92173e7435543a823f8c1d4efa43..691aa7e9a501230020d0794515c611fe2e605bd5 100644 (file)
@@ -13,7 +13,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 
-final class RestrictedLeafrefType extends AbstractRestrictedType<LeafrefTypeDefinition> implements LeafrefTypeDefinition {
+final class RestrictedLeafrefType extends AbstractRestrictedType<LeafrefTypeDefinition>
+        implements LeafrefTypeDefinition {
 
     private final boolean requireInstance;
 
index 04dd026703760d2c92345231e9ed3419c7fd2d40..0c1aa6aca51a7fc53bd0b663800c219cd2308781 100644 (file)
@@ -16,7 +16,8 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 
-final class RestrictedStringType extends AbstractLengthRestrictedType<StringTypeDefinition> implements StringTypeDefinition {
+final class RestrictedStringType extends AbstractLengthRestrictedType<StringTypeDefinition>
+        implements StringTypeDefinition {
     private final List<PatternConstraint> patternConstraints;
 
     RestrictedStringType(final StringTypeDefinition baseType, final SchemaPath path,
index 3e3200e465412528bb0297e5f0d6e6078bc690fe..521036e6122bb94da1b9e38d9554147def670ab3 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import java.util.List;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -31,6 +32,7 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  * Restricted types are a refinement of the restrictions applied to a particular type. YANG defines restrictions only
  * on a subset of the base types, but conceptually any such definition can hold unknown nodes.
  *
+ * <p>
  * 1) Restrictable
  *    binary (length)
  *    int{8,16,32,64} (range)
@@ -39,6 +41,7 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  *    decimal64 (range)
  *    instance-identifier (require-instance)
  *
+ * <p>
  * 2) Non-restrictable
  *    boolean
  *    bits
@@ -48,11 +51,13 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  *    leafref
  *    union
  *
+ * <p>
  * This class holds methods which allow creation of restricted types using {@link TypeBuilder} and its subclasses. Each
  * restricted type is logically anchored at a {@link SchemaPath}, but can be substituted by its base type if it does
  * not contribute any additional restrictions. TypeBuilder instances take this into account, and result in the base type
  * being returned from the builder when the base type and restricted type are semantically equal.
  *
+ * <p>
  * Restricted types inherit the default value, description, reference, status and units from the base type, if that type
  * defines them.
  */
@@ -62,7 +67,8 @@ public final class RestrictedTypes {
         throw new UnsupportedOperationException();
     }
 
-    public static LengthRestrictedTypeBuilder<BinaryTypeDefinition> newBinaryBuilder(@Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
+    public static LengthRestrictedTypeBuilder<BinaryTypeDefinition> newBinaryBuilder(
+            @Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
         return new LengthRestrictedTypeBuilder<BinaryTypeDefinition>(baseType, path) {
             @Override
             BinaryTypeDefinition buildType(final List<LengthConstraint> lengthConstraints) {
@@ -72,8 +78,8 @@ public final class RestrictedTypes {
             @Override
             List<LengthConstraint> typeLengthConstraints() {
                 /**
-                 * Length constraint imposed on YANG binary type by our implementation. byte[].length is an integer, capping our
-                 * ability to support arbitrary binary data.
+                 * Length constraint imposed on YANG binary type by our implementation. byte[].length is an integer,
+                 * capping our ability to support arbitrary binary data.
                  */
                 return JavaLengthConstraints.INTEGER_SIZE_CONSTRAINTS;
             }
@@ -89,7 +95,8 @@ public final class RestrictedTypes {
         return new BitsTypeBuilder(baseType, path);
     }
 
-    public static TypeBuilder<BooleanTypeDefinition> newBooleanBuilder(@Nonnull final BooleanTypeDefinition baseType, @Nonnull final SchemaPath path) {
+    public static TypeBuilder<BooleanTypeDefinition> newBooleanBuilder(@Nonnull final BooleanTypeDefinition baseType,
+            @Nonnull final SchemaPath path) {
         return new AbstractRestrictedTypeBuilder<BooleanTypeDefinition>(baseType, path) {
             @Override
             BooleanTypeDefinition buildType() {
@@ -98,8 +105,9 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<DecimalTypeDefinition> newDecima64Builder(final DecimalTypeDefinition baseType, final SchemaPath path) {
-        return new RangeRestrictedTypeBuilder<DecimalTypeDefinition>(Preconditions.checkNotNull(baseType), path) {
+    public static RangeRestrictedTypeBuilder<DecimalTypeDefinition> newDecima64Builder(
+            final DecimalTypeDefinition baseType, final SchemaPath path) {
+        return new RangeRestrictedTypeBuilder<DecimalTypeDefinition>(checkNotNull(baseType), path) {
             @Override
             DecimalTypeDefinition buildType() {
                 return new RestrictedDecimalType(getBaseType(), getPath(), getUnknownSchemaNodes(),
@@ -108,7 +116,8 @@ public final class RestrictedTypes {
         };
     }
 
-    public static TypeBuilder<EmptyTypeDefinition> newEmptyBuilder(final EmptyTypeDefinition baseType, final SchemaPath path) {
+    public static TypeBuilder<EmptyTypeDefinition> newEmptyBuilder(final EmptyTypeDefinition baseType,
+            final SchemaPath path) {
         return new AbstractRestrictedTypeBuilder<EmptyTypeDefinition>(baseType, path) {
             @Override
             EmptyTypeDefinition buildType() {
@@ -117,11 +126,13 @@ public final class RestrictedTypes {
         };
     }
 
-    public static EnumerationTypeBuilder newEnumerationBuilder(final EnumTypeDefinition baseType, final SchemaPath path) {
+    public static 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 TypeBuilder<IdentityrefTypeDefinition> newIdentityrefBuilder(final IdentityrefTypeDefinition baseType,
+            final SchemaPath path) {
         return new AbstractRestrictedTypeBuilder<IdentityrefTypeDefinition>(baseType, path) {
             @Override
             IdentityrefTypeDefinition buildType() {
@@ -130,7 +141,8 @@ public final class RestrictedTypes {
         };
     }
 
-    public static InstanceIdentifierTypeBuilder newInstanceIdentifierBuilder(final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
+    public static InstanceIdentifierTypeBuilder newInstanceIdentifierBuilder(
+            final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
         return new InstanceIdentifierTypeBuilder(baseType, path);
     }
 
@@ -142,13 +154,15 @@ public final class RestrictedTypes {
                 if (getRequireInstance() == getBaseType().requireInstance()) {
                     return getBaseType();
                 }
-                return new RestrictedLeafrefType(getBaseType(), getPath(), getUnknownSchemaNodes(), getRequireInstance());
+                return new RestrictedLeafrefType(getBaseType(), getPath(), getUnknownSchemaNodes(),
+                        getRequireInstance());
             }
         };
     }
 
-    public static RangeRestrictedTypeBuilder<IntegerTypeDefinition> newIntegerBuilder(final IntegerTypeDefinition baseType, final SchemaPath path) {
-        return new RangeRestrictedTypeBuilder<IntegerTypeDefinition>(Preconditions.checkNotNull(baseType), path) {
+    public static RangeRestrictedTypeBuilder<IntegerTypeDefinition> newIntegerBuilder(
+            final IntegerTypeDefinition baseType, final SchemaPath path) {
+        return new RangeRestrictedTypeBuilder<IntegerTypeDefinition>(checkNotNull(baseType), path) {
             @Override
             IntegerTypeDefinition buildType() {
                 return new RestrictedIntegerType(getBaseType(), getPath(), getUnknownSchemaNodes(),
@@ -161,7 +175,8 @@ public final class RestrictedTypes {
         return new StringTypeBuilder(baseType, path);
     }
 
-    public static TypeBuilder<UnionTypeDefinition> newUnionBuilder(final UnionTypeDefinition baseType, final SchemaPath path) {
+    public static TypeBuilder<UnionTypeDefinition> newUnionBuilder(final UnionTypeDefinition baseType,
+            final SchemaPath path) {
         return new AbstractRestrictedTypeBuilder<UnionTypeDefinition>(baseType, path) {
             @Override
             UnionTypeDefinition buildType() {
@@ -170,8 +185,9 @@ public final class RestrictedTypes {
         };
     }
 
-    public static RangeRestrictedTypeBuilder<UnsignedIntegerTypeDefinition> newUnsignedBuilder(final UnsignedIntegerTypeDefinition baseType, final SchemaPath path) {
-        return new RangeRestrictedTypeBuilder<UnsignedIntegerTypeDefinition>(Preconditions.checkNotNull(baseType), path) {
+    public static RangeRestrictedTypeBuilder<UnsignedIntegerTypeDefinition> newUnsignedBuilder(
+            final UnsignedIntegerTypeDefinition baseType, final SchemaPath path) {
+        return new RangeRestrictedTypeBuilder<UnsignedIntegerTypeDefinition>(checkNotNull(baseType), path) {
             @Override
             UnsignedIntegerTypeDefinition buildType() {
                 return new RestrictedUnsignedType(getBaseType(), getPath(), getUnknownSchemaNodes(),
index 117375d21d5de6f22c7abd92600d8e98e745577d..8b8ba8d35b034121229d448ffd02ff11534d68eb 100644 (file)
@@ -65,84 +65,99 @@ final class TypeDefinitions {
             type.getDefaultValue(), type.getLengthConstraints());
     }
 
-    static boolean equals(final BinaryTypeDefinition type, final Object obj) {
-        if (type == obj) {
-            return true;
-        }
+    static int hashCode(final BitsTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getBits());
+    }
 
-        final BinaryTypeDefinition other = castIfEquals(BinaryTypeDefinition.class, type, obj);
-        return other != null && type.getLengthConstraints().equals(other.getLengthConstraints());
+
+    static int hashCode(final BooleanTypeDefinition type) {
+        return basicHashCode(type);
     }
 
-    static String toString(final BinaryTypeDefinition type) {
-        return toStringHelper(type).add("length", type.getLengthConstraints()).toString();
+    static int hashCode(final DecimalTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getFractionDigits(), type.getRangeConstraints());
     }
 
-    static int hashCode(final BitsTypeDefinition type) {
+    static int hashCode(final EmptyTypeDefinition type) {
+        return basicHashCode(type);
+    }
+
+    static int hashCode(final EnumTypeDefinition type) {
         return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getBits());
+            type.getDefaultValue(), type.getValues());
     }
 
-    static boolean equals(final BitsTypeDefinition type, final Object obj) {
-        if (type == obj) {
-            return true;
-        }
+    static int hashCode(final IdentityrefTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getIdentity());
+    }
 
-        final BitsTypeDefinition other = castIfEquals(BitsTypeDefinition.class, type, obj);
-        return other != null && type.getBits().equals(other.getBits());
+    static int hashCode(final InstanceIdentifierTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.requireInstance());
     }
 
-    static String toString(final BitsTypeDefinition type) {
-        return toStringHelper(type).add("bits", type.getBits()).toString();
+    static int hashCode(final IntegerTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getRangeConstraints());
     }
 
-    static int hashCode(final BooleanTypeDefinition type) {
-        return basicHashCode(type);
+    static int hashCode(final LeafrefTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getPathStatement());
     }
 
-    static boolean equals(final BooleanTypeDefinition type, final Object obj) {
-        return type == obj || castIfEquals(BooleanTypeDefinition.class, type, obj) != null;
+    static int hashCode(final StringTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getLengthConstraints(), type.getPatternConstraints());
     }
 
-    static String toString(final BooleanTypeDefinition type) {
-        return toStringHelper(type).toString();
+    static int hashCode(final UnionTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
+            type.getDefaultValue(), type.getTypes());
     }
 
-    static int hashCode(final DecimalTypeDefinition type) {
+    static int hashCode(final UnsignedIntegerTypeDefinition type) {
         return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getFractionDigits(), type.getRangeConstraints());
+            type.getDefaultValue(), type.getRangeConstraints());
     }
 
-    static boolean equals(final DecimalTypeDefinition type, final Object obj) {
+    static boolean equals(final BinaryTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
         }
 
-        final DecimalTypeDefinition other = castIfEquals(DecimalTypeDefinition.class, type, obj);
-        return other != null && type.getFractionDigits().equals(other.getFractionDigits())
-                && type.getRangeConstraints().equals(other.getRangeConstraints());
+        final BinaryTypeDefinition other = castIfEquals(BinaryTypeDefinition.class, type, obj);
+        return other != null && type.getLengthConstraints().equals(other.getLengthConstraints());
     }
 
-    static String toString(final DecimalTypeDefinition type) {
-        return toStringHelper(type).add("fractionDigits", type.getFractionDigits())
-                .add("range", type.getRangeConstraints()).toString();
-    }
+    static boolean equals(final BitsTypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
 
-    static int hashCode(final EmptyTypeDefinition type) {
-        return basicHashCode(type);
+        final BitsTypeDefinition other = castIfEquals(BitsTypeDefinition.class, type, obj);
+        return other != null && type.getBits().equals(other.getBits());
     }
 
-    static boolean equals(final EmptyTypeDefinition type, final Object obj) {
-        return type == obj || castIfEquals(EmptyTypeDefinition.class, type, obj) != null;
+    static boolean equals(final BooleanTypeDefinition type, final Object obj) {
+        return type == obj || castIfEquals(BooleanTypeDefinition.class, type, obj) != null;
     }
 
-    static String toString(final EmptyTypeDefinition type) {
-        return toStringHelper(type).toString();
+    static boolean equals(final DecimalTypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final DecimalTypeDefinition other = castIfEquals(DecimalTypeDefinition.class, type, obj);
+        return other != null && type.getFractionDigits().equals(other.getFractionDigits())
+                && type.getRangeConstraints().equals(other.getRangeConstraints());
     }
 
-    static int hashCode(final EnumTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getValues());
+    static boolean equals(final EmptyTypeDefinition type, final Object obj) {
+        return type == obj || castIfEquals(EmptyTypeDefinition.class, type, obj) != null;
     }
 
     static boolean equals(final EnumTypeDefinition type, final Object obj) {
@@ -154,15 +169,6 @@ final class TypeDefinitions {
         return other != null && type.getValues().equals(other.getValues());
     }
 
-    static String toString(final EnumTypeDefinition type) {
-        return toStringHelper(type).add("values", type.getValues()).toString();
-    }
-
-    static int hashCode(final IdentityrefTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getIdentity());
-    }
-
     static boolean equals(final IdentityrefTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -172,15 +178,6 @@ final class TypeDefinitions {
         return other != null && type.getIdentity().equals(other.getIdentity());
     }
 
-    static String toString(final IdentityrefTypeDefinition type) {
-        return toStringHelper(type).add("identity", type.getIdentity()).toString();
-    }
-
-    static int hashCode(final InstanceIdentifierTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.requireInstance());
-    }
-
     static boolean equals(final InstanceIdentifierTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -190,15 +187,6 @@ final class TypeDefinitions {
         return other != null && type.requireInstance() == other.requireInstance();
     }
 
-    static String toString(final InstanceIdentifierTypeDefinition type) {
-        return toStringHelper(type).add("requireInstance", type.requireInstance()).toString();
-    }
-
-    static int hashCode(final IntegerTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getRangeConstraints());
-    }
-
     static boolean equals(final IntegerTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -208,33 +196,15 @@ final class TypeDefinitions {
         return other != null && type.getRangeConstraints().equals(other.getRangeConstraints());
     }
 
-    static String toString(final IntegerTypeDefinition type) {
-        return toStringHelper(type).add("range", type.getRangeConstraints()).toString();
-    }
-
-    static int hashCode(final LeafrefTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getPathStatement());
-    }
-
     static boolean equals(final LeafrefTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
         }
 
-        final LeafrefTypeDefinition other =castIfEquals(LeafrefTypeDefinition.class, type, obj);
+        final LeafrefTypeDefinition other = castIfEquals(LeafrefTypeDefinition.class, type, obj);
         return other != null && type.getPathStatement().equals(other.getPathStatement());
     }
 
-    static String toString(final LeafrefTypeDefinition type) {
-        return toStringHelper(type).add("pathStatement", type.getPathStatement()).toString();
-    }
-
-    static int hashCode(final StringTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getLengthConstraints(), type.getPatternConstraints());
-    }
-
     static boolean equals(final StringTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -245,16 +215,6 @@ final class TypeDefinitions {
                 && type.getPatternConstraints().equals(other.getPatternConstraints());
     }
 
-    static String toString(final StringTypeDefinition type) {
-        return toStringHelper(type).add("length", type.getLengthConstraints())
-                .add("patterns", type.getPatternConstraints()).toString();
-    }
-
-    static int hashCode(final UnionTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getTypes());
-    }
-
     static boolean equals(final UnionTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -264,15 +224,6 @@ final class TypeDefinitions {
         return other != null && type.getTypes().equals(other.getTypes());
     }
 
-    static String toString(final UnionTypeDefinition type) {
-        return toStringHelper(type).add("types", type.getTypes()).toString();
-    }
-
-    static int hashCode(final UnsignedIntegerTypeDefinition type) {
-        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(), type.getUnits(),
-            type.getDefaultValue(), type.getRangeConstraints());
-    }
-
     static boolean equals(final UnsignedIntegerTypeDefinition type, final Object obj) {
         if (type == obj) {
             return true;
@@ -282,6 +233,56 @@ final class TypeDefinitions {
         return other != null && type.getRangeConstraints().equals(other.getRangeConstraints());
     }
 
+    static String toString(final BinaryTypeDefinition type) {
+        return toStringHelper(type).add("length", type.getLengthConstraints()).toString();
+    }
+
+    static String toString(final BitsTypeDefinition type) {
+        return toStringHelper(type).add("bits", type.getBits()).toString();
+    }
+
+    static String toString(final BooleanTypeDefinition type) {
+        return toStringHelper(type).toString();
+    }
+
+    static String toString(final DecimalTypeDefinition type) {
+        return toStringHelper(type).add("fractionDigits", type.getFractionDigits())
+                .add("range", type.getRangeConstraints()).toString();
+    }
+
+    static String toString(final EmptyTypeDefinition type) {
+        return toStringHelper(type).toString();
+    }
+
+    static String toString(final EnumTypeDefinition type) {
+        return toStringHelper(type).add("values", type.getValues()).toString();
+    }
+
+    static String toString(final IdentityrefTypeDefinition type) {
+        return toStringHelper(type).add("identity", type.getIdentity()).toString();
+    }
+
+    static String toString(final InstanceIdentifierTypeDefinition type) {
+        return toStringHelper(type).add("requireInstance", type.requireInstance()).toString();
+    }
+
+    static String toString(final IntegerTypeDefinition type) {
+        return toStringHelper(type).add("range", type.getRangeConstraints()).toString();
+    }
+
+    static String toString(final LeafrefTypeDefinition type) {
+        return toStringHelper(type).add("pathStatement", type.getPathStatement()).toString();
+    }
+
+    static String toString(final StringTypeDefinition type) {
+        return toStringHelper(type).add("length", type.getLengthConstraints())
+                .add("patterns", type.getPatternConstraints()).toString();
+    }
+
+    static String toString(final UnionTypeDefinition type) {
+        return toStringHelper(type).add("types", type.getTypes()).toString();
+    }
+
     static String toString(final UnsignedIntegerTypeDefinition type) {
         return toStringHelper(type).add("range", type.getRangeConstraints()).toString();
     }
index 597d16017c43d1d978d1cf8c27f18fc287306c9c..17cd535e2753d8cf6159bce0800e35351c3e0121 100644 (file)
@@ -39,9 +39,9 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 @RunWith(MockitoJUnitRunner.class)
 public class InMemorySchemaSourceCacheTest {
 
-    private static final Class<YangSchemaSourceRepresentation> representation = YangSchemaSourceRepresentation.class;
-    private static final long lifetime = 1000l;
-    private static final TimeUnit units = TimeUnit.MILLISECONDS;
+    private static final Class<YangSchemaSourceRepresentation> REPRESENTATION = YangSchemaSourceRepresentation.class;
+    private static final long LIFETIME = 1000L;
+    private static final TimeUnit UNITS = TimeUnit.MILLISECONDS;
 
     @Mock
     private SchemaSourceRegistry registry;
@@ -56,31 +56,30 @@ public class InMemorySchemaSourceCacheTest {
 
     @Test
     public void inMemorySchemaSourceCacheTest1() {
-        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache = InMemorySchemaSourceCache
-                .createSoftCache(this.registry, InMemorySchemaSourceCacheTest.representation);
+        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
+            InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION);
         Assert.assertNotNull(inMemorySchemaSourceCache);
         inMemorySchemaSourceCache.close();
     }
 
     @Test
     public void inMemorySchemaSourceCacheTest2() {
-        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache = InMemorySchemaSourceCache
-                .createSoftCache(this.registry, InMemorySchemaSourceCacheTest.representation,
-                        InMemorySchemaSourceCacheTest.lifetime, InMemorySchemaSourceCacheTest.units);
+        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
+            InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION, LIFETIME, UNITS);
         Assert.assertNotNull(inMemorySchemaSourceCache);
         inMemorySchemaSourceCache.close();
     }
 
     @Test
     public void inMemorySchemaSourceCacheOfferAndGetSourcestest() throws Exception {
-        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache = InMemorySchemaSourceCache
-                .createSoftCache(this.registry, InMemorySchemaSourceCacheTest.representation);
+        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
+            InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION);
         final String content = "content";
         final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
         inMemorySchemaSourceCache.offer(source);
         final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", "2012-12-12");
-        final CheckedFuture<? extends YangSchemaSourceRepresentation, SchemaSourceException> checkedSource = inMemorySchemaSourceCache
-                .getSource(sourceIdentifier);
+        final CheckedFuture<? extends YangSchemaSourceRepresentation, SchemaSourceException> checkedSource =
+            inMemorySchemaSourceCache.getSource(sourceIdentifier);
         Assert.assertNotNull(checkedSource);
         final YangSchemaSourceRepresentation yangSchemaSourceRepresentation = checkedSource.get();
         Assert.assertNotNull(yangSchemaSourceRepresentation);
@@ -90,11 +89,11 @@ public class InMemorySchemaSourceCacheTest {
 
     @Test(expected = ExecutionException.class)
     public void inMemorySchemaSourceCacheNullGetSourcestest() throws Exception {
-        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache = InMemorySchemaSourceCache
-                .createSoftCache(this.registry, InMemorySchemaSourceCacheTest.representation);
+        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
+            InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION);
         final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", "2012-12-12");
-        final CheckedFuture<? extends YangSchemaSourceRepresentation, SchemaSourceException> checkedSource = inMemorySchemaSourceCache
-                .getSource(sourceIdentifier);
+        final CheckedFuture<? extends YangSchemaSourceRepresentation, SchemaSourceException> checkedSource =
+            inMemorySchemaSourceCache.getSource(sourceIdentifier);
         Assert.assertNotNull(checkedSource);
         checkedSource.get();
         inMemorySchemaSourceCache.close();
@@ -102,12 +101,10 @@ public class InMemorySchemaSourceCacheTest {
 
     @Test
     public void inMemorySchemaSourceCache3test() throws Exception {
-        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache = InMemorySchemaSourceCache
-                .createSoftCache(this.registry, InMemorySchemaSourceCacheTest.representation);
-
-        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache2 = InMemorySchemaSourceCache
-                .createSoftCache(this.registry, representation, InMemorySchemaSourceCacheTest.lifetime,
-                        InMemorySchemaSourceCacheTest.units);
+        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
+            InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION);
+        final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache2 =
+            InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION, LIFETIME, UNITS);
 
         final String content = "content";
         final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
@@ -115,10 +112,10 @@ public class InMemorySchemaSourceCacheTest {
         inMemorySchemaSourceCache2.offer(source);
 
         final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", "2012-12-12");
-        final CheckedFuture<? extends YangSchemaSourceRepresentation, SchemaSourceException> checkedSource = inMemorySchemaSourceCache
-                .getSource(sourceIdentifier);
-        final CheckedFuture<? extends SchemaSourceRepresentation, SchemaSourceException> checkedSource2 = inMemorySchemaSourceCache2
-                .getSource(sourceIdentifier);
+        final CheckedFuture<? extends YangSchemaSourceRepresentation, SchemaSourceException> checkedSource =
+            inMemorySchemaSourceCache.getSource(sourceIdentifier);
+        final CheckedFuture<? extends SchemaSourceRepresentation, SchemaSourceException> checkedSource2 =
+            inMemorySchemaSourceCache2.getSource(sourceIdentifier);
         Assert.assertNotNull(checkedSource);
         Assert.assertNotNull(checkedSource2);
 
index 9bc44aa84fdb6c0ec09108afa7a7dfeb5c9c08e0..a9d6bc90532010cd95c1a5ebe10fc0fb1f1f3e5c 100644 (file)
@@ -7,19 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.model.repo.util;
 
-import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-
 import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.CheckedFuture;
 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;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
@@ -61,7 +60,8 @@ public class SchemaSourceTransformerTest {
     @Test
     public void schemaSourceTransformerGetSourceTest() throws Exception {
         final Provider p = new Provider();
-        final Registrator reg = new Registrator(p, SchemaSourceTransformerTest.SRC_CLASS, PotentialSchemaSource.Costs.IMMEDIATE);
+        final Registrator reg = new Registrator(p, SchemaSourceTransformerTest.SRC_CLASS,
+                PotentialSchemaSource.Costs.IMMEDIATE);
         final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("source");
         reg.register(sourceIdentifier);
         this.schema = new SchemaSourceTransformer<>(p,
@@ -109,7 +109,7 @@ public class SchemaSourceTransformerTest {
 
         final PotentialSchemaSource<T> src;
 
-        public Foo(final SourceIdentifier sourceIdentifier, final Class<T> representation, final Costs cost) {
+        Foo(final SourceIdentifier sourceIdentifier, final Class<T> representation, final Costs cost) {
             this.src = PotentialSchemaSource.create(sourceIdentifier, representation,
                     cost.getValue());
         }
@@ -122,7 +122,7 @@ public class SchemaSourceTransformerTest {
 
     private class Registrator extends AbstractSchemaSourceCache<YangSchemaSourceRepresentation> {
 
-        protected Registrator(final SchemaSourceRegistry consumer, final Class<YangSchemaSourceRepresentation> srcClass,
+        Registrator(final SchemaSourceRegistry consumer, final Class<YangSchemaSourceRepresentation> srcClass,
                 final Costs cost) {
             super(consumer, srcClass, cost);
         }
index 5948d000fed269d98e78be255fe9eed7614889a2..32ae99eb25a50edf26156e50b9baec14563aff9b 100644 (file)
@@ -7,36 +7,37 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
+import static org.junit.Assert.assertEquals;
+
 import com.google.common.base.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 
-import static org.junit.Assert.assertEquals;
-
 public class BaseConstraintsTest {
 
     @Test
     public void canCreateConstraints() {
-        Number min = 5;
-        Number max = 99;
-        String description = "Any description";
-        String reference = "any_ref";
-        String reg_exp = "x|z";
-        Optional<String> desc = Optional.of(description);
-        Optional<String> ref = Optional.of(reference);
+        final Number min = 5;
+        final Number max = 99;
+        final String description = "Any description";
+        final String reference = "any_ref";
 
-        LengthConstraint lengthCons = BaseConstraints.newLengthConstraint(min, max, desc, ref);
+        LengthConstraint lengthCons = BaseConstraints.newLengthConstraint(min, max, Optional.of(description),
+            Optional.of(reference));
 
         assertEquals("LengthConstraints Get min", min, lengthCons.getMin());
         assertEquals("LengthConstraints Get max", max, lengthCons.getMax());
         assertEquals("LengthConstraints Get description", description, lengthCons.getDescription());
         assertEquals("LengthConstraints Get reference", reference, lengthCons.getReference());
 
+        final String reg_exp = "x|z";
+        final Optional<String> desc = Optional.of(description);
+        final Optional<String> ref = Optional.of(reference);
         PatternConstraint patternCons = BaseConstraints.newPatternConstraint(reg_exp, desc, ref);
 
         assertEquals("PatternConstraints Get regex", reg_exp, patternCons.getRegularExpression());
         assertEquals("PatternConstraints Get description", description, patternCons.getDescription());
         assertEquals("PatternConstraints Get reference", reference, patternCons.getReference());
     }
-}
\ No newline at end of file
+}
index aefdf8a3941dafe5517a3c7acc2e29a808d0595a..2ed2274ccea86cde82d87ee835cc786b0d452f8a 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.util;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+
 import org.junit.Test;
 
 public class BaseTypesTest {
index 146cb48191dd6b9099188149da2977dbebba8388..52063b4b88fe7e521a1e5299ef658a45da0457b4 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.model.util.type.BaseTypes.binaryType;
+
 import java.util.Collections;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Status;
@@ -21,8 +22,8 @@ public class BinaryTypeTest {
 
     @Test
     public void canCreateBinaryType() {
-        BinaryTypeDefinition binType = binaryType();
-        BinaryTypeDefinition binType1 = binaryType();
+        final BinaryTypeDefinition binType = binaryType();
+        final BinaryTypeDefinition binType1 = binaryType();
 
         assertEquals(0, binType.getLengthConstraints().size());
         assertNull(binType.getDefaultValue());
@@ -42,4 +43,4 @@ public class BinaryTypeTest {
         assertFalse("binType shouldn't equal to object of other type", binType.equals("str"));
     }
 
-}
\ No newline at end of file
+}
index 5507357018d30a06a183bbd1995b3531b9d273c1..b4054de4cc0f42e5fb04cd66ae3e0ebd924d4060 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.doReturn;
+
 import java.util.Collections;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -27,17 +28,17 @@ public class BitsTypeTest {
     private BitsTypeDefinition.Bit bit;
 
     @Test
-    public void canCreateBitsType(){
+    public void canCreateBitsType() {
         MockitoAnnotations.initMocks(this);
         doReturn("test").when(bit).getName();
 
-        QName qName = QName.create("TestQName");
-        SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(qName), true);
+        QName qname = QName.create("TestQName");
+        SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(qname), true);
 
         BitsTypeDefinition bitsType = BaseTypes.bitsTypeBuilder(schemaPath).addBit(bit).build();
 
         assertNull("Description is not null", bitsType.getDescription());
-        assertEquals("QName", qName, bitsType.getQName());
+        assertEquals("QName", qname, bitsType.getQName());
         assertNull("Should be null", bitsType.getUnits());
         assertNotEquals("Description should not be null", null, bitsType.toString());
         assertNull("Reference is not null", bitsType.getReference());
@@ -56,4 +57,4 @@ public class BitsTypeTest {
 
     }
 
-}
\ No newline at end of file
+}
index 56253d9d2947521747743552d25e02d1fb2b4e9f..7c57e819478781152b73de40744c53f9d8deac7d 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.model.util.type.BaseTypes.booleanType;
+
 import java.util.Collections;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Status;
@@ -20,27 +21,20 @@ public class BooleanTypeTest {
 
     @Test
     public void canCreateBooleanType() {
-        BooleanTypeDefinition boolType = booleanType();
-        String stringBoolType = boolType.toString();
+        final BooleanTypeDefinition boolType = booleanType();
+        final String stringBoolType = boolType.toString();
 
         assertEquals("getPath gives List of BOOLEAN_QNAME",
                 Collections.singletonList(BaseTypes.BOOLEAN_QNAME), boolType.getPath().getPathFromRoot());
-
         assertEquals("getQName gives BOOLEAN_QNAME", BaseTypes.BOOLEAN_QNAME, boolType.getQName());
-
         assertNull(boolType.getDescription());
 
-        String strPath = boolType.getPath().toString();
+        final String strPath = boolType.getPath().toString();
         assertTrue("Should contain string of getPath", stringBoolType.contains(strPath));
-
         assertNull("Should be null", boolType.getUnits());
-
         assertEquals("Base type is null", null, boolType.getBaseType());
-
         assertNull("Default value is null", boolType.getDefaultValue());
-
         assertEquals("Status CURRENT", Status.CURRENT, boolType.getStatus());
-
         assertEquals("Should contain empty list", Collections.EMPTY_LIST, boolType.getUnknownSchemaNodes());
     }
 }
index 271dd708f0131446544c797a909eec71c6b22947..96de5bab22491948a27014b2dd494425895f3e94 100644 (file)
@@ -15,10 +15,10 @@ import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 public class Bug4969Test {
     @Test
     public void testRegex() {
-        RevisionAwareXPath xPath = new RevisionAwareXPathImpl(
-                "nd:network[nd:network-id=current()/../network-ref]/nd:node[nd:node-id=current()/../node-ref]/termination-point/tp-id",
-                true);
+        RevisionAwareXPath xpath = new RevisionAwareXPathImpl(
+                "nd:network[nd:network-id=current()/../network-ref]/nd:node[nd:node-id=current()/../node-ref]"
+                + "/termination-point/tp-id", true);
         assertEquals("nd:network/nd:node/termination-point/tp-id",
-                SchemaContextUtil.stripConditionsFromXPathString(xPath));
+                SchemaContextUtil.stripConditionsFromXPathString(xpath));
     }
 }
index d5a7243f44f94174ddf9ee72a34857394af528f1..aae6a5ef3bc331b6f95cd4cfece9461e6c5095a4 100644 (file)
@@ -7,7 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
 import com.google.common.collect.Sets;
+import java.util.Collections;
+import java.util.NoSuchElementException;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
@@ -15,9 +23,6 @@ import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-
-import java.util.Collections;
-import java.util.NoSuchElementException;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
@@ -25,12 +30,6 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
 public class DataNodeIteratorTest {
 
     private DataNodeIterator dataNodeIterator;
@@ -41,12 +40,12 @@ public class DataNodeIteratorTest {
         this.dataNodeIterator = new DataNodeIterator(dataNodeContainer);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected = IllegalArgumentException.class)
     public void createDataNodeIteratorWithNullArgument() {
         new DataNodeIterator(null);
     }
 
-    @Test(expected=UnsupportedOperationException.class)
+    @Test(expected = UnsupportedOperationException.class)
     public void removeFromEmptyDataNodeContainer() {
         dataNodeIterator.remove();
     }
@@ -83,7 +82,8 @@ public class DataNodeIteratorTest {
         final Set<ChoiceCaseNode> cases = Sets.newHashSet(mockedCase1, mockedCase2);
         doReturn(cases).when(mockedChoice).getCases();
 
-        final Set<DataSchemaNode> childNodes = Sets.newHashSet(mockedAugmentingContainer, mockedContainer, mockedList, mockedChoice);
+        final Set<DataSchemaNode> childNodes = Sets.newHashSet(mockedAugmentingContainer, mockedContainer, mockedList,
+                mockedChoice);
         doReturn(childNodes).when(mockedModule).getChildNodes();
 
         final NotificationDefinition mockedNotification = mock(NotificationDefinition.class);
@@ -120,4 +120,4 @@ public class DataNodeIteratorTest {
         assertTrue(dataNodeIterator.allLists().contains(mockedListInRpcInputContainer));
         assertTrue(dataNodeIterator.allGroupings().contains(mockedGrouping));
     }
-}
\ No newline at end of file
+}
index 9c021d91c172cac59bca2209bc0069dcf43fe1b9..366e81b912a7888591dc1f3fbc76513802dbd1ce 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.model.util.type.BaseTypes.emptyType;
+
 import java.util.Collections;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Status;
@@ -34,4 +35,4 @@ public class EmptyTypeTest {
         assertEquals("UnknownSchemaNodes", Collections.EMPTY_LIST, emptyType.getUnknownSchemaNodes());
         assertTrue("toString", emptyType.toString().contains("empty"));
     }
-}
\ No newline at end of file
+}
index 46db0ed9c02c212aefe4bf25832e5a23672f4913..5bf00d6018ec3c76b8131d62275c27abe2d3c7c4 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import static org.junit.Assert.assertTrue;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
index 2cd69698524137252bccedfe5af7c38e68abf6b4..2e4be322a1cfd2859e0f1b6afd2daa85d262befd 100644 (file)
@@ -31,9 +31,12 @@ public class LeafrefTest {
         final RevisionAwareXPathImpl revision = new RevisionAwareXPathImpl("/test:Cont1/test:List1", false);
         final RevisionAwareXPathImpl revision2 = new RevisionAwareXPathImpl("/test:Cont1/test:List2", false);
 
-        final LeafrefTypeDefinition leafref = BaseTypes.leafrefTypeBuilder(schemaPath).setPathStatement(revision).build();
-        final LeafrefTypeDefinition leafref2 = BaseTypes.leafrefTypeBuilder(schemaPath).setPathStatement(revision2).build();
-        final LeafrefTypeDefinition leafref3 = BaseTypes.leafrefTypeBuilder(schemaPath).setPathStatement(revision).build();
+        final LeafrefTypeDefinition leafref = BaseTypes.leafrefTypeBuilder(schemaPath).setPathStatement(revision)
+            .build();
+        final LeafrefTypeDefinition leafref2 = BaseTypes.leafrefTypeBuilder(schemaPath).setPathStatement(revision2)
+            .build();
+        final LeafrefTypeDefinition leafref3 = BaseTypes.leafrefTypeBuilder(schemaPath).setPathStatement(revision)
+            .build();
         final LeafrefTypeDefinition leafref4 = leafref;
 
         assertNotNull("Object 'leafref' shouldn't be null.", leafref);
@@ -45,10 +48,13 @@ public class LeafrefTest {
         assertNull(leafref.getDescription());
         assertNull(leafref.getReference());
         assertEquals("Status of 'leafref' is current.", Status.CURRENT, leafref.getStatus());
-        assertTrue("Object 'leafref' shouldn't have any unknown schema nodes.", leafref.getUnknownSchemaNodes().isEmpty());
-        assertEquals("Revision aware XPath of 'leafref' should be '/test:Cont1/test:List1'.", revision, leafref.getPathStatement());
+        assertTrue("Object 'leafref' shouldn't have any unknown schema nodes.",
+                leafref.getUnknownSchemaNodes().isEmpty());
+        assertEquals("Revision aware XPath of 'leafref' should be '/test:Cont1/test:List1'.", revision,
+                leafref.getPathStatement());
         assertNotNull("String representation of 'leafref' shouldn't be null.", leafref.toString());
-        assertNotEquals("Hash codes of two different object of type Leafref shouldn't be equal.", leafref.hashCode(), leafref2.hashCode());
+        assertNotEquals("Hash codes of two different object of type Leafref shouldn't be equal.", leafref.hashCode(),
+                leafref2.hashCode());
         assertTrue("Objects of type Leafref should be equal.", leafref.equals(leafref3));
         assertTrue("Objects of type Leafref should be equal.", leafref.equals(leafref4));
         assertFalse("Objects of type Leafref shouldn't be equal.", leafref.equals(leafref2));
index 305fea505c5e65d57fd82a1a345735e5403cc4b3..2465bdc4afcfea4a02109ca15da73c9374fcceb4 100644 (file)
@@ -33,8 +33,10 @@ public class PatternConstraintImplTest {
         final PatternConstraintImpl patternConstraint5 = new PatternConstraintImpl(regexExp2, description2, reference2);
 
         assertNotNull("Object of PatternConstraintImpl shouldn't be null.", patternConstraint);
-        assertEquals("Description should be 'test description'.", "test description", patternConstraint.getDescription());
-        assertEquals("Error app tag shouldn't be null.", "invalid-regular-expression", patternConstraint.getErrorAppTag());
+        assertEquals("Description should be 'test description'.", "test description",
+                patternConstraint.getDescription());
+        assertEquals("Error app tag shouldn't be null.", "invalid-regular-expression",
+                patternConstraint.getErrorAppTag());
         assertNotNull(patternConstraint.getErrorMessage());
         assertEquals("Reference should be equals 'RFC 6020'.", "RFC 6020", patternConstraint.getReference());
         assertEquals("Regular expression should be equls '\\D'.", "\\D", patternConstraint.getRegularExpression());
index 52398a71428f82b21c6395d31ea88b299fed0a7c..acb5eaf75d5ab03ea52760de3cb70f49f092f96b 100644 (file)
@@ -13,12 +13,13 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.text.ParseException;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
@@ -68,17 +69,15 @@ public class SchemaContextProxyTest {
 
     private static SchemaContext mockSchema(final Module... module) {
         SchemaContext mock = mock(SchemaContext.class);
-        doReturn(Sets.newHashSet(module)).when(mock).getModules();
+        doReturn(ImmutableSet.copyOf(module)).when(mock).getModules();
         return mock;
     }
 
-    /**
-     * <pre>
+    /*
      * CFG(R)
      *  | \
      *  |  \
-     * M2 &lt;- M3
-     * </pre>
+     * M2 <- M3
      */
     @Test
     public void testBasic() {
@@ -91,17 +90,16 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3);
     }
 
-    /**
-     * <pre>
+    /*
      * No root or additional modules
      *  | \
      *  |  \
-     * M2 &lt;- M3
-     * </pre>
+     * M2 <- M3
      */
     @Test
     public void testNull() {
@@ -118,13 +116,11 @@ public class SchemaContextProxyTest {
         assertProxyContext(filteringSchemaContextProxy, null);
     }
 
-    /**
-     * <pre>
+    /*
      *  Config
      *  | \ (NR)
      *  |  \
-     * M2 &lt;- M3
-     * </pre>
+     * M2 <- M3
      */
     @Test
     public void testConfigDifferentRevisions() {
@@ -139,25 +135,25 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, moduleConfig2, module2, module3);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, moduleConfig2, module2, module3);
     }
 
-    /**
-     * <pre>
+    /*
      *     CFG(R)
      *    |      \
      *   |         \
-     * M2&lt;-(NullRev)M3
-     * </pre>
+     * M2<-(NullRev)M3
      */
     @Test
     public void testBasicNullRevision() throws Exception {
-        Module moduleConfig = mockModule(CONFIG_NAME,SimpleDateFormatUtil.getRevisionFormat().parse("2013-04-05"));
-        Module module2 = mockModule(MODULE2_NAME, SimpleDateFormatUtil.getRevisionFormat().parse("2014-06-17"));
-        Module module20 = mockModule(MODULE2_NAME, null);
-        Module module3 = mockModule(MODULE3_NAME, SimpleDateFormatUtil.getRevisionFormat().parse("2014-06-12"));
-        Module module30 = mockModule(MODULE3_NAME, null);
+        final Module moduleConfig = mockModule(CONFIG_NAME,SimpleDateFormatUtil.getRevisionFormat()
+                .parse("2013-04-05"));
+        final Module module2 = mockModule(MODULE2_NAME, SimpleDateFormatUtil.getRevisionFormat().parse("2014-06-17"));
+        final Module module20 = mockModule(MODULE2_NAME, null);
+        final Module module3 = mockModule(MODULE3_NAME, SimpleDateFormatUtil.getRevisionFormat().parse("2014-06-12"));
+        final Module module30 = mockModule(MODULE3_NAME, null);
 
         mockModuleImport(module20, moduleConfig);
         mockModuleImport(module2, moduleConfig);
@@ -166,42 +162,40 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
 
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3);
     }
 
-    /**
-     * <pre>
+    /*
      * CFG(R)   ROOT(R)
      *  |         \
      *  |          \
      * M2          M3
-     * </pre>
      */
     @Test
     public void testBasicMoreRootModules() {
-        Module moduleConfig = mockModule(CONFIG_NAME);
-        Module moduleRoot = mockModule(ROOT_NAME);
-        Module module2 = mockModule(MODULE2_NAME);
-        Module module3 = mockModule(MODULE3_NAME);
+        final Module moduleConfig = mockModule(CONFIG_NAME);
+        final Module moduleRoot = mockModule(ROOT_NAME);
+        final Module module2 = mockModule(MODULE2_NAME);
+        final Module module3 = mockModule(MODULE3_NAME);
 
         mockModuleImport(module2, moduleConfig);
         mockModuleImport(module3, moduleRoot);
 
         SchemaContext schemaContext = mockSchema(moduleConfig, moduleRoot, module2, module3);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleRoot, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleRoot,
+                moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleRoot, module3, moduleConfig, module2);
     }
 
-    /**
-     * <pre>
+    /*
      * CFG(R)
      *  |
      *  |
-     * M2 &lt;- M3
-     * </pre>
+     * M2 <- M3
      */
     @Test
     public void testChainNotDepend() {
@@ -214,17 +208,16 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2);
     }
 
-    /**
-     * <pre>
+    /*
      * CFG(R)
      *  |
      *  |
-     * M2 -&gt; M3 -&gt; M4 -&gt; M5
-     * </pre>
+     * M2 -> M3 -> M4 -> M5
      */
     @Test
     public void testChainDependMulti() {
@@ -240,17 +233,16 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3, module4, module5);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3, module4, module5);
     }
 
-    /**
-     * <pre>
+    /*
      * CFG(R)
      *  |
      *  |
-     * M2 -&gt; M3 &lt;- M4
-     * </pre>
+     * M2 -> M3 <- M4
      */
     @Test
     public void testChainNotDependMulti() {
@@ -264,25 +256,24 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3, module4);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3);
     }
 
-    /**
-     * <pre>
+    /*
      *  CFG(R)
      *  | \ \ \
      *  |  \ \ \
      * M2 M3 M4 M5
-     * </pre>
      */
     @Test
     public void testChainNotMulti() {
-        Module moduleConfig = mockModule(CONFIG_NAME);
-        Module module2 = mockModule(MODULE2_NAME);
-        Module module3 = mockModule(MODULE3_NAME);
-        Module module4 = mockModule(MODULE4_NAME);
-        Module module5 = mockModule(MODULE5_NAME);
+        final Module moduleConfig = mockModule(CONFIG_NAME);
+        final Module module2 = mockModule(MODULE2_NAME);
+        final Module module3 = mockModule(MODULE3_NAME);
+        final Module module4 = mockModule(MODULE4_NAME);
+        final Module module5 = mockModule(MODULE5_NAME);
 
         mockModuleImport(module2, moduleConfig);
         mockModuleImport(module3, moduleConfig);
@@ -291,17 +282,16 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3, module4, module5);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3, module4, module5);
     }
 
-    /**
-     * <pre>
+    /*
      * CFG(R)
      *  | \
      *  |  \
-     * M2 &lt;- M3 M4=M3(Different revision)
-     * </pre>
+     * M2 <- M3 M4=M3(Different revision)
      */
     @Test
     public void testBasicRevisionChange() throws Exception {
@@ -317,16 +307,15 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3, module4);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3);
     }
 
-    /**
-     * <pre>
+    /*
      * CFG(R)
      * |
-     * M2 -(no revision)-&gt; M3(R2) ... M3(R1)
-     * </pre>
+     * M2 -(no revision)-> M3(R2) ... M3(R1)
      */
     @Test
     public void testImportNoRevision() {
@@ -340,20 +329,19 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module30, module31);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
 
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module31);
     }
 
-    /**
-     * <pre>
+    /*
      * CFG(R)
      * |   \
      * |    \
-     * |    M2 -&gt; M3
+     * |    M2 -> M3
      * |
-     * M41(S) =&gt; M4
-     * </pre>
+     * M41(S) => M4
      */
     @Test
     public void testBasicSubmodule() {
@@ -369,16 +357,13 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3, module4);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null, moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, null,
+                moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3, module4);
     }
 
-    /**
-     * <pre>
-     *
-     * M2 -&gt; M3 -&gt; M4 -&gt; M5
-     *
-     * </pre>
+    /*
+     * M2 -> M3 -> M4 -> M5
      */
     @Test
     public void testChainAdditionalModules() {
@@ -393,21 +378,19 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(module2, module3, module4, module5);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, Sets.newHashSet(module2), null);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
+                Collections.singleton(module2), null);
         assertProxyContext(filteringSchemaContextProxy, module2, module3, module4, module5);
     }
 
-    /**
-     * <pre>
+    /*
      *
      * CFG(R)
      *  |
      *  |       M5
      * M2
      *
-     * M3 -&gt; M4
-     *
-     * </pre>
+     * M3 -> M4
      */
     @Test
     public void testChainAdditionalModulesConfig() {
@@ -423,7 +406,8 @@ public class SchemaContextProxyTest {
 
         SchemaContext schemaContext = mockSchema(moduleConfig, module2, module3, module4, module5);
 
-        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext, Sets.newHashSet(module3), moduleConfig);
+        FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
+            Collections.singleton(module3), moduleConfig);
         assertProxyContext(filteringSchemaContextProxy, moduleConfig, module2, module3, module4);
     }
 
@@ -432,10 +416,10 @@ public class SchemaContextProxyTest {
         final Module moduleConfig = mockModule(CONFIG_NAME);
         final SchemaContext schemaContext = mockSchema(moduleConfig);
         final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
-                Sets.newHashSet(), moduleConfig);
+                new HashSet<>(), moduleConfig);
 
         final ContainerSchemaNode mockedContainer = mock(ContainerSchemaNode.class);
-        final Set<DataSchemaNode> childNodes = Sets.newHashSet(mockedContainer);
+        final Set<DataSchemaNode> childNodes = Collections.singleton(mockedContainer);
         doReturn(childNodes).when(moduleConfig).getChildNodes();
 
         final Set<DataSchemaNode> dataDefinitions = filteringSchemaContextProxy.getDataDefinitions();
@@ -447,13 +431,14 @@ public class SchemaContextProxyTest {
         final Module moduleConfig = mockModule(CONFIG_NAME);
         final SchemaContext schemaContext = mockSchema(moduleConfig);
         final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
-                Sets.newHashSet(), moduleConfig);
+                new HashSet<>(), moduleConfig);
 
         final NotificationDefinition mockedNotification = mock(NotificationDefinition.class);
-        final Set<NotificationDefinition> notifications = Sets.newHashSet(mockedNotification);
+        final Set<NotificationDefinition> notifications = Collections.singleton(mockedNotification);
         doReturn(notifications).when(moduleConfig).getNotifications();
 
-        final Set<NotificationDefinition> schemaContextProxyNotifications = filteringSchemaContextProxy.getNotifications();
+        final Set<NotificationDefinition> schemaContextProxyNotifications =
+            filteringSchemaContextProxy.getNotifications();
         assertTrue(schemaContextProxyNotifications.contains(mockedNotification));
     }
 
@@ -462,10 +447,10 @@ public class SchemaContextProxyTest {
         final Module moduleConfig = mockModule(CONFIG_NAME);
         final SchemaContext schemaContext = mockSchema(moduleConfig);
         final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
-                Sets.newHashSet(), moduleConfig);
+                new HashSet<>(), moduleConfig);
 
         final RpcDefinition mockedRpc = mock(RpcDefinition.class);
-        final Set<RpcDefinition> rpcs = Sets.newHashSet(mockedRpc);
+        final Set<RpcDefinition> rpcs = Collections.singleton(mockedRpc);
         doReturn(rpcs).when(moduleConfig).getRpcs();
 
         final Set<RpcDefinition> operations = filteringSchemaContextProxy.getOperations();
@@ -477,7 +462,7 @@ public class SchemaContextProxyTest {
         final Module moduleConfig = mockModule(CONFIG_NAME);
         final SchemaContext schemaContext = mockSchema(moduleConfig);
         final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
-                Sets.newHashSet(), moduleConfig);
+                new HashSet<>(), moduleConfig);
 
         final ExtensionDefinition mockedExtension = mock(ExtensionDefinition.class);
         final List<ExtensionDefinition> extensions = Lists.newArrayList(mockedExtension);
@@ -492,7 +477,7 @@ public class SchemaContextProxyTest {
         final Module moduleConfig = mockModule(CONFIG_NAME);
         final SchemaContext schemaContext = mockSchema(moduleConfig);
         final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
-                Sets.newHashSet(), moduleConfig);
+                new HashSet<>(), moduleConfig);
 
         final UnknownSchemaNode mockedUnknownSchemaNode = mock(UnknownSchemaNode.class);
         final List<UnknownSchemaNode> unknownSchemaNodes = Lists.newArrayList(mockedUnknownSchemaNode);
@@ -508,13 +493,14 @@ public class SchemaContextProxyTest {
         final Module moduleConfig = mockModule(CONFIG_NAME);
         final SchemaContext schemaContext = mockSchema(moduleConfig);
         final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
-                Sets.newHashSet(), moduleConfig);
+                new HashSet<>(), moduleConfig);
 
         final TypeDefinition<?> mockedTypeDefinition = mock(TypeDefinition.class);
-        final Set<TypeDefinition<?>> typeDefinitions = Sets.newHashSet(mockedTypeDefinition);
+        final Set<TypeDefinition<?>> typeDefinitions = Collections.singleton(mockedTypeDefinition);
         doReturn(typeDefinitions).when(moduleConfig).getTypeDefinitions();
 
-        final Set<TypeDefinition<?>> schemaContextProxyTypeDefinitions = filteringSchemaContextProxy.getTypeDefinitions();
+        final Set<TypeDefinition<?>> schemaContextProxyTypeDefinitions = filteringSchemaContextProxy
+            .getTypeDefinitions();
         assertTrue(schemaContextProxyTypeDefinitions.contains(mockedTypeDefinition));
     }
 
@@ -523,10 +509,10 @@ public class SchemaContextProxyTest {
         final Module moduleConfig = mockModule(CONFIG_NAME);
         final SchemaContext schemaContext = mockSchema(moduleConfig);
         final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
-                Sets.newHashSet(), moduleConfig);
+                new HashSet<>(), moduleConfig);
 
         final ContainerSchemaNode mockedContainer = mock(ContainerSchemaNode.class);
-        final Set<DataSchemaNode> childNodes = Sets.newHashSet(mockedContainer);
+        final Set<DataSchemaNode> childNodes = Collections.singleton(mockedContainer);
         doReturn(childNodes).when(moduleConfig).getChildNodes();
 
         final Set<DataSchemaNode> schemaContextProxyChildNodes = filteringSchemaContextProxy.getChildNodes();
@@ -538,10 +524,10 @@ public class SchemaContextProxyTest {
         final Module moduleConfig = mockModule(CONFIG_NAME);
         final SchemaContext schemaContext = mockSchema(moduleConfig);
         final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
-                Sets.newHashSet(), moduleConfig);
+                new HashSet<>(), moduleConfig);
 
         final GroupingDefinition mockedGrouping = mock(GroupingDefinition.class);
-        final Set<GroupingDefinition> groupings = Sets.newHashSet(mockedGrouping);
+        final Set<GroupingDefinition> groupings = Collections.singleton(mockedGrouping);
         doReturn(groupings).when(moduleConfig).getGroupings();
 
         final Set<GroupingDefinition> schemaContextProxyGroupings = filteringSchemaContextProxy.getGroupings();
@@ -553,38 +539,35 @@ public class SchemaContextProxyTest {
         final Module moduleConfig = mockModule(CONFIG_NAME);
         final SchemaContext schemaContext = mockSchema(moduleConfig);
         final FilteringSchemaContextProxy filteringSchemaContextProxy = createProxySchemaCtx(schemaContext,
-                Sets.newHashSet(), moduleConfig);
+                new HashSet<>(), moduleConfig);
 
-        final QName qName = QName.create("config-namespace", "2016-08-11", "cont");
+        final QName qname = QName.create("config-namespace", "2016-08-11", "cont");
         final ContainerSchemaNode mockedContainer = mock(ContainerSchemaNode.class);
         doReturn(mockedContainer).when(moduleConfig).getDataChildByName(any(QName.class));
 
-        final DataSchemaNode dataSchemaNode = filteringSchemaContextProxy.getDataChildByName(qName);
+        final DataSchemaNode dataSchemaNode = filteringSchemaContextProxy.getDataChildByName(qname);
         assertTrue(dataSchemaNode instanceof ContainerSchemaNode);
     }
 
-    private static void assertProxyContext(final FilteringSchemaContextProxy filteringSchemaContextProxy, final Module... expected) {
-
-        Set<Module> modSet = Sets.newHashSet();
-
-        if (expected!=null) {
-
-            modSet = Sets.newHashSet(expected);
-        }
+    private static void assertProxyContext(final FilteringSchemaContextProxy filteringSchemaContextProxy,
+            final Module... expected) {
 
+        final Set<Module> modSet = expected != null ? ImmutableSet.copyOf(expected) : new HashSet<>();
         Set<Module> modSetFiltering = filteringSchemaContextProxy.getModules();
 
         assertEquals(modSet, modSetFiltering);
 
         //asserting collections
-        if (expected!=null) {
+        if (expected != null) {
             for (final Module module : expected) {
-                assertEquals(module, filteringSchemaContextProxy.findModuleByName(module.getName(), module.getRevision()));
+                assertEquals(module, filteringSchemaContextProxy.findModuleByName(module.getName(),
+                            module.getRevision()));
 
                 Set<Module> mod = filteringSchemaContextProxy.findModuleByNamespace(module.getNamespace());
                 assertTrue(mod.contains(module));
 
-                assertEquals(module, filteringSchemaContextProxy.findModuleByNamespaceAndRevision(module.getNamespace(), module.getRevision()));
+                assertEquals(module, filteringSchemaContextProxy.findModuleByNamespaceAndRevision(module.getNamespace(),
+                            module.getRevision()));
 
                 assertEquals(module.getSource(), filteringSchemaContextProxy.getModuleSource(module).get());
             }
@@ -593,26 +576,19 @@ public class SchemaContextProxyTest {
 
     private static FilteringSchemaContextProxy createProxySchemaCtx(final SchemaContext schemaContext,
             final Set<Module> additionalModules, final Module... modules) {
-
         Set<Module> modulesSet = new HashSet<>();
-
-        if (modules!=null) {
-
-            modulesSet = Sets.newHashSet(modules);
-
+        if (modules != null) {
+            modulesSet = ImmutableSet.copyOf(modules);
         }
 
-        return new FilteringSchemaContextProxy(schemaContext, createModuleIds(modulesSet) , createModuleIds(additionalModules));
+        return new FilteringSchemaContextProxy(schemaContext, createModuleIds(modulesSet),
+                createModuleIds(additionalModules));
     }
 
     private static Set<ModuleId> createModuleIds(final Set<Module> modules) {
-
-        Set<ModuleId> moduleIds = Sets.newHashSet();
-
-        if (modules!=null && modules.size()>0) {
-
+        Set<ModuleId> moduleIds = new HashSet<>();
+        if (modules != null) {
             for (Module module : modules) {
-
                 moduleIds.add(new ModuleId(module.getName(), module.getRevision()));
             }
         }
@@ -621,7 +597,6 @@ public class SchemaContextProxyTest {
     }
 
     private static void mockSubmodules(final Module mainModule, final Module... submodules) {
-
         Set<Module> submodulesSet = new HashSet<>();
         submodulesSet.addAll(Arrays.asList(submodules));
 
@@ -629,7 +604,7 @@ public class SchemaContextProxyTest {
     }
 
     private static void mockModuleImport(final Module importer, final Module... imports) {
-        Set<ModuleImport> mockedImports = Sets.newHashSet();
+        Set<ModuleImport> mockedImports = new HashSet<>();
         for (final Module module : imports) {
             mockedImports.add(new ModuleImport() {
                 @Override
@@ -654,7 +629,6 @@ public class SchemaContextProxyTest {
 
                 @Override
                 public String toString() {
-
                     return String.format("Module: %s, revision:%s", module.getName(), module.getRevision());
                 }
             });
@@ -675,16 +649,16 @@ public class SchemaContextProxyTest {
     }
 
     //mock module with default revision
-    private static Module mockModule(final String mName) {
+    private static Module mockModule(final String name) {
 
         Module mockedModule = mock(Module.class);
-        doReturn(mName).when(mockedModule).getName();
+        doReturn(name).when(mockedModule).getName();
         doReturn(revision).when(mockedModule).getRevision();
-        final URI newNamespace = URI.create(namespace.toString() + ":" + mName);
+        final URI newNamespace = URI.create(namespace.toString() + ":" + name);
         doReturn(newNamespace).when(mockedModule).getNamespace();
         doReturn(QNameModule.create(newNamespace, revision)).when(mockedModule).getQNameModule();
         doReturn(TEST_SOURCE).when(mockedModule).getSource();
-        doReturn(Sets.newHashSet()).when(mockedModule).getSubmodules();
+        doReturn(new HashSet<>()).when(mockedModule).getSubmodules();
         doReturn(mockedModule.getQNameModule().toString()).when(mockedModule).toString();
         mockModuleImport(mockedModule);
 
index d69af03bb358be61046b5a61983d04714b5b580f..d7b751322b3fb62d90a82146b63a93bdd6afe91e 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import static org.junit.Assert.assertEquals;
+
 import java.util.Collections;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -21,31 +22,33 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
 
 public class SchemaContextUtilTest {
-    @Mock private SchemaContext mockSchemaContext;
-    @Mock private Module mockModule;
+    @Mock
+    private SchemaContext mockSchemaContext;
+    @Mock
+    private Module mockModule;
 
     @Test
     public void testFindDummyData() {
         MockitoAnnotations.initMocks(this);
 
-        QName qName = QName.create("TestQName");
-        SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(qName), true);
+        QName qname = QName.create("TestQName");
+        SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(qname), true);
         assertEquals("Should be null. Module TestQName not found", null,
                 SchemaContextUtil.findDataSchemaNode(mockSchemaContext, schemaPath));
 
-        RevisionAwareXPath xPath = new RevisionAwareXPathImpl("/bookstore/book/title", true);
+        RevisionAwareXPath xpath = new RevisionAwareXPathImpl("/bookstore/book/title", true);
         assertEquals("Should be null. Module bookstore not found", null,
-                SchemaContextUtil.findDataSchemaNode(mockSchemaContext, mockModule, xPath));
+                SchemaContextUtil.findDataSchemaNode(mockSchemaContext, mockModule, xpath));
 
         SchemaNode schemaNode = BaseTypes.int32Type();
-        RevisionAwareXPath xPathRelative = new RevisionAwareXPathImpl("../prefix", false);
+        RevisionAwareXPath xpathRelative = new RevisionAwareXPathImpl("../prefix", false);
         assertEquals("Should be null, Module prefix not found", null,
                 SchemaContextUtil.findDataSchemaNodeForRelativeXPath(
-                        mockSchemaContext, mockModule, schemaNode, xPathRelative));
+                        mockSchemaContext, mockModule, schemaNode, xpathRelative));
 
         assertEquals("Should be null. Module TestQName not found", null,
-                SchemaContextUtil.findNodeInSchemaContext(mockSchemaContext, Collections.singleton(qName)));
+                SchemaContextUtil.findNodeInSchemaContext(mockSchemaContext, Collections.singleton(qname)));
 
         assertEquals("Should be null.", null, SchemaContextUtil.findParentModule(mockSchemaContext, schemaNode));
     }
-}
\ No newline at end of file
+}
index cdae5415c07d607ba9eb485168609e736a9ed6ef..6ec194712e50169dc7b7be74e745063a8e846dc0 100644 (file)
@@ -7,18 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
-import com.google.common.base.Optional;
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Mock;
-import org.junit.Before;
-import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
-import org.junit.Test;
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 import static org.mockito.Mockito.doReturn;
-import static org.hamcrest.CoreMatchers.instanceOf;
+
+import com.google.common.base.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
 public class SchemaNodeUtilsTest {
 
index 5e640ae744e5b5454a6f19c7e3ecf08da79f4277..0310c2bce6fde2fed6f58167ae1b2ec221d85685 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import static java.util.Collections.emptyList;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Date;
@@ -35,11 +36,10 @@ public class BitImplTest {
         QName qnameA2 = QName.create(uriA2, new Date(7000000), "some nameA2");
         SchemaPath schemaPathA = SchemaPath.create(true, qnameA1, qnameA2);
 
-        QName qnameB1 = QName.create(uriB1, new Date(6000000), "some nameB1");
-        QName qnameB2 = QName.create(uriB2, new Date(7000000), "some nameB2");
-        SchemaPath schemaPathB = SchemaPath.create(true, qnameB1, qnameB2);
+        final QName qnameB1 = QName.create(uriB1, new Date(6000000), "some nameB1");
+        final QName qnameB2 = QName.create(uriB2, new Date(7000000), "some nameB2");
+        final SchemaPath schemaPathB = SchemaPath.create(true, qnameB1, qnameB2);
 
-        BitImpl biB;
         BitImpl biA = new BitImpl(schemaPathA, 55L, "description", "reference", Status.CURRENT, emptyList());
 
         assertEquals("biA should equals to itsefl", biA, biA);
@@ -48,7 +48,7 @@ public class BitImplTest {
 
          // // test schemaPath
         biA = new BitImpl(schemaPathA, 55L, "description", "reference", Status.CURRENT, emptyList());
-        biB = new BitImpl(schemaPathB, 55L, "description", "reference", Status.CURRENT, emptyList());
+        BitImpl biB = new BitImpl(schemaPathB, 55L, "description", "reference", Status.CURRENT, emptyList());
         assertFalse("biA shouldn't equal to biB", biA.equals(biB));
 
         biA = new BitImpl(schemaPathB, 55L, "description", "reference", Status.CURRENT, emptyList());
@@ -74,6 +74,7 @@ public class BitImplTest {
         assertEquals("Incorrect value for unknown nodes.", emptyList(), biA.getUnknownSchemaNodes());
 
         // test of toString method
-        assertEquals("toString method doesn't return correct value", "Bit[name=some nameA2, position=55]", biA.toString());
+        assertEquals("toString method doesn't return correct value", "Bit[name=some nameA2, position=55]",
+                biA.toString());
     }
 }
index de7272c44374f93614ee6b3ed0899cdb03a5fcea..bc742e5f50552951a27f3bbd89e07d296c8cd08e 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
+
 import com.google.common.base.Optional;
 import java.util.ArrayList;
 import org.junit.Test;
@@ -61,10 +62,10 @@ public class TypeTest {
                 SCHEMA_PATH).build();
         hashCodeEqualsToStringTest(derivedBinaryType1, derivedBinaryType2);
 
-        final RestrictedBinaryType restrictedBinaryType1 = (RestrictedBinaryType)RestrictedTypes.newBinaryBuilder
-                (baseBinaryType1, SCHEMA_PATH).buildType();
-        final RestrictedBinaryType restrictedBinaryType2 = (RestrictedBinaryType)RestrictedTypes.newBinaryBuilder
-                (baseBinaryType2, SCHEMA_PATH).buildType();
+        final RestrictedBinaryType restrictedBinaryType1 = (RestrictedBinaryType)RestrictedTypes.newBinaryBuilder(
+                baseBinaryType1, SCHEMA_PATH).buildType();
+        final RestrictedBinaryType restrictedBinaryType2 = (RestrictedBinaryType)RestrictedTypes.newBinaryBuilder(
+                baseBinaryType2, SCHEMA_PATH).buildType();
         hashCodeEqualsToStringTest(restrictedBinaryType1, restrictedBinaryType2);
 
         final LengthRestrictedTypeBuilder<BinaryTypeDefinition> lengthRestrictedTypeBuilder = RestrictedTypes
@@ -82,10 +83,10 @@ public class TypeTest {
         final BaseBooleanType baseBooleanType2 = (BaseBooleanType)BaseTypes.booleanType();
         hashCodeEqualsToStringTest(baseBooleanType1, baseBooleanType2);
 
-        final DerivedBooleanType derivedBooleanType1 = (DerivedBooleanType)DerivedTypes.derivedTypeBuilder
-                (baseBooleanType1, SCHEMA_PATH).build();
-        final DerivedBooleanType derivedBooleanType2 = (DerivedBooleanType)DerivedTypes.derivedTypeBuilder
-                (baseBooleanType1, SCHEMA_PATH).build();
+        final DerivedBooleanType derivedBooleanType1 = (DerivedBooleanType)DerivedTypes.derivedTypeBuilder(
+                baseBooleanType1, SCHEMA_PATH).build();
+        final DerivedBooleanType derivedBooleanType2 = (DerivedBooleanType)DerivedTypes.derivedTypeBuilder(
+                baseBooleanType1, SCHEMA_PATH).build();
         hashCodeEqualsToStringTest(derivedBooleanType1, derivedBooleanType2);
 
         restrictedBuilderTest(RestrictedTypes.newBooleanBuilder(baseBooleanType1, SCHEMA_PATH), RestrictedTypes
@@ -104,15 +105,15 @@ public class TypeTest {
         final IdentityrefTypeDefinition identityrefTypeDefinition2 = identityrefTypeBuilder2.build();
         hashCodeEqualsToStringTest(identityrefTypeDefinition1, identityrefTypeDefinition2);
 
-        final DerivedIdentityrefType derivedIdentityrefType1 = (DerivedIdentityrefType)DerivedTypes.derivedTypeBuilder
-                (identityrefTypeDefinition1, SCHEMA_PATH).build();
-        final DerivedIdentityrefType derivedIdentityrefType2 = (DerivedIdentityrefType)DerivedTypes.derivedTypeBuilder
-                (identityrefTypeDefinition2, SCHEMA_PATH).build();
+        final DerivedIdentityrefType derivedIdentityrefType1 = (DerivedIdentityrefType)DerivedTypes.derivedTypeBuilder(
+                identityrefTypeDefinition1, SCHEMA_PATH).build();
+        final DerivedIdentityrefType derivedIdentityrefType2 = (DerivedIdentityrefType)DerivedTypes.derivedTypeBuilder(
+                identityrefTypeDefinition2, SCHEMA_PATH).build();
         hashCodeEqualsToStringTest(derivedIdentityrefType1, derivedIdentityrefType2);
         concreteBuilderTest(identityrefTypeDefinition1, derivedIdentityrefType1);
 
-        restrictedBuilderTest(RestrictedTypes.newIdentityrefBuilder(derivedIdentityrefType1, SCHEMA_PATH), RestrictedTypes
-                .newIdentityrefBuilder(derivedIdentityrefType2, SCHEMA_PATH));
+        restrictedBuilderTest(RestrictedTypes.newIdentityrefBuilder(derivedIdentityrefType1, SCHEMA_PATH),
+                RestrictedTypes.newIdentityrefBuilder(derivedIdentityrefType2, SCHEMA_PATH));
     }
 
     @Test
@@ -146,10 +147,10 @@ public class TypeTest {
         final BaseEmptyType baseEmptyType2 = (BaseEmptyType)BaseTypes.emptyType();
         hashCodeEqualsToStringTest(baseEmptyType1, baseEmptyType2);
 
-        final DerivedEmptyType derivedEmptyType1 = (DerivedEmptyType)DerivedTypes.derivedTypeBuilder
-                (baseEmptyType1, SCHEMA_PATH).build();
-        final DerivedEmptyType derivedEmptyType2 = (DerivedEmptyType)DerivedTypes.derivedTypeBuilder
-                (baseEmptyType2, SCHEMA_PATH).build();
+        final DerivedEmptyType derivedEmptyType1 = (DerivedEmptyType)DerivedTypes.derivedTypeBuilder(
+                baseEmptyType1, SCHEMA_PATH).build();
+        final DerivedEmptyType derivedEmptyType2 = (DerivedEmptyType)DerivedTypes.derivedTypeBuilder(
+                baseEmptyType2, SCHEMA_PATH).build();
         hashCodeEqualsToStringTest(derivedEmptyType1, derivedEmptyType2);
 
         restrictedBuilderTest(RestrictedTypes.newEmptyBuilder(baseEmptyType1, SCHEMA_PATH),
@@ -174,11 +175,13 @@ public class TypeTest {
         final InstanceIdentifierTypeBuilder instanceIdentifierBuilder1 = RestrictedTypes
                 .newInstanceIdentifierBuilder(baseInstanceIdentifierType1, SCHEMA_PATH);
         instanceIdentifierBuilder1.setRequireInstance(true);
-        final InstanceIdentifierTypeDefinition instanceIdentifierTypeDefinition1 = instanceIdentifierBuilder1.buildType();
+        final InstanceIdentifierTypeDefinition instanceIdentifierTypeDefinition1 = instanceIdentifierBuilder1
+                .buildType();
         final InstanceIdentifierTypeBuilder instanceIdentifierBuilder2 = RestrictedTypes
                 .newInstanceIdentifierBuilder(baseInstanceIdentifierType1, SCHEMA_PATH);
         instanceIdentifierBuilder2.setRequireInstance(true);
-        final InstanceIdentifierTypeDefinition instanceIdentifierTypeDefinition2 = instanceIdentifierBuilder2.buildType();
+        final InstanceIdentifierTypeDefinition instanceIdentifierTypeDefinition2 = instanceIdentifierBuilder2
+                .buildType();
         hashCodeEqualsToStringTest(instanceIdentifierTypeDefinition2, instanceIdentifierTypeDefinition1);
         concreteBuilderTest(baseInstanceIdentifierType1, derivedInstanceIdentifierType1);
     }
@@ -198,10 +201,10 @@ public class TypeTest {
         testInstance(BaseInt32Type.INSTANCE, integerTypeDefinition32);
         testInstance(BaseInt64Type.INSTANCE, integerTypeDefinition64);
 
-        final RestrictedIntegerType restrictedIntegerType1 = (RestrictedIntegerType)RestrictedTypes.newIntegerBuilder
-                (integerTypeDefinition8, SCHEMA_PATH).buildType();
-        final RestrictedIntegerType restrictedIntegerType2 = (RestrictedIntegerType)RestrictedTypes.newIntegerBuilder
-                (BaseInt8Type.INSTANCE, SCHEMA_PATH).buildType();
+        final RestrictedIntegerType restrictedIntegerType1 = (RestrictedIntegerType)RestrictedTypes.newIntegerBuilder(
+                integerTypeDefinition8, SCHEMA_PATH).buildType();
+        final RestrictedIntegerType restrictedIntegerType2 = (RestrictedIntegerType)RestrictedTypes.newIntegerBuilder(
+                BaseInt8Type.INSTANCE, SCHEMA_PATH).buildType();
         hashCodeEqualsToStringTest(restrictedIntegerType1, restrictedIntegerType2);
 
         final UnsignedIntegerTypeDefinition integerTypeDefinitionu8 = BaseTypes.uint8Type();
@@ -237,7 +240,8 @@ public class TypeTest {
         concreteBuilderTest(integerTypeDefinition8, derivedIntegerType1);
         concreteBuilderTest(integerTypeDefinitionu8, derivedUnsignedType2);
 
-        final DerivedTypeBuilder<?> derivedTypeBuilder = DerivedTypes.derivedTypeBuilder(integerTypeDefinition8, SCHEMA_PATH);
+        final DerivedTypeBuilder<?> derivedTypeBuilder = DerivedTypes.derivedTypeBuilder(integerTypeDefinition8,
+                SCHEMA_PATH);
         derivedTypeBuilder.setDefaultValue(1);
         derivedTypeBuilder.setDescription("test-description");
         derivedTypeBuilder.setReference("test-reference");
@@ -299,10 +303,10 @@ public class TypeTest {
 
     @Test
     public void enumerationTypeTest() {
-        final BaseEnumerationType baseEnumerationType1 = (BaseEnumerationType)BaseTypes.enumerationTypeBuilder
-                (SCHEMA_PATH).build();
-        final BaseEnumerationType baseEnumerationType2 = (BaseEnumerationType)BaseTypes.enumerationTypeBuilder
-                (SCHEMA_PATH).build();
+        final BaseEnumerationType baseEnumerationType1 = (BaseEnumerationType)BaseTypes.enumerationTypeBuilder(
+                SCHEMA_PATH).build();
+        final BaseEnumerationType baseEnumerationType2 = (BaseEnumerationType)BaseTypes.enumerationTypeBuilder(
+                SCHEMA_PATH).build();
         hashCodeEqualsToStringTest(baseEnumerationType1, baseEnumerationType2);
         assertEquals(baseEnumerationType1.getValues(), baseEnumerationType2.getValues());
 
@@ -369,16 +373,16 @@ public class TypeTest {
 
     @Test
     public void abstractTypeDefinitionQnameTest() {
-        final AbstractTypeDefinition<?> abstractTypeDefinition = (AbstractTypeDefinition<?>)BaseTypes.decimalTypeBuilder
-                (SCHEMA_PATH).setFractionDigits(1).buildType();
+        final AbstractTypeDefinition<?> abstractTypeDefinition = (AbstractTypeDefinition<?>)
+            BaseTypes.decimalTypeBuilder(SCHEMA_PATH).setFractionDigits(1).buildType();
         assertEquals(abstractTypeDefinition.getQName(), Q_NAME);
     }
 
     @Test
     public void abstractDerivedTypeTest() {
         final BaseBinaryType baseBinaryType1 = BaseBinaryType.INSTANCE;
-        final AbstractDerivedType<?> abstractDerivedType = (AbstractDerivedType<?>) DerivedTypes.derivedTypeBuilder(baseBinaryType1,
-                SCHEMA_PATH).build();
+        final AbstractDerivedType<?> abstractDerivedType = (AbstractDerivedType<?>)
+            DerivedTypes.derivedTypeBuilder(baseBinaryType1, SCHEMA_PATH).build();
         assertEquals(abstractDerivedType.getDescription(), null);
         assertEquals(abstractDerivedType.getReference(), null);
         assertEquals(abstractDerivedType.getStatus().toString(), "CURRENT");
@@ -394,9 +398,10 @@ public class TypeTest {
 
     @Test
     public void concreteTypeBuilderBuildTest() {
-        final BaseEnumerationType baseEnumerationType1 = (BaseEnumerationType)BaseTypes.enumerationTypeBuilder
-                (SCHEMA_PATH).build();
-        final ConcreteTypeBuilder<?> concreteTypeBuilder = ConcreteTypes.concreteTypeBuilder(baseEnumerationType1, SCHEMA_PATH);
+        final BaseEnumerationType baseEnumerationType1 = (BaseEnumerationType)
+            BaseTypes.enumerationTypeBuilder(SCHEMA_PATH).build();
+        final ConcreteTypeBuilder<?> concreteTypeBuilder = ConcreteTypes.concreteTypeBuilder(
+                baseEnumerationType1, SCHEMA_PATH);
         final TypeDefinition<?> typeDefinition = concreteTypeBuilder.build();
         assertNotNull(typeDefinition);
     }
@@ -434,7 +439,7 @@ public class TypeTest {
         final UnresolvedNumber min = UnresolvedNumber.min();
         final UnresolvedNumber max = UnresolvedNumber.max();
         final LengthConstraint lengthConstraint = BaseConstraints.newLengthConstraint(min, max, absent, absent);
-        final RangeConstraint rangeConstraint= BaseConstraints.newRangeConstraint(min, max, absent, absent);
+        final RangeConstraint rangeConstraint = BaseConstraints.newRangeConstraint(min, max, absent, absent);
 
         final EnumPair enumPair = EnumPairBuilder.create("enum1", 1).setDescription("description")
                 .setReference("reference").setUnknownSchemaNodes(mock(UnknownSchemaNode.class)).build();
@@ -451,7 +456,7 @@ public class TypeTest {
                 BIT_A, "error msg", "other important messages");
         assertEquals(invalidBitDefinitionException.getOffendingBit(), BIT_A);
 
-        final InvalidEnumDefinitionException invalidEnumDefinitionException= new InvalidEnumDefinitionException(
+        final InvalidEnumDefinitionException invalidEnumDefinitionException = new InvalidEnumDefinitionException(
                 enumPair, "error msg", "other important messages");
         assertEquals(invalidEnumDefinitionException.getOffendingEnum(), enumPair);
     }
@@ -473,11 +478,11 @@ public class TypeTest {
 
     @Test(expected = InvalidEnumDefinitionException.class)
     public void invalidEnumDefinitionExceptionTest() {
-        final UnknownSchemaNode UNKNOWN_SCHEMA_NODE= mock(UnknownSchemaNode.class);
+        final UnknownSchemaNode unknown = mock(UnknownSchemaNode.class);
         final EnumPair enumPair1 = EnumPairBuilder.create("enum1", 1).setDescription("description")
-                .setReference("reference").setUnknownSchemaNodes(UNKNOWN_SCHEMA_NODE).build();
+                .setReference("reference").setUnknownSchemaNodes(unknown).build();
         final EnumPair enumPair2 = EnumPairBuilder.create("enum", 1).setDescription("description")
-                .setReference("reference").setUnknownSchemaNodes(UNKNOWN_SCHEMA_NODE).build();
+                .setReference("reference").setUnknownSchemaNodes(unknown).build();
         final EnumerationTypeBuilder enumerationTypeBuilder = BaseTypes.enumerationTypeBuilder(SCHEMA_PATH);
         enumerationTypeBuilder.addEnum(enumPair1);
         enumerationTypeBuilder.addEnum(enumPair2);
@@ -500,7 +505,8 @@ public class TypeTest {
         hashCodeEqualsToStringTest(typeDefinition1, typeDefinition2);
     }
 
-    private static void concreteBuilderTest(final TypeDefinition<?> baseTypeDef, final TypeDefinition<?> derivedTypeDef) {
+    private static void concreteBuilderTest(final TypeDefinition<?> baseTypeDef,
+            final TypeDefinition<?> derivedTypeDef) {
         final ConcreteTypeBuilder<?> concreteTypeBuilder = ConcreteTypes.concreteTypeBuilder(baseTypeDef, SCHEMA_PATH);
         final TypeDefinition<?> typeDefinition = concreteTypeBuilder.buildType();
         assertEquals(typeDefinition.getBaseType(), derivedTypeDef.getBaseType());