Address trivial eclipse warnings 01/48501/3
authorRobert Varga <rovarga@cisco.com>
Sat, 19 Nov 2016 14:51:40 +0000 (15:51 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 22 Nov 2016 12:14:00 +0000 (12:14 +0000)
- missing javadoc
- superfluous else branches
- checkstyle violations

Change-Id: Ibf74b95d6ae7d1c9889852f541cce3e9d6b28bb4
Signed-off-by: Robert Varga <rovarga@cisco.com>
32 files changed:
common/util/src/main/java/org/opendaylight/yangtools/util/ClassLoaderUtils.java
common/util/src/main/java/org/opendaylight/yangtools/util/DurationStatisticsTracker.java
common/util/src/main/java/org/opendaylight/yangtools/util/MapAdaptor.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/AsyncNotifyingListenableFutureTask.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/ExceptionMapper.java
common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/DeadlockDetectingListeningExecutorServiceTest.java
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/QName.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/FixedYangInstanceIdentifier.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/StackedPathArguments.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/StackedYangInstanceIdentifier.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNodes.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/stream/NormalizedNodeWriter.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/NormalizedNodeDataTreeCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/EnumStringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/SchemaTracker.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/UnionStringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefContextUtils.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefPath.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodes.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableUnkeyedListNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractDataTreeCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractModifiedNodeBasedCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractRecursiveCandidateNode.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlStreamUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedNodeUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaOrderedNormalizedNodeWriterTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModificationMetadataTreeTest.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/QNameCacheNamespace.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AugmentStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/NamedByteArrayInputStream.java

index 45f4e0ce49dc92a29862a4dee18773c6c1ed1c62..6e65b03658f58b55b3268dd03d9af9fffb49fbc7 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.util;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+
 import com.google.common.base.Joiner;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
@@ -109,9 +110,9 @@ public final class ClassLoaderUtils {
                 final String outerName = Joiner.on(".").join(components.subList(0, length));
                 final String innerName = outerName + "$" + components.get(length);
                 return cls.loadClass(innerName);
-            } else {
-                throw e;
             }
+
+            throw e;
         }
     }
 
index a551642e39b6f166405c0a7a4d86242c2eef5b10..c376afc2ade0f22b03884cc0f72ded2e6e67daa6 100644 (file)
@@ -182,11 +182,10 @@ public abstract class DurationStatisticsTracker {
     }
 
     private static String formatDuration(final DurationWithTime current) {
-        if (current != null) {
-            return formatDuration(current.getDuration(), current.getTimeMillis());
-        } else {
+        if (current == null) {
             return formatDuration(0, null);
         }
+        return formatDuration(current.getDuration(), current.getTimeMillis());
     }
 
     private static TimeUnit chooseUnit(final long nanos) {
index df404a079ee4c74d5f75398a3f27b1e4f83afc97..e6c23ddc05f84416c1b52afc22d734510b9e505a 100644 (file)
@@ -167,8 +167,8 @@ public final class MapAdaptor {
      * Input will be thrown away, result will be retained for read-only access or
      * {@link #takeSnapshot(Map)} purposes.
      *
-     * @param input
-     * @return
+     * @param input non-optimized (read-write) map
+     * @return  optimized read-only map
      */
     public <K, V> Map<K, V> optimize(final Map<K, V> input) {
         if (input instanceof ReadOnlyTrieMap) {
index 0e36b74da3dc9c8d50721388ee438197cfa84fb0..53629b033055c47f9d84018c240888e2226df7fd 100644 (file)
@@ -136,11 +136,10 @@ public class AsyncNotifyingListenableFutureTask<V> extends FutureTask<V> impleme
      */
     public static <V> AsyncNotifyingListenableFutureTask<V> create(final Callable<V> callable,
             @Nullable final Executor listenerExecutor) {
-        if (listenerExecutor != null) {
-            return new DelegatingAsyncNotifyingListenableFutureTask<>(callable, listenerExecutor);
-        } else {
+        if (listenerExecutor == null) {
             return new AsyncNotifyingListenableFutureTask<>(callable);
         }
+        return new DelegatingAsyncNotifyingListenableFutureTask<>(callable, listenerExecutor);
     }
 
     /**
@@ -155,11 +154,10 @@ public class AsyncNotifyingListenableFutureTask<V> extends FutureTask<V> impleme
      */
     public static <V> AsyncNotifyingListenableFutureTask<V> create(final Runnable runnable, @Nullable final V result,
             @Nullable final Executor listenerExecutor) {
-        if (listenerExecutor != null) {
-            return new DelegatingAsyncNotifyingListenableFutureTask<>(runnable, result, listenerExecutor);
-        } else {
+        if (listenerExecutor == null) {
             return new AsyncNotifyingListenableFutureTask<>(runnable, result);
         }
+        return new DelegatingAsyncNotifyingListenableFutureTask<>(runnable, result, listenerExecutor);
     }
 
     @Override
index 1616cd24aaebc4c6b7512c7493195b629194ebcd..b109b190a94b190425b9a2a051d1723b519758ce 100644 (file)
@@ -81,22 +81,21 @@ public abstract class ExceptionMapper<X extends Exception> implements Function<E
         // If exception is ExecutionException whose cause is of the specified
         // type, return the cause.
         if (e instanceof ExecutionException && e.getCause() != null) {
-            if (exceptionType.isAssignableFrom( e.getCause().getClass())) {
+            if (exceptionType.isAssignableFrom(e.getCause().getClass())) {
                 return (X) e.getCause();
-            } else {
-                return newWithCause(opName + " execution failed", e.getCause());
             }
+            return newWithCause(opName + " execution failed", e.getCause());
         }
 
         // Otherwise return an instance of the specified type with the original
         // cause.
 
         if (e instanceof InterruptedException) {
-            return newWithCause( opName + " was interupted.", e);
+            return newWithCause(opName + " was interupted.", e);
         }
 
         if (e instanceof CancellationException ) {
-            return newWithCause( opName + " was cancelled.", e);
+            return newWithCause(opName + " was cancelled.", e);
         }
 
         // We really shouldn't get here but need to cover it anyway for completeness.
index fa322277f732d0f108c6e45ed008ff13b6a3cb71..7ca99127a194df4cb474f257e2e97bd4f198938b 100644 (file)
@@ -42,15 +42,16 @@ import org.opendaylight.yangtools.util.concurrent.CommonTestUtils.Invoker;
 public class DeadlockDetectingListeningExecutorServiceTest {
 
     interface InitialInvoker {
-        void invokeExecutor( ListeningExecutorService executor, Runnable task );
+        void invokeExecutor(ListeningExecutorService executor, Runnable task);
     }
 
     static final InitialInvoker SUBMIT = ListeningExecutorService::submit;
 
     static final InitialInvoker EXECUTE = Executor::execute;
 
-    @SuppressWarnings("serial")
     public static class TestDeadlockException extends Exception {
+        private static final long serialVersionUID = 1L;
+
     }
 
     private static final Supplier<Exception> DEADLOCK_EXECUTOR_SUPPLIER = TestDeadlockException::new;
@@ -63,14 +64,14 @@ public class DeadlockDetectingListeningExecutorServiceTest {
 
     @After
     public void tearDown() {
-        if (executor != null ) {
+        if (executor != null) {
             executor.shutdownNow();
         }
     }
 
     DeadlockDetectingListeningExecutorService newExecutor() {
-        return new DeadlockDetectingListeningExecutorService( Executors.newSingleThreadExecutor(),
-                DEADLOCK_EXECUTOR_SUPPLIER );
+        return new DeadlockDetectingListeningExecutorService(Executors.newSingleThreadExecutor(),
+                DEADLOCK_EXECUTOR_SUPPLIER);
     }
 
     @Test
@@ -82,7 +83,7 @@ public class DeadlockDetectingListeningExecutorServiceTest {
 
         ListenableFuture<String> future = executor.submit(() -> "foo");
 
-        assertEquals( "Future result", "foo", future.get( 5, TimeUnit.SECONDS ) );
+        assertEquals( "Future result", "foo", future.get( 5, TimeUnit.SECONDS));
 
         // Test submit with Runnable.
 
@@ -91,10 +92,9 @@ public class DeadlockDetectingListeningExecutorServiceTest {
 
         // Test submit with Runnable and value.
 
-        future = executor.submit(() -> {
-        }, "foo" );
+        future = executor.submit(() -> { }, "foo");
 
-        assertEquals( "Future result", "foo", future.get( 5, TimeUnit.SECONDS ) );
+        assertEquals("Future result", "foo", future.get(5, TimeUnit.SECONDS));
     }
 
     @Test
@@ -102,38 +102,38 @@ public class DeadlockDetectingListeningExecutorServiceTest {
 
         executor = newExecutor();
 
-        testNonBlockingSubmitOnExecutorThread( SUBMIT, SUBMIT_CALLABLE );
-        testNonBlockingSubmitOnExecutorThread( SUBMIT, SUBMIT_RUNNABLE );
-        testNonBlockingSubmitOnExecutorThread( SUBMIT, SUBMIT_RUNNABLE_WITH_RESULT );
+        testNonBlockingSubmitOnExecutorThread(SUBMIT, SUBMIT_CALLABLE);
+        testNonBlockingSubmitOnExecutorThread(SUBMIT, SUBMIT_RUNNABLE);
+        testNonBlockingSubmitOnExecutorThread(SUBMIT, SUBMIT_RUNNABLE_WITH_RESULT);
 
-        testNonBlockingSubmitOnExecutorThread( EXECUTE, SUBMIT_CALLABLE );
+        testNonBlockingSubmitOnExecutorThread(EXECUTE, SUBMIT_CALLABLE);
     }
 
-    void testNonBlockingSubmitOnExecutorThread( final InitialInvoker initialInvoker,
-            final Invoker invoker ) throws Throwable {
+    void testNonBlockingSubmitOnExecutorThread(final InitialInvoker initialInvoker, final Invoker invoker)
+            throws Throwable {
 
         final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
-        final CountDownLatch futureCompletedLatch = new CountDownLatch( 1 );
+        final CountDownLatch futureCompletedLatch = new CountDownLatch(1);
 
-        Runnable task = () -> Futures.addCallback( invoker.invokeExecutor( executor, null ), new FutureCallback() {
+        Runnable task = () -> Futures.addCallback(invoker.invokeExecutor(executor, null), new FutureCallback<Object>() {
             @Override
-            public void onSuccess( final Object result ) {
+            public void onSuccess(final Object result) {
                 futureCompletedLatch.countDown();
             }
 
             @Override
-            public void onFailure( final Throwable t ) {
-                caughtEx.set( t );
+            public void onFailure(final Throwable t) {
+                caughtEx.set(t);
                 futureCompletedLatch.countDown();
             }
-        } );
+        });
 
-        initialInvoker.invokeExecutor( executor, task );
+        initialInvoker.invokeExecutor(executor, task);
 
-        assertTrue( "Task did not complete - executor likely deadlocked",
-                futureCompletedLatch.await( 5, TimeUnit.SECONDS ) );
+        assertTrue("Task did not complete - executor likely deadlocked",
+                futureCompletedLatch.await(5, TimeUnit.SECONDS));
 
-        if (caughtEx.get() != null ) {
+        if (caughtEx.get() != null) {
             throw caughtEx.get();
         }
     }
@@ -143,57 +143,54 @@ public class DeadlockDetectingListeningExecutorServiceTest {
 
         executor = newExecutor();
 
-        testBlockingSubmitOnExecutorThread( SUBMIT, SUBMIT_CALLABLE );
-        testBlockingSubmitOnExecutorThread( SUBMIT, SUBMIT_RUNNABLE );
-        testBlockingSubmitOnExecutorThread( SUBMIT, SUBMIT_RUNNABLE_WITH_RESULT );
+        testBlockingSubmitOnExecutorThread(SUBMIT, SUBMIT_CALLABLE);
+        testBlockingSubmitOnExecutorThread(SUBMIT, SUBMIT_RUNNABLE);
+        testBlockingSubmitOnExecutorThread(SUBMIT, SUBMIT_RUNNABLE_WITH_RESULT);
 
-        testBlockingSubmitOnExecutorThread( EXECUTE, SUBMIT_CALLABLE );
+        testBlockingSubmitOnExecutorThread(EXECUTE, SUBMIT_CALLABLE);
     }
 
-    void testBlockingSubmitOnExecutorThread( final InitialInvoker initialInvoker,
-            final Invoker invoker ) throws Exception {
+    void testBlockingSubmitOnExecutorThread(final InitialInvoker initialInvoker, final Invoker invoker)
+            throws Exception {
 
         final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
-        final CountDownLatch latch = new CountDownLatch( 1 );
+        final CountDownLatch latch = new CountDownLatch(1);
 
         Runnable task = () -> {
 
             try {
-                invoker.invokeExecutor( executor, null ).get();
-            } catch( ExecutionException e ) {
-                caughtEx.set( e.getCause() );
-            } catch( Throwable e ) {
-                caughtEx.set( e );
+                invoker.invokeExecutor(executor, null).get();
+            } catch(ExecutionException e) {
+                caughtEx.set(e.getCause());
+            } catch(Throwable e) {
+                caughtEx.set(e);
             } finally {
                 latch.countDown();
             }
         };
 
-        initialInvoker.invokeExecutor( executor, task );
-
-        assertTrue( "Task did not complete - executor likely deadlocked",
-                latch.await( 5, TimeUnit.SECONDS ) );
+        initialInvoker.invokeExecutor(executor, task);
 
-        assertNotNull( "Expected exception thrown", caughtEx.get() );
-        assertEquals( "Caught exception type", TestDeadlockException.class, caughtEx.get().getClass() );
+        assertTrue("Task did not complete - executor likely deadlocked", latch.await( 5, TimeUnit.SECONDS));
+        assertNotNull("Expected exception thrown", caughtEx.get());
+        assertEquals("Caught exception type", TestDeadlockException.class, caughtEx.get().getClass());
     }
 
     @Test
     public void testListenableFutureCallbackWithExecutor() throws InterruptedException {
 
         String listenerThreadPrefix = "ListenerThread";
-        ExecutorService listenerExecutor = Executors.newFixedThreadPool( 1,
-                new ThreadFactoryBuilder().setNameFormat( listenerThreadPrefix + "-%d" ).build() );
+        ExecutorService listenerExecutor = Executors.newFixedThreadPool(1,
+                new ThreadFactoryBuilder().setNameFormat(listenerThreadPrefix + "-%d").build());
 
         executor = new DeadlockDetectingListeningExecutorService(
-                Executors.newSingleThreadExecutor(
-                        new ThreadFactoryBuilder().setNameFormat( "SingleThread" ).build() ),
-                        DEADLOCK_EXECUTOR_SUPPLIER, listenerExecutor );
+            Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("SingleThread").build()),
+                DEADLOCK_EXECUTOR_SUPPLIER, listenerExecutor);
 
         try {
-            testListenerCallback( executor, SUBMIT_CALLABLE, listenerThreadPrefix );
-            testListenerCallback( executor, SUBMIT_RUNNABLE, listenerThreadPrefix );
-            testListenerCallback( executor, SUBMIT_RUNNABLE_WITH_RESULT, listenerThreadPrefix );
+            testListenerCallback(executor, SUBMIT_CALLABLE, listenerThreadPrefix);
+            testListenerCallback(executor, SUBMIT_RUNNABLE, listenerThreadPrefix);
+            testListenerCallback(executor, SUBMIT_RUNNABLE_WITH_RESULT, listenerThreadPrefix);
         } finally {
             listenerExecutor.shutdownNow();
         }
index 12a01fa1b820e45816680d251a08c09a87216a47..d49078681b9f7d5048de5b8edbcf59694e68866d 100644 (file)
@@ -266,7 +266,6 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
     }
 
     /**
-     *
      * Creates new QName.
      *
      * @param namespace
@@ -276,7 +275,7 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
      *            in format <code>YYYY-mm-dd</code>.
      * @param localName
      *            Local name part of QName. MUST NOT BE null.
-     * @return
+     * @return A new QName
      * @throws NullPointerException
      *             If any of parameters is null.
      * @throws IllegalArgumentException
@@ -305,7 +304,7 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
      *            Namespace of QName, MUST NOT BE Null.
      * @param localName
      *            Local name part of QName. MUST NOT BE null.
-     * @return
+     * @return A new QName
      * @throws NullPointerException
      *             If any of parameters is null.
      * @throws IllegalArgumentException
index 39afcacba28b74c855da5ebd1a4b35b20aac2658..d5a07238e300fca6391f7d55f895b160c9089ed4 100644 (file)
@@ -120,9 +120,8 @@ final class FixedYangInstanceIdentifier extends YangInstanceIdentifier implement
     boolean pathArgumentsEqual(final YangInstanceIdentifier other) {
         if (other instanceof FixedYangInstanceIdentifier) {
             return path.equals(((FixedYangInstanceIdentifier) other).path);
-        } else {
-            return super.pathArgumentsEqual(other);
         }
+        return super.pathArgumentsEqual(other);
     }
 
     @Override
index 94596ceedc3d7163ec308c49467d218db06f9654..7279b58f4b0c4253698791eba1e9880ceefa1ca2 100644 (file)
@@ -40,9 +40,8 @@ final class StackedPathArguments extends PathArgumentList {
     public PathArgument get(final int index) {
         if (index < base.size()) {
             return base.get(index);
-        } else {
-            return stack.get(index - base.size());
         }
+        return stack.get(index - base.size());
     }
 
     @Override
index 5ccc73759a97095fa280792268081cecaf207a4f..35de59be97095e184312f4e523576a28a85c9938 100644 (file)
@@ -153,9 +153,8 @@ final class StackedYangInstanceIdentifier extends YangInstanceIdentifier impleme
         if (other instanceof StackedYangInstanceIdentifier) {
             final StackedYangInstanceIdentifier stacked = (StackedYangInstanceIdentifier) other;
             return pathArgument.equals(stacked.pathArgument) && parent.equals(stacked.parent);
-        } else {
-            return super.pathArgumentsEqual(other);
         }
+        return super.pathArgumentsEqual(other);
     }
 
     private void readObject(final ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
index fc0302ba4ff9c34076614f08dc171cd938193caa..34d23c5a3e84cf41f333f056b63b651b19ad3cfc 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.data.api.schema;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+
 import com.google.common.annotations.Beta;
 import com.google.common.base.Optional;
 import com.google.common.base.Strings;
@@ -35,11 +36,7 @@ public final class NormalizedNodes {
 
     public static Optional<NormalizedNode<?, ?>> findNode(final YangInstanceIdentifier rootPath, final NormalizedNode<?, ?> rootNode, final YangInstanceIdentifier childPath) {
         final Optional<YangInstanceIdentifier> relativePath = childPath.relativeTo(rootPath);
-        if (relativePath.isPresent()) {
-            return findNode(rootNode, relativePath.get());
-        } else {
-            return Optional.absent();
-        }
+        return relativePath.isPresent() ? findNode(rootNode, relativePath.get()) : Optional.absent();
     }
 
     public static Optional<NormalizedNode<?, ?>> findNode(final Optional<NormalizedNode<?, ?>> parent, final Iterable<PathArgument> relativePath) {
index 2d91bf34e6eb6f2af0314abfcc29b48b602c8a20..29702b22f1223041adb9cc557cf7527f95ce10e5 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.data.api.schema.stream;
 
 import static org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter.UNKNOWN_SIZE;
+
 import com.google.common.annotations.Beta;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
@@ -81,11 +82,7 @@ public class NormalizedNodeWriter implements Closeable, Flushable {
      * @return A new instance.
      */
     public static NormalizedNodeWriter forStreamWriter(final NormalizedNodeStreamWriter writer, final boolean orderKeyLeaves) {
-        if (orderKeyLeaves) {
-            return new OrderedNormalizedNodeWriter(writer);
-        } else {
-            return new NormalizedNodeWriter(writer);
-        }
+        return orderKeyLeaves ? new OrderedNormalizedNodeWriter(writer) : new NormalizedNodeWriter(writer);
     }
 
     /**
index 0b0bd7cbf5d7159242852f7d6016823b57184341..d41a334d68cdfb5c38c98de303264ea84d5460b5 100644 (file)
@@ -11,8 +11,8 @@ import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
 import java.util.Collection;
-import java.util.Collections;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -49,9 +49,8 @@ final class NormalizedNodeDataTreeCandidateNode implements DataTreeCandidateNode
     public Collection<DataTreeCandidateNode> getChildNodes() {
         if (data instanceof NormalizedNodeContainer) {
             return Collections2.transform(((NormalizedNodeContainer<?, ?, ?>) data).getValue(), FACTORY_FUNCTION);
-        } else {
-            return Collections.emptyList();
         }
+        return ImmutableList.of();
     }
 
     @Override
@@ -60,9 +59,8 @@ final class NormalizedNodeDataTreeCandidateNode implements DataTreeCandidateNode
             @SuppressWarnings({ "rawtypes", "unchecked" })
             final Optional<? extends NormalizedNode<?, ?>> child = ((NormalizedNodeContainer)data).getChild(identifier);
             return FACTORY_FUNCTION.apply(child.orNull());
-        } else {
-            return null;
         }
+        return null;
     }
 
     @Override
index 54fe384de8334340c12522b0a53876779b7d835f..bfc67e49bb00be34c5ec3f1618ae56a1a552ebb3 100644 (file)
@@ -41,16 +41,16 @@ final class EnumStringCodec extends TypeDefinitionAwareCodec<String, EnumTypeDef
 
     @Override
     public String deserialize(final String s) {
-        if (values != null) {
-            // Lookup the serialized string in the values. Returned string is the interned instance, which we want
-            // to use as the result.
-            final String result = values.get(s);
-            Preconditions.checkArgument(result != null, "Invalid value '%s' for enum type. Allowed values are: %s",
-                s, values.keySet());
-            return result;
-        } else {
+        if (values == null) {
             return s;
         }
+
+        // Lookup the serialized string in the values. Returned string is the interned instance, which we want
+        // to use as the result.
+        final String result = values.get(s);
+        Preconditions.checkArgument(result != null, "Invalid value '%s' for enum type. Allowed values are: %s",
+                s, values.keySet());
+        return result;
     }
 
     @Override
index 1f6adf8bf96496a94f53692d309a61d0b203f80c..18dbab2b3e67892381e85dad6237f4a5b1f11286 100644 (file)
@@ -172,12 +172,12 @@ public final class SchemaTracker {
         final Object parent = getParent();
         if (parent instanceof LeafListSchemaNode) {
             return (LeafListSchemaNode) parent;
-        } else {
-            final SchemaNode child = SchemaUtils.findChildSchemaByQName((SchemaNode) parent, qname);
-            Preconditions.checkArgument(child instanceof LeafListSchemaNode,
-                    "Node %s is neither a leaf-list nor currently in a leaf-list", child.getPath());
-            return (LeafListSchemaNode) child;
         }
+
+        final SchemaNode child = SchemaUtils.findChildSchemaByQName((SchemaNode) parent, qname);
+        Preconditions.checkArgument(child instanceof LeafListSchemaNode,
+            "Node %s is neither a leaf-list nor currently in a leaf-list", child.getPath());
+        return (LeafListSchemaNode) child;
     }
 
     public ChoiceSchemaNode startChoiceNode(final NodeIdentifier name) {
index 6d47ab94ab774f95eb194529ef2ad105b6e35796..5dea5939e7dc022c3650895fbe2b19bd4f699317 100644 (file)
@@ -33,9 +33,8 @@ final class UnionStringCodec extends TypeDefinitionAwareCodec<Object, UnionTypeD
     public String serialize(final Object data) {
         if (data instanceof byte[]) {
             return BaseEncoding.base64().encode((byte[]) data);
-        } else {
-            return Objects.toString(data, "");
         }
+        return Objects.toString(data, "");
     }
 
     @Override
index c4705eae40b67f9303c699b2c6dd3a9a888e8a03..e29efe94304bc7f096e60c2984188d25c8299b2b 100644 (file)
@@ -24,8 +24,7 @@ public final class LeafRefContextUtils {
         throw new UnsupportedOperationException();
     }
 
-    public static LeafRefContext getLeafRefReferencingContext(final SchemaNode node,
-            final LeafRefContext root) {
+    public static LeafRefContext getLeafRefReferencingContext(final SchemaNode node, final LeafRefContext root) {
         final SchemaPath schemaPath = node.getPath();
         return getLeafRefReferencingContext(schemaPath, root);
     }
@@ -36,9 +35,7 @@ public final class LeafRefContextUtils {
         return getLeafRefReferencingContext(pathFromRoot, root);
     }
 
-    public static LeafRefContext getLeafRefReferencingContext(
-            final Iterable<QName> pathFromRoot, LeafRefContext root) {
-
+    public static LeafRefContext getLeafRefReferencingContext(final Iterable<QName> pathFromRoot, LeafRefContext root) {
         LeafRefContext leafRefCtx = null;
         final Iterator<QName> iterator = pathFromRoot.iterator();
         while (iterator.hasNext() && root != null) {
@@ -52,8 +49,7 @@ public final class LeafRefContextUtils {
         return leafRefCtx;
     }
 
-    public static LeafRefContext getLeafRefReferencedByContext(final SchemaNode node,
-            final LeafRefContext root) {
+    public static LeafRefContext getLeafRefReferencedByContext(final SchemaNode node, final LeafRefContext root) {
         final SchemaPath schemaPath = node.getPath();
         return getLeafRefReferencedByContext(schemaPath, root);
     }
@@ -64,8 +60,8 @@ public final class LeafRefContextUtils {
         return getLeafRefReferencedByContext(pathFromRoot, root);
     }
 
-    public static LeafRefContext getLeafRefReferencedByContext(
-            final Iterable<QName> pathFromRoot, LeafRefContext root) {
+    public static LeafRefContext getLeafRefReferencedByContext(final Iterable<QName> pathFromRoot,
+            LeafRefContext root) {
 
         LeafRefContext leafRefCtx = null;
         final Iterator<QName> iterator = pathFromRoot.iterator();
@@ -81,13 +77,11 @@ public final class LeafRefContextUtils {
     }
 
     public static boolean isLeafRef(final SchemaNode node, final LeafRefContext root) {
-
         if (node == null || root == null) {
             return false;
         }
 
-        final LeafRefContext leafRefReferencingContext = getLeafRefReferencingContext(
-                node, root);
+        final LeafRefContext leafRefReferencingContext = getLeafRefReferencingContext(node, root);
         if (leafRefReferencingContext == null) {
             return false;
         }
@@ -96,13 +90,11 @@ public final class LeafRefContextUtils {
     }
 
     public static boolean hasLeafRefChild(final SchemaNode node, final LeafRefContext root) {
-
         if (node == null || root == null) {
             return false;
         }
 
-        final LeafRefContext leafRefReferencingContext = getLeafRefReferencingContext(
-                node, root);
+        final LeafRefContext leafRefReferencingContext = getLeafRefReferencingContext(node, root);
         if (leafRefReferencingContext == null) {
             return false;
         }
@@ -110,15 +102,12 @@ public final class LeafRefContextUtils {
         return leafRefReferencingContext.hasReferencingChild();
     }
 
-    public static boolean isReferencedByLeafRef(final SchemaNode node,
-            final LeafRefContext root) {
-
+    public static boolean isReferencedByLeafRef(final SchemaNode node, final LeafRefContext root) {
         if (node == null || root == null) {
             return false;
         }
 
-        final LeafRefContext leafRefReferencedByContext = getLeafRefReferencedByContext(
-                node, root);
+        final LeafRefContext leafRefReferencedByContext = getLeafRefReferencedByContext(node, root);
         if (leafRefReferencedByContext == null) {
             return false;
         }
@@ -126,15 +115,12 @@ public final class LeafRefContextUtils {
         return leafRefReferencedByContext.isReferenced();
     }
 
-    public static boolean hasChildReferencedByLeafRef(final SchemaNode node,
-            final LeafRefContext root) {
-
-        if ((node == null) || (root == null)) {
+    public static boolean hasChildReferencedByLeafRef(final SchemaNode node, final LeafRefContext root) {
+        if (node == null || root == null) {
             return false;
         }
 
-        final LeafRefContext leafRefReferencedByContext = getLeafRefReferencedByContext(
-                node, root);
+        final LeafRefContext leafRefReferencedByContext = getLeafRefReferencedByContext(node, root);
         if (leafRefReferencedByContext == null) {
             return false;
         }
@@ -142,33 +128,24 @@ public final class LeafRefContextUtils {
         return leafRefReferencedByContext.hasReferencedChild();
     }
 
-    public static List<LeafRefContext> findAllLeafRefChilds(final SchemaNode node,
-            final LeafRefContext root) {
-
+    public static List<LeafRefContext> findAllLeafRefChilds(final SchemaNode node, final LeafRefContext root) {
         return findAllLeafRefChilds(node.getPath(), root);
     }
 
-    public static List<LeafRefContext> findAllLeafRefChilds(
-            final SchemaPath schemaPath, final LeafRefContext root) {
-
+    public static List<LeafRefContext> findAllLeafRefChilds(final SchemaPath schemaPath, final LeafRefContext root) {
         return findAllLeafRefChilds(schemaPath.getPathFromRoot(), root);
     }
 
-    public static List<LeafRefContext> findAllLeafRefChilds(
-            final Iterable<QName> pathFromRoot, final LeafRefContext root) {
-
-        final LeafRefContext leafRefReferencingContext = getLeafRefReferencingContext(
-                pathFromRoot, root);
+    public static List<LeafRefContext> findAllLeafRefChilds(final Iterable<QName> pathFromRoot,
+            final LeafRefContext root) {
+        final LeafRefContext leafRefReferencingContext = getLeafRefReferencingContext(pathFromRoot, root);
         final List<LeafRefContext> allLeafRefsChilds = findAllLeafRefChilds(leafRefReferencingContext);
 
         return allLeafRefsChilds;
     }
 
-    public static List<LeafRefContext> findAllLeafRefChilds(
-            final LeafRefContext parent) {
-
+    public static List<LeafRefContext> findAllLeafRefChilds(final LeafRefContext parent) {
         final LinkedList<LeafRefContext> leafRefChilds = new LinkedList<>();
-
         if (parent == null) {
             return leafRefChilds;
         }
@@ -176,44 +153,37 @@ public final class LeafRefContextUtils {
         if (parent.isReferencing()) {
             leafRefChilds.add(parent);
             return leafRefChilds;
-        } else {
-            final Set<Entry<QName, LeafRefContext>> childs = parent
-                    .getReferencingChilds().entrySet();
-            for (final Entry<QName, LeafRefContext> child : childs) {
-                leafRefChilds.addAll(findAllLeafRefChilds(child.getValue()));
-            }
+        }
+
+        final Set<Entry<QName, LeafRefContext>> childs = parent.getReferencingChilds().entrySet();
+        for (final Entry<QName, LeafRefContext> child : childs) {
+            leafRefChilds.addAll(findAllLeafRefChilds(child.getValue()));
         }
         return leafRefChilds;
     }
 
-    public static List<LeafRefContext> findAllChildsReferencedByLeafRef(
-            final SchemaNode node, final LeafRefContext root) {
-
+    public static List<LeafRefContext> findAllChildsReferencedByLeafRef(final SchemaNode node,
+            final LeafRefContext root) {
         return findAllChildsReferencedByLeafRef(node.getPath(), root);
     }
 
-    public static List<LeafRefContext> findAllChildsReferencedByLeafRef(
-            final SchemaPath schemaPath, final LeafRefContext root) {
-
-        return findAllChildsReferencedByLeafRef(schemaPath.getPathFromRoot(),
-                root);
+    public static List<LeafRefContext> findAllChildsReferencedByLeafRef(final SchemaPath schemaPath,
+            final LeafRefContext root) {
+        return findAllChildsReferencedByLeafRef(schemaPath.getPathFromRoot(), root);
     }
 
-    public static List<LeafRefContext> findAllChildsReferencedByLeafRef(
-            final Iterable<QName> pathFromRoot, final LeafRefContext root) {
+    public static List<LeafRefContext> findAllChildsReferencedByLeafRef(final Iterable<QName> pathFromRoot,
+            final LeafRefContext root) {
 
-        final LeafRefContext leafRefReferencedByContext = getLeafRefReferencedByContext(
-                pathFromRoot, root);
-        final List<LeafRefContext> allChildsReferencedByLeafRef = findAllChildsReferencedByLeafRef(leafRefReferencedByContext);
+        final LeafRefContext leafRefReferencedByContext = getLeafRefReferencedByContext(pathFromRoot, root);
+        final List<LeafRefContext> allChildsReferencedByLeafRef =
+                findAllChildsReferencedByLeafRef(leafRefReferencedByContext);
 
         return allChildsReferencedByLeafRef;
     }
 
-    public static List<LeafRefContext> findAllChildsReferencedByLeafRef(
-            final LeafRefContext parent) {
-
+    public static List<LeafRefContext> findAllChildsReferencedByLeafRef(final LeafRefContext parent) {
         final LinkedList<LeafRefContext> childsReferencedByLeafRef = new LinkedList<>();
-
         if (parent == null) {
             return childsReferencedByLeafRef;
         }
@@ -221,14 +191,11 @@ public final class LeafRefContextUtils {
         if (parent.isReferenced()) {
             childsReferencedByLeafRef.add(parent);
             return childsReferencedByLeafRef;
-        } else {
-            final Set<Entry<QName, LeafRefContext>> childs = parent
-                    .getReferencedByChilds().entrySet();
-            for (final Entry<QName, LeafRefContext> child : childs) {
-                childsReferencedByLeafRef
-                        .addAll(findAllChildsReferencedByLeafRef(child
-                                .getValue()));
-            }
+        }
+
+        final Set<Entry<QName, LeafRefContext>> childs = parent.getReferencedByChilds().entrySet();
+        for (final Entry<QName, LeafRefContext> child : childs) {
+            childsReferencedByLeafRef.addAll(findAllChildsReferencedByLeafRef(child.getValue()));
         }
         return childsReferencedByLeafRef;
     }
@@ -238,22 +205,19 @@ public final class LeafRefContextUtils {
         return getAllLeafRefsReferencingThisNode(node.getPath(), root);
     }
 
-    public static Map<QName, LeafRefContext> getAllLeafRefsReferencingThisNode(
-            final SchemaPath path, final LeafRefContext root) {
+    public static Map<QName, LeafRefContext> getAllLeafRefsReferencingThisNode(final SchemaPath path,
+            final LeafRefContext root) {
         return getAllLeafRefsReferencingThisNode(path.getPathFromRoot(), root);
     }
 
-    public static Map<QName, LeafRefContext> getAllLeafRefsReferencingThisNode(
-            final Iterable<QName> pathFromRoot, final LeafRefContext root) {
-
-        final LeafRefContext leafRefReferencedByContext = getLeafRefReferencedByContext(
-                pathFromRoot, root);
+    public static Map<QName, LeafRefContext> getAllLeafRefsReferencingThisNode(final Iterable<QName> pathFromRoot,
+            final LeafRefContext root) {
 
+        final LeafRefContext leafRefReferencedByContext = getLeafRefReferencedByContext(pathFromRoot, root);
         if (leafRefReferencedByContext == null) {
             return new HashMap<>();
         }
 
         return leafRefReferencedByContext.getAllReferencedByLeafRefCtxs();
     }
-
 }
index 84f17d195d462f8bcb7074f6d9b8ab018baa0c7e..988de8e8874ee9fd7ad3140e16517a21a234fc3f 100644 (file)
@@ -195,8 +195,7 @@ public abstract class LeafRefPath implements Immutable {
      * @return A new child path
      */
     public LeafRefPath createChild(final LeafRefPath relative) {
-        Preconditions.checkArgument(!relative.isAbsolute(),
-                "Child creation requires relative path");
+        Preconditions.checkArgument(!relative.isAbsolute(), "Child creation requires relative path");
 
         LeafRefPath parent = this;
         for (QNameWithPredicate qname : relative.getPathFromRoot()) {
@@ -248,20 +247,18 @@ public abstract class LeafRefPath implements Immutable {
 
             @Override
             public QNameWithPredicate next() {
-                if (current.parent != null) {
-                    final QNameWithPredicate ret = current.qname;
-                    current = current.parent;
-                    return ret;
-                } else {
-                    throw new NoSuchElementException(
-                            "No more elements available");
+                if (current.parent == null) {
+                    throw new NoSuchElementException("No more elements available");
                 }
+
+                final QNameWithPredicate ret = current.qname;
+                current = current.parent;
+                return ret;
             }
 
             @Override
             public void remove() {
-                throw new UnsupportedOperationException(
-                        "Component removal not supported");
+                throw new UnsupportedOperationException("Component removal not supported");
             }
         };
     }
index f27815bac667dab8bc22518f09e6ed9c452127cc..f68044ce0bd43c1d3a3d7152b1cac7cb745185fd 100644 (file)
@@ -205,9 +205,8 @@ abstract class InstanceIdToNodes<T extends PathArgument> implements Identifiable
         }
         if (augmentation != null) {
             return new InstanceIdToCompositeNodes.AugmentationNormalization(augmentation, parent);
-        } else {
-            return fromDataSchemaNode(child);
         }
+        return fromDataSchemaNode(child);
     }
 
     static InstanceIdToNodes<?> fromDataSchemaNode(final DataSchemaNode potential) {
index 7b658054fba0048b67e6582c287c536a4adbca11..fb47782805c9e96ba17746fe3d969822feaa4b79 100644 (file)
@@ -99,9 +99,8 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder<Un
         dirty = true;
         if (value.isEmpty()) {
             return new EmptyImmutableUnkeyedListNode(nodeIdentifier);
-        } else {
-            return new ImmutableUnkeyedListNode(nodeIdentifier, ImmutableList.copyOf(value));
         }
+        return new ImmutableUnkeyedListNode(nodeIdentifier, ImmutableList.copyOf(value));
     }
 
     @Override
@@ -115,7 +114,9 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder<Un
         return withoutChild(key);
     }
 
-    protected static final class EmptyImmutableUnkeyedListNode extends AbstractImmutableNormalizedNode<NodeIdentifier, Collection<UnkeyedListEntryNode>> implements Immutable, UnkeyedListNode {
+    protected static final class EmptyImmutableUnkeyedListNode extends
+            AbstractImmutableNormalizedNode<NodeIdentifier, Collection<UnkeyedListEntryNode>> implements Immutable,
+            UnkeyedListNode {
         protected EmptyImmutableUnkeyedListNode(final NodeIdentifier nodeIdentifier) {
             super(nodeIdentifier);
         }
index f7bea78824c56a9442a062d6b6be39ace089a542..082dfd4c870c05c9aa630651af781f8689c57182 100644 (file)
@@ -23,11 +23,7 @@ abstract class AbstractDataTreeCandidateNode implements DataTreeCandidateNode {
     private static Optional<NormalizedNode<?, ?>> getChild(
             final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> container,
                     final PathArgument identifier) {
-        if (container != null) {
-            return container.getChild(identifier);
-        } else {
-            return Optional.absent();
-        }
+        return container == null ? Optional.absent() : container.getChild(identifier);
     }
 
     static DataTreeCandidateNode deltaChild(
@@ -40,19 +36,15 @@ abstract class AbstractDataTreeCandidateNode implements DataTreeCandidateNode {
             final NormalizedNode<?, ?> oldChild = maybeOldChild.get();
             if (maybeNewChild.isPresent()) {
                 return AbstractRecursiveCandidateNode.replaceNode(oldChild, maybeNewChild.get());
-            } else {
-                return AbstractRecursiveCandidateNode.deleteNode(oldChild);
-            }
-        } else {
-            if (maybeNewChild.isPresent()) {
-                return AbstractRecursiveCandidateNode.writeNode(maybeNewChild.get());
-            } else {
-                return null;
             }
+            return AbstractRecursiveCandidateNode.deleteNode(oldChild);
         }
+
+        return maybeNewChild.isPresent() ? AbstractRecursiveCandidateNode.writeNode(maybeNewChild.get()) : null;
     }
 
-    static Collection<DataTreeCandidateNode> deltaChildren(@Nullable final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> oldData,
+    static Collection<DataTreeCandidateNode> deltaChildren(
+            @Nullable final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> oldData,
             @Nullable final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> newData) {
         Preconditions.checkArgument(newData != null || oldData != null,
                 "No old or new data, modification type should be NONE and deltaChildren() mustn't be called.");
index aa1ae48ceed8183951807beb85c1459f0eb757a1..02d961eed3c05d1fb0dd1dfd802623b01dfa4252 100644 (file)
@@ -10,8 +10,8 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
 import java.util.Collection;
-import java.util.Collections;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -46,11 +46,7 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
     }
 
     private static TreeNode childMeta(final TreeNode parent, final PathArgument id) {
-        if (parent != null) {
-            return parent.getChild(id).orNull();
-        } else {
-            return null;
-        }
+        return parent == null ? null : parent.getChild(id).orNull();
     }
 
     private static boolean canHaveChildren(@Nullable final TreeNode oldMeta, @Nullable final TreeNode newMeta) {
@@ -84,21 +80,20 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
         case UNMODIFIED:
             // Unmodified node, but we still need to resolve potential children. canHaveChildren returns
             // false if both arguments are null.
-            if (canHaveChildren(oldMeta, newMeta)) {
-                return Collections2.transform(getContainer(newMeta != null ? newMeta : oldMeta).getValue(),
-                    AbstractRecursiveCandidateNode::unmodifiedNode);
-            } else {
-                return Collections.emptyList();
+            if (!canHaveChildren(oldMeta, newMeta)) {
+                return ImmutableList.of();
             }
+
+            return Collections2.transform(getContainer(newMeta != null ? newMeta : oldMeta).getValue(),
+                AbstractRecursiveCandidateNode::unmodifiedNode);
         case DELETE:
         case WRITE:
             // This is unusual, the user is requesting we follow into an otherwise-terminal node.
             // We need to fudge things based on before/after data to correctly fake the expectations.
-            if (canHaveChildren(oldMeta, newMeta)) {
-                return AbstractDataTreeCandidateNode.deltaChildren(getContainer(oldMeta), getContainer(newMeta));
-            } else {
-                return Collections.emptyList();
+            if (!canHaveChildren(oldMeta, newMeta)) {
+                return ImmutableList.of();
             }
+            return AbstractDataTreeCandidateNode.deltaChildren(getContainer(oldMeta), getContainer(newMeta));
         default:
             throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
         }
@@ -111,11 +106,7 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
     }
 
     private static Optional<NormalizedNode<?, ?>> optionalData(final TreeNode meta) {
-        if (meta != null) {
-            return Optional.of(meta.getData());
-        } else {
-            return Optional.absent();
-        }
+        return meta == null ? Optional.absent() : Optional.of(meta.getData());
     }
 
     @Override
@@ -142,23 +133,18 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
             }
             return null;
         case UNMODIFIED:
-            if (canHaveChildren(oldMeta, newMeta)) {
-                final Optional<NormalizedNode<?, ?>> maybeChild = getContainer(newMeta != null ? newMeta : oldMeta).getChild(identifier);
-                if (maybeChild.isPresent()) {
-                    return AbstractRecursiveCandidateNode.unmodifiedNode(maybeChild.get());
-                } else {
-                    return null;
-                }
-            } else {
+            if (!canHaveChildren(oldMeta, newMeta)) {
                 return null;
             }
+            final Optional<NormalizedNode<?, ?>> maybeChild = getContainer(newMeta != null ? newMeta : oldMeta)
+                    .getChild(identifier);
+            return maybeChild.isPresent() ? AbstractRecursiveCandidateNode.unmodifiedNode(maybeChild.get()) : null;
         case DELETE:
         case WRITE:
-            if (canHaveChildren(oldMeta, newMeta)) {
-                return AbstractDataTreeCandidateNode.deltaChild(getContainer(oldMeta), getContainer(newMeta), identifier);
-            } else {
+            if (!canHaveChildren(oldMeta, newMeta)) {
                 return null;
             }
+            return AbstractDataTreeCandidateNode.deltaChild(getContainer(oldMeta), getContainer(newMeta), identifier);
         default:
             throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
         }
index f8dd37d24dd458f57a4906c691339014fd319ec8..8f1baffcf686e5a9b9cadb1bd211f8222caabab4 100644 (file)
@@ -76,9 +76,8 @@ abstract class AbstractRecursiveCandidateNode extends AbstractDataTreeCandidateN
     private DataTreeCandidateNode createChild(final NormalizedNode<?, ?> childData) {
         if (isContainer(childData)) {
             return createContainer((NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) childData);
-        } else {
-            return createLeaf(childData);
         }
+        return createLeaf(childData);
     }
 
     protected abstract DataTreeCandidateNode createContainer(NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> childData);
index 8ba53004fcd26fe78b608221bc3f4230efa57162..06e5764f13b8edc036e044466f7d7b1160e2c350 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
+
 import com.google.common.base.Optional;
 import com.google.common.collect.Maps;
 import java.io.ByteArrayOutputStream;
@@ -190,9 +191,8 @@ public class XmlStreamUtilsTest {
             final QName moduleQName = QName.create(namespace, revision, "module");
             final QNameModule module = QNameModule.create(moduleQName.getNamespace(), moduleQName.getRevision());
             return QName.create(module, localName);
-        } else {
-            return QName.create(namespace, revision, localName);
         }
+        return QName.create(namespace, revision, localName);
     }
 
     private LeafSchemaNode findSchemaNodeWithLeafrefType(final DataNodeContainer module, final String nodeName) {
index 7df8959ffd27d699e2e6b530e02e551a374203e6..67d9409d10da4712c9a133d45efc416ce36fd85a 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
+
 import com.google.common.base.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -89,7 +90,7 @@ public class NormalizedNodeUtilsTest {
      *
      * </pre>
      *
-     * @return
+     * @return A test document
      */
     public NormalizedNode<?, ?> createDocumentOne() {
         return ImmutableContainerNodeBuilder
index 4b4ef99b4f8c499a8fa0f5dfaf31faf2b147f116..1922cfa02b5af2dc38724e227f48d7416f107f76 100644 (file)
@@ -156,7 +156,7 @@ public class SchemaOrderedNormalizedNodeWriterTest {
         XMLAssert.assertXMLIdentical(new Diff(EXPECTED_2, stringWriter.toString()), true);
     }
 
-    private SchemaContext getSchemaContext(String filePath) throws URISyntaxException, ReactorException, FileNotFoundException {
+    private SchemaContext getSchemaContext(final String filePath) throws URISyntaxException, ReactorException, FileNotFoundException {
         final InputStream resourceStream = getClass().getResourceAsStream(filePath);
         final YangStatementSourceImpl source = new YangStatementSourceImpl(resourceStream);
         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
@@ -165,11 +165,11 @@ public class SchemaOrderedNormalizedNodeWriterTest {
         return reactor.buildEffective();
     }
 
-    private YangInstanceIdentifier.NodeIdentifier getNodeIdentifier(String ns, String name) {
+    private static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier(final String ns, final String name) {
         return YangInstanceIdentifier.NodeIdentifier.create(createQName(ns, name));
     }
 
-    private QName createQName(String ns, String name) {
+    private static QName createQName(final String ns, final String name) {
         return QName.create(ns, "2016-02-17", name);
     }
 
index a74bad4c3a75492869c3c463b1815ea6746eb2f4..0f1ead33089e0b08c1ec8db868116e3350545b44 100644 (file)
@@ -26,8 +26,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
@@ -120,7 +120,7 @@ public class ModificationMetadataTreeTest {
      *
      * </pre>
      *
-     * @return
+     * @return a test document
      */
     public NormalizedNode<?, ?> createDocumentOne() {
         return ImmutableContainerNodeBuilder
index d6f0192747e2da920727ccc6291aa41d9259eb88..79b25dd257f0c3e8a6c88ce6a9adfa096b2caa60 100644 (file)
@@ -47,12 +47,12 @@ public final class QNameCacheNamespace extends NamespaceBehaviour<QName, QName,
     public QName getFrom(final NamespaceStorageNode storage, final QName key) {
         final NamespaceStorageNode root = getRoot(storage);
         final QName stored = root.getFromLocalStorage(QNameCacheNamespace.class, key);
-        if (stored == null) {
-            root.addToLocalStorage(QNameCacheNamespace.class, key, key);
-            return key;
-        } else {
+        if (stored != null) {
             return stored;
         }
+
+        root.addToLocalStorage(QNameCacheNamespace.class, key, key);
+        return key;
     }
 
     @Override
index 8fd4e000dc88fa8a99810f775cf7438cff99c3ff..7aa513a0204e89daf13049c4527fb6bcfce563d0 100644 (file)
@@ -304,15 +304,15 @@ public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeId
                  */
                 if (!Utils.belongsToTheSameModule(targetStmtQName, sourceStmtQName)) {
                     return true;
-                } else {
-                    /*
-                     * If target or one of its parent is a presence container from
-                     * the same module, return false and skip mandatory nodes
-                     * validation
-                     */
-                    if (StmtContextUtils.isPresenceContainer(targetCtx)) {
-                        return false;
-                    }
+                }
+
+                /*
+                 * If target or one of its parent is a presence container from
+                 * the same module, return false and skip mandatory nodes
+                 * validation
+                 */
+                if (StmtContextUtils.isPresenceContainer(targetCtx)) {
+                    return false;
                 }
             } while ((targetCtx = targetCtx.getParentContext()) != root);
 
index cd5f9fd7c04cca6eadc162306d2fcf831dee9c36..05c390c1187fcc0151105ed8d02346f228f0c971 100644 (file)
@@ -125,7 +125,7 @@ public class ModuleStatementSupport extends
         QNameModule qNameModule = QNameModule.create(moduleNs, revisionDate.orElse(null)).intern();
 
         stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule);
-    };
+    }
 
     @Override
     public void onLinkageDeclared(final Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt) {
index 5f4b9a463054275b8cac9ad9225871e882d6980f..9f4dcca254465a4dedf35b09113d45ec36d6d48b 100644 (file)
@@ -112,11 +112,7 @@ final class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode {
 
     @Override
     public DataSchemaNode getDataChildByName(final QName name) {
-        if (getQName().equals(name)) {
-            return caseShorthandNode;
-        } else {
-            return null;
-        }
+        return getQName().equals(name) ? caseShorthandNode : null;
     }
 
     @Override
@@ -160,10 +156,7 @@ final class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode {
 
     @Override
     public String toString() {
-        return CaseShorthandImpl.class.getSimpleName() + "[" +
-                "qname=" +
-                getQName() +
-                "]";
+        return CaseShorthandImpl.class.getSimpleName() + "[" + "qname=" + getQName() + "]";
     }
 
     private static ChoiceCaseNode getOriginalIfPresent(final SchemaNode caseShorthandNode) {
index 158dce8cf3361e2517b3b3e570d6640c0cdbcb18..9deb0f05b4ae487a1e948bb62b205debfe4ee985 100644 (file)
@@ -15,19 +15,18 @@ import java.io.InputStream;
 
 public class NamedByteArrayInputStream extends ByteArrayInputStream implements NamedInputStream {
     private final String toString;
-    public NamedByteArrayInputStream(byte[] buf, String toString) {
+    public NamedByteArrayInputStream(final byte[] buf, final String toString) {
         super(buf);
         this.toString = toString;
     }
 
-    public static ByteArrayInputStream create(InputStream originalIS) throws IOException {
+    public static ByteArrayInputStream create(final InputStream originalIS) throws IOException {
         final byte[] data = ByteStreams.toByteArray(originalIS);
 
         if (originalIS instanceof NamedInputStream) {
             return new NamedByteArrayInputStream(data, originalIS.toString());
-        } else {
-            return new ByteArrayInputStream(data);
         }
+        return new ByteArrayInputStream(data);
     }
 
     @Override