Java 8: use lambdas and function references 36/47836/2
authorStephen Kitt <skitt@redhat.com>
Wed, 2 Nov 2016 12:33:43 +0000 (13:33 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 2 Nov 2016 15:27:14 +0000 (15:27 +0000)
This simply switches functional declarations to lambdas where
possible, and lambdas to function references where possible.

Change-Id: I3c0c97349b05aa8e8ecdda85906cbe41ed5c9c1a
Signed-off-by: Stephen Kitt <skitt@redhat.com>
20 files changed:
common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/spi/NoopObjectCacheBinder.java
common/object-cache-noop/src/main/java/org/opendaylight/yangtools/objcache/impl/StaticObjectCacheBinder.java
common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/AsyncNotifyingListeningExecutorServiceTest.java
common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/CommonTestUtils.java
common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/DeadlockDetectingListeningExecutorServiceTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/NormalizedNodeToJsonStreamTest.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlUtils.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefPath.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/DomSerializerTestUtils.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/NormalizedNodeXmlTranslationTest.java
yang/yang-data-jaxen/src/main/java/org/opendaylight/yangtools/yang/data/jaxen/JaxenXPath.java
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/Util.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/SchemaNodeIdentifier.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/StmtTestUtils.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/FilteringSchemaContextProxy.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/repo/util/FilesystemSchemaSourceCacheTest.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ChoiceEffectiveStatementImpl.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java

index 0ff336502700ad40efb666cc9230f5bea0b6abb7..e8791157dd0dada0a8e67b3d9e184ab182606fa9 100644 (file)
@@ -7,17 +7,10 @@
  */
 package org.opendaylight.yangtools.objcache.spi;
 
-import org.opendaylight.yangtools.objcache.ObjectCache;
-
 public final class NoopObjectCacheBinder extends AbstractObjectCacheBinder {
     public static final NoopObjectCacheBinder INSTANCE = new NoopObjectCacheBinder();
 
     private  NoopObjectCacheBinder() {
-        super(new IObjectCacheFactory() {
-            @Override
-            public ObjectCache getObjectCache(final Class<?> objClass) {
-                return NoopObjectCache.getInstance();
-            }
-        });
+        super(objClass -> NoopObjectCache.getInstance());
     }
 }
index 3ef9fbf941d90f79dc7eef87a2e72c1d907a42dc..3153ff2cc7428efb41e7733c8b63577f17bba860 100644 (file)
@@ -7,21 +7,14 @@
  */
 package org.opendaylight.yangtools.objcache.impl;
 
-import org.opendaylight.yangtools.objcache.ObjectCache;
 import org.opendaylight.yangtools.objcache.spi.AbstractObjectCacheBinder;
-import org.opendaylight.yangtools.objcache.spi.IObjectCacheFactory;
 import org.opendaylight.yangtools.objcache.spi.NoopObjectCache;
 
 public final class StaticObjectCacheBinder extends AbstractObjectCacheBinder {
     private static final StaticObjectCacheBinder INSTANCE = new StaticObjectCacheBinder();
 
     private StaticObjectCacheBinder() {
-        super(new IObjectCacheFactory() {
-            @Override
-            public ObjectCache getObjectCache(final Class<?> objClass) {
-                return NoopObjectCache.getInstance();
-            }
-        });
+        super(objClass -> NoopObjectCache.getInstance());
     }
 
     public static StaticObjectCacheBinder getInstance() {
index 635753467c9a3abfea2945151aadf8b43951328d..83451004f824a0b7edc89e8961e17b0388ce32e2 100644 (file)
@@ -160,10 +160,7 @@ public class AsyncNotifyingListeningExecutorServiceTest {
     @Test
     public void testDelegatedMethods() throws InterruptedException {
 
-        Runnable task = new Runnable() {
-            @Override
-            public void run(){
-            }
+        Runnable task = () -> {
         };
 
         List<Runnable> taskList = Lists.newArrayList();
index c4cc4baa074fe8ba5956aa64cabf3a6a676b287b..7404c8c3843995cbd367e6ec6adc568f1855d650 100644 (file)
@@ -26,49 +26,25 @@ public class CommonTestUtils {
                 CountDownLatch blockingLatch );
     }
 
-    public static final Invoker SUBMIT_CALLABLE = new Invoker() {
+    public static final Invoker SUBMIT_CALLABLE = (executor, blockingLatch) -> executor.submit(new Callable<Void>() {
         @Override
-        public ListenableFuture<?> invokeExecutor( ListeningExecutorService executor,
-                final CountDownLatch blockingLatch ) {
-            return executor.submit( new Callable<Void>() {
-                @Override
-                public Void call() throws Exception {
-                    if (blockingLatch != null ) {
-                        Uninterruptibles.awaitUninterruptibly( blockingLatch );
-                    }
-                    return null;
-                }
-            } );
+        public Void call() throws Exception {
+            if (blockingLatch != null ) {
+                Uninterruptibles.awaitUninterruptibly( blockingLatch );
+            }
+            return null;
         }
-    };
+    } );
 
-    public static final Invoker SUBMIT_RUNNABLE =  new Invoker() {
-        @Override
-        public ListenableFuture<?> invokeExecutor( ListeningExecutorService executor,
-                final CountDownLatch blockingLatch ) {
-            return executor.submit( new Runnable() {
-                @Override
-                public void run() {
-                    if (blockingLatch != null ) {
-                        Uninterruptibles.awaitUninterruptibly( blockingLatch );
-                    }
-                }
-            } );
+    public static final Invoker SUBMIT_RUNNABLE = (executor, blockingLatch) -> executor.submit(() -> {
+        if (blockingLatch != null ) {
+            Uninterruptibles.awaitUninterruptibly( blockingLatch );
         }
-    };
+    });
 
-    public static final Invoker SUBMIT_RUNNABLE_WITH_RESULT = new Invoker() {
-        @Override
-        public ListenableFuture<?> invokeExecutor( ListeningExecutorService executor,
-                final CountDownLatch blockingLatch ) {
-            return executor.submit( new Runnable() {
-                @Override
-                public void run() {
-                    if (blockingLatch != null ) {
-                        Uninterruptibles.awaitUninterruptibly( blockingLatch );
-                    }
-                }
-            }, "foo" );
+    public static final Invoker SUBMIT_RUNNABLE_WITH_RESULT = (executor, blockingLatch) -> executor.submit(() -> {
+        if (blockingLatch != null ) {
+            Uninterruptibles.awaitUninterruptibly( blockingLatch );
         }
-    };
+    }, "foo" );
 }
index e14499f7d7afb364ba99ce953ce8fc08e1480fc7..fa322277f732d0f108c6e45ed008ff13b6a3cb71 100644 (file)
@@ -22,9 +22,9 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
@@ -45,30 +45,15 @@ public class DeadlockDetectingListeningExecutorServiceTest {
         void invokeExecutor( ListeningExecutorService executor, Runnable task );
     }
 
-    static final InitialInvoker SUBMIT = new InitialInvoker() {
-        @Override
-        public void invokeExecutor( final ListeningExecutorService executor, final Runnable task ) {
-            executor.submit( task );
-        }
-    };
+    static final InitialInvoker SUBMIT = ListeningExecutorService::submit;
 
-    static final InitialInvoker EXECUTE = new InitialInvoker() {
-        @Override
-        public void invokeExecutor( final ListeningExecutorService executor, final Runnable task ) {
-            executor.execute( task );
-        }
-    };
+    static final InitialInvoker EXECUTE = Executor::execute;
 
     @SuppressWarnings("serial")
     public static class TestDeadlockException extends Exception {
     }
 
-    private static final Supplier<Exception> DEADLOCK_EXECUTOR_SUPPLIER = new Supplier<Exception>() {
-        @Override
-        public Exception get() {
-            return new TestDeadlockException();
-        }
-    };
+    private static final Supplier<Exception> DEADLOCK_EXECUTOR_SUPPLIER = TestDeadlockException::new;
 
     DeadlockDetectingListeningExecutorService executor;
 
@@ -95,29 +80,18 @@ public class DeadlockDetectingListeningExecutorServiceTest {
 
         // Test submit with Callable.
 
-        ListenableFuture<String> future = executor.submit( new Callable<String>() {
-            @Override
-            public String call() throws Exception{
-                return "foo";
-            }
-        } );
+        ListenableFuture<String> future = executor.submit(() -> "foo");
 
         assertEquals( "Future result", "foo", future.get( 5, TimeUnit.SECONDS ) );
 
         // Test submit with Runnable.
 
-        executor.submit( new Runnable() {
-            @Override
-            public void run(){
-            }
-        } ).get();
+        executor.submit(() -> {
+        }).get();
 
         // Test submit with Runnable and value.
 
-        future = executor.submit( new Runnable() {
-            @Override
-            public void run(){
-            }
+        future = executor.submit(() -> {
         }, "foo" );
 
         assertEquals( "Future result", "foo", future.get( 5, TimeUnit.SECONDS ) );
@@ -141,26 +115,18 @@ public class DeadlockDetectingListeningExecutorServiceTest {
         final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
         final CountDownLatch futureCompletedLatch = new CountDownLatch( 1 );
 
-        Runnable task = new Runnable() {
-            @SuppressWarnings({ "unchecked", "rawtypes" })
+        Runnable task = () -> Futures.addCallback( invoker.invokeExecutor( executor, null ), new FutureCallback() {
             @Override
-            public void run() {
-
-                Futures.addCallback( invoker.invokeExecutor( executor, null ), new FutureCallback() {
-                    @Override
-                    public void onSuccess( final Object result ) {
-                        futureCompletedLatch.countDown();
-                    }
-
-                    @Override
-                    public void onFailure( final Throwable t ) {
-                        caughtEx.set( t );
-                        futureCompletedLatch.countDown();
-                    }
-                } );
+            public void onSuccess( final Object result ) {
+                futureCompletedLatch.countDown();
             }
 
-        };
+            @Override
+            public void onFailure( final Throwable t ) {
+                caughtEx.set( t );
+                futureCompletedLatch.countDown();
+            }
+        } );
 
         initialInvoker.invokeExecutor( executor, task );
 
@@ -190,21 +156,17 @@ public class DeadlockDetectingListeningExecutorServiceTest {
         final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
         final CountDownLatch latch = new CountDownLatch( 1 );
 
-        Runnable task = new Runnable() {
-            @Override
-            public void run() {
-
-                try {
-                    invoker.invokeExecutor( executor, null ).get();
-                } catch( ExecutionException e ) {
-                    caughtEx.set( e.getCause() );
-                } catch( Throwable e ) {
-                    caughtEx.set( e );
-                } finally {
-                    latch.countDown();
-                }
-            }
+        Runnable task = () -> {
 
+            try {
+                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 );
index f8bb50d9ab12df9f47c547c5636496b98216bac6..b78ff441cd645448812633cbf42a0d850260da47 100644 (file)
@@ -88,19 +88,15 @@ public class NormalizedNodeToJsonStreamTest {
         final Writer writer = new StringWriter();
         final NormalizedNode<?, ?> leafNodeInContainer = TestingNormalizedNodeStructuresCreator.leafNodeInContainer();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer, leafNodeInContainer);
-        new JsonValidator() {
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
 
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
-
-                final JsonPrimitive lf11 = childPrimitive(cont1, "complexjson:lf11", "lf11");
-                assertNotNull(lf11);
-                final int asInt = lf11.getAsInt();
-                assertEquals(453, asInt);
-            }
-        }.validate(jsonOutput);
+            final JsonPrimitive lf11 = childPrimitive(cont1, "complexjson:lf11", "lf11");
+            assertNotNull(lf11);
+            final int asInt = lf11.getAsInt();
+            assertEquals(453, asInt);
+        }).validate(jsonOutput);
 
     }
 
@@ -110,25 +106,21 @@ public class NormalizedNodeToJsonStreamTest {
         final NormalizedNode<?, ?> leafListNodeInContainer = TestingNormalizedNodeStructuresCreator
                 .leafListNodeInContainerMultiline();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer, leafListNodeInContainer);
-        new JsonValidator() {
-
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
-                final JsonArray lflst11 = childArray(cont1, "complexjson:lflst11", "lflst11");
-                assertNotNull(lflst11);
-
-                final HashSet<Object> lflst11Values = Sets.newHashSet();
-                for (final JsonElement jsonElement : lflst11) {
-                    assertTrue(jsonElement instanceof JsonPrimitive);
-                    lflst11Values.add(jsonElement.getAsString());
-                }
-
-                assertEquals(Sets.newHashSet("lflst11 value2\r\nanother line 2", "lflst11 value1\nanother line 1"),
-                        lflst11Values);
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
+            final JsonArray lflst11 = childArray(cont1, "complexjson:lflst11", "lflst11");
+            assertNotNull(lflst11);
+
+            final HashSet<Object> lflst11Values = Sets.newHashSet();
+            for (final JsonElement jsonElement : lflst11) {
+                assertTrue(jsonElement instanceof JsonPrimitive);
+                lflst11Values.add(jsonElement.getAsString());
             }
-        }.validate(jsonOutput);
+
+            assertEquals(Sets.newHashSet("lflst11 value2\r\nanother line 2", "lflst11 value1\nanother line 1"),
+                    lflst11Values);
+        }).validate(jsonOutput);
 
     }
 
@@ -138,19 +130,15 @@ public class NormalizedNodeToJsonStreamTest {
         final NormalizedNode<?, ?> leafNodeViaAugmentationInContainer = TestingNormalizedNodeStructuresCreator
                 .leafNodeViaAugmentationInContainer();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer, leafNodeViaAugmentationInContainer);
-        new JsonValidator() {
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
 
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
-
-                final JsonPrimitive lf12_1 = childPrimitive(cont1, "complexjson:lf12_1", "lf12_1");
-                assertNotNull(lf12_1);
-                final String asString = lf12_1.getAsString();
-                assertEquals("lf12 value", asString);
-            }
-        }.validate(jsonOutput);
+            final JsonPrimitive lf12_1 = childPrimitive(cont1, "complexjson:lf12_1", "lf12_1");
+            assertNotNull(lf12_1);
+            final String asString = lf12_1.getAsString();
+            assertEquals("lf12 value", asString);
+        }).validate(jsonOutput);
 
     }
 
@@ -160,24 +148,20 @@ public class NormalizedNodeToJsonStreamTest {
         final NormalizedNode<?, ?> leafListNodeInContainer = TestingNormalizedNodeStructuresCreator
                 .leafListNodeInContainer();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer, leafListNodeInContainer);
-        new JsonValidator() {
-
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
-                final JsonArray lflst11 = childArray(cont1, "complexjson:lflst11", "lflst11");
-                assertNotNull(lflst11);
-
-                final HashSet<Object> lflst11Values = Sets.newHashSet();
-                for (final JsonElement jsonElement : lflst11) {
-                    assertTrue(jsonElement instanceof JsonPrimitive);
-                    lflst11Values.add(jsonElement.getAsString());
-                }
-
-                assertEquals(Sets.newHashSet("lflst11 value2", "lflst11 value1"), lflst11Values);
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
+            final JsonArray lflst11 = childArray(cont1, "complexjson:lflst11", "lflst11");
+            assertNotNull(lflst11);
+
+            final HashSet<Object> lflst11Values = Sets.newHashSet();
+            for (final JsonElement jsonElement : lflst11) {
+                assertTrue(jsonElement instanceof JsonPrimitive);
+                lflst11Values.add(jsonElement.getAsString());
             }
-        }.validate(jsonOutput);
+
+            assertEquals(Sets.newHashSet("lflst11 value2", "lflst11 value1"), lflst11Values);
+        }).validate(jsonOutput);
     }
 
     @Test
@@ -186,37 +170,33 @@ public class NormalizedNodeToJsonStreamTest {
         final NormalizedNode<?, ?> keyedListNodeInContainer = TestingNormalizedNodeStructuresCreator
                 .keyedListNodeInContainer();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer, keyedListNodeInContainer);
-        new JsonValidator() {
-
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
-                final JsonArray lst11 = childArray(cont1, "complexjson:lst11", "lst11");
-                assertNotNull(lst11);
-
-                final Iterator<JsonElement> iterator = lst11.iterator();
-                assertTrue(iterator.hasNext());
-                final JsonElement lst11Entry1Raw = iterator.next();
-                assertFalse(iterator.hasNext());
-                assertTrue(lst11Entry1Raw instanceof JsonObject);
-                final JsonObject lst11Entry1 = (JsonObject) lst11Entry1Raw;
-
-                final JsonPrimitive key111 = childPrimitive(lst11Entry1, "complexjson:key111", "key111");
-                assertNotNull(key111);
-                final JsonPrimitive lf112 = childPrimitive(lst11Entry1, "complexjson:lf112", "lf112");
-                assertNotNull(lf112);
-                final JsonPrimitive lf113 = childPrimitive(lst11Entry1, "complexjson:lf113", "lf113");
-                assertNotNull(lf113);
-                final JsonPrimitive lf111 = childPrimitive(lst11Entry1, "complexjson:lf111", "lf111");
-                assertNotNull(lf111);
-
-                assertEquals("key111 value", key111.getAsString());
-                assertEquals("/complexjson:cont1/complexjson:lflst11[.='foo']", lf112.getAsString());
-                assertEquals("lf113 value", lf113.getAsString());
-                assertEquals("lf111 value", lf111.getAsString());
-            }
-        }.validate(jsonOutput);
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
+            final JsonArray lst11 = childArray(cont1, "complexjson:lst11", "lst11");
+            assertNotNull(lst11);
+
+            final Iterator<JsonElement> iterator = lst11.iterator();
+            assertTrue(iterator.hasNext());
+            final JsonElement lst11Entry1Raw = iterator.next();
+            assertFalse(iterator.hasNext());
+            assertTrue(lst11Entry1Raw instanceof JsonObject);
+            final JsonObject lst11Entry1 = (JsonObject) lst11Entry1Raw;
+
+            final JsonPrimitive key111 = childPrimitive(lst11Entry1, "complexjson:key111", "key111");
+            assertNotNull(key111);
+            final JsonPrimitive lf112 = childPrimitive(lst11Entry1, "complexjson:lf112", "lf112");
+            assertNotNull(lf112);
+            final JsonPrimitive lf113 = childPrimitive(lst11Entry1, "complexjson:lf113", "lf113");
+            assertNotNull(lf113);
+            final JsonPrimitive lf111 = childPrimitive(lst11Entry1, "complexjson:lf111", "lf111");
+            assertNotNull(lf111);
+
+            assertEquals("key111 value", key111.getAsString());
+            assertEquals("/complexjson:cont1/complexjson:lflst11[.='foo']", lf112.getAsString());
+            assertEquals("lf113 value", lf113.getAsString());
+            assertEquals("lf111 value", lf111.getAsString());
+        }).validate(jsonOutput);
     }
 
     @Test
@@ -225,18 +205,14 @@ public class NormalizedNodeToJsonStreamTest {
         final NormalizedNode<?, ?> choiceNodeInContainer = TestingNormalizedNodeStructuresCreator
                 .choiceNodeInContainer();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer, choiceNodeInContainer);
-        new JsonValidator() {
-
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
-                final JsonPrimitive lf13 = childPrimitive(cont1, "complexjson:lf13", "lf13");
-                assertNotNull(lf13);
-
-                assertEquals("lf13 value", lf13.getAsString());
-            }
-        }.validate(jsonOutput);
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
+            final JsonPrimitive lf13 = childPrimitive(cont1, "complexjson:lf13", "lf13");
+            assertNotNull(lf13);
+
+            assertEquals("lf13 value", lf13.getAsString());
+        }).validate(jsonOutput);
     }
 
     /**
@@ -257,29 +233,25 @@ public class NormalizedNodeToJsonStreamTest {
                 .caseNodeAugmentationInChoiceInContainer();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer,
                 caseNodeAugmentationInChoiceInContainer);
-        new JsonValidator() {
-
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
-
-                final JsonPrimitive lf15_21 = childPrimitive(cont1, "complexjson:lf15_21", "lf15_21");
-                assertNotNull(lf15_21);
-                final JsonPrimitive lf13 = childPrimitive(cont1, "complexjson:lf13", "lf13");
-                assertNotNull(lf13);
-                final JsonPrimitive lf15_11 = childPrimitive(cont1, "complexjson:lf15_11", "lf15_11");
-                assertNotNull(lf15_11);
-                final JsonPrimitive lf15_12 = childPrimitive(cont1, "complexjson:lf15_12", "lf15_12");
-                assertNotNull(lf15_12);
-
-                assertEquals("lf15_21 value", lf15_21.getAsString());
-                assertEquals("lf13 value", lf13.getAsString());
-                assertTrue("one two".equals(lf15_11.getAsString()) || "two one".equals(lf15_11.getAsString()));
-                assertEquals("complexjson:lf11", lf15_12.getAsString());
-
-            }
-        }.validate(jsonOutput);
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
+
+            final JsonPrimitive lf15_21 = childPrimitive(cont1, "complexjson:lf15_21", "lf15_21");
+            assertNotNull(lf15_21);
+            final JsonPrimitive lf13 = childPrimitive(cont1, "complexjson:lf13", "lf13");
+            assertNotNull(lf13);
+            final JsonPrimitive lf15_11 = childPrimitive(cont1, "complexjson:lf15_11", "lf15_11");
+            assertNotNull(lf15_11);
+            final JsonPrimitive lf15_12 = childPrimitive(cont1, "complexjson:lf15_12", "lf15_12");
+            assertNotNull(lf15_12);
+
+            assertEquals("lf15_21 value", lf15_21.getAsString());
+            assertEquals("lf13 value", lf13.getAsString());
+            assertTrue("one two".equals(lf15_11.getAsString()) || "two one".equals(lf15_11.getAsString()));
+            assertEquals("complexjson:lf11", lf15_12.getAsString());
+
+        }).validate(jsonOutput);
     }
 
     /**
@@ -300,32 +272,28 @@ public class NormalizedNodeToJsonStreamTest {
                 .caseNodeExternalAugmentationInChoiceInContainer();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer,
                 caseNodeExternalAugmentationInChoiceInContainer);
-        new JsonValidator() {
-
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
-
-                final JsonPrimitive lf15_11Augment = childPrimitive(cont1, "complexjson-augmentation:lf15_11");
-                assertNotNull(lf15_11Augment);
-                final JsonPrimitive lf15_12Augment = childPrimitive(cont1, "complexjson-augmentation:lf15_12");
-                assertNotNull(lf15_12Augment);
-                final JsonPrimitive lf13 = childPrimitive(cont1, "complexjson:lf13", "lf13");
-                assertNotNull(lf13);
-                final JsonPrimitive lf15_11 = childPrimitive(cont1, "complexjson:lf15_11", "lf15_11");
-                assertNotNull(lf15_11);
-                final JsonPrimitive lf15_12 = childPrimitive(cont1, "complexjson:lf15_12", "lf15_12");
-                assertNotNull(lf15_12);
-
-                assertEquals("lf15_11 value from augmentation", lf15_11Augment.getAsString());
-                assertEquals("lf15_12 value from augmentation", lf15_12Augment.getAsString());
-                assertEquals("lf13 value", lf13.getAsString());
-                assertTrue("one two".equals(lf15_11.getAsString()) || "two one".equals(lf15_11.getAsString()));
-                assertEquals("complexjson:lf11", lf15_12.getAsString());
-
-            }
-        }.validate(jsonOutput);
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
+
+            final JsonPrimitive lf15_11Augment = childPrimitive(cont1, "complexjson-augmentation:lf15_11");
+            assertNotNull(lf15_11Augment);
+            final JsonPrimitive lf15_12Augment = childPrimitive(cont1, "complexjson-augmentation:lf15_12");
+            assertNotNull(lf15_12Augment);
+            final JsonPrimitive lf13 = childPrimitive(cont1, "complexjson:lf13", "lf13");
+            assertNotNull(lf13);
+            final JsonPrimitive lf15_11 = childPrimitive(cont1, "complexjson:lf15_11", "lf15_11");
+            assertNotNull(lf15_11);
+            final JsonPrimitive lf15_12 = childPrimitive(cont1, "complexjson:lf15_12", "lf15_12");
+            assertNotNull(lf15_12);
+
+            assertEquals("lf15_11 value from augmentation", lf15_11Augment.getAsString());
+            assertEquals("lf15_12 value from augmentation", lf15_12Augment.getAsString());
+            assertEquals("lf13 value", lf13.getAsString());
+            assertTrue("one two".equals(lf15_11.getAsString()) || "two one".equals(lf15_11.getAsString()));
+            assertEquals("complexjson:lf11", lf15_12.getAsString());
+
+        }).validate(jsonOutput);
     }
 
     /**
@@ -344,18 +312,14 @@ public class NormalizedNodeToJsonStreamTest {
         final NormalizedNode<?, ?> choiceNodeAugmentationInContainer = TestingNormalizedNodeStructuresCreator
                 .choiceNodeAugmentationInContainer();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer, choiceNodeAugmentationInContainer);
-        new JsonValidator() {
-
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
-
-                final JsonPrimitive lf17 = childPrimitive(cont1, "complexjson:lf17", "lf17");
-                assertNotNull(lf17);
-                assertEquals("lf17 value", lf17.getAsString());
-            }
-        }.validate(jsonOutput);
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
+
+            final JsonPrimitive lf17 = childPrimitive(cont1, "complexjson:lf17", "lf17");
+            assertNotNull(lf17);
+            assertEquals("lf17 value", lf17.getAsString());
+        }).validate(jsonOutput);
     }
 
     @Test
@@ -364,30 +328,26 @@ public class NormalizedNodeToJsonStreamTest {
         final NormalizedNode<?, ?> unkeyedNodeInContainer = TestingNormalizedNodeStructuresCreator
                 .unkeyedNodeInContainer();
         final String jsonOutput = normalizedNodeToJsonStreamTransformation(writer, unkeyedNodeInContainer);
-        new JsonValidator() {
+        ((JsonValidator) jsonOutput1 -> {
+            final JsonObject cont1 = resolveCont1(jsonOutput1);
+            assertNotNull(cont1);
 
-            @Override
-            public void validate(final String jsonOutput) {
-                final JsonObject cont1 = resolveCont1(jsonOutput);
-                assertNotNull(cont1);
+            final JsonArray lst12 = childArray(cont1, "complexjson:lst12", "lst12");
+            assertNotNull(lst12);
 
-                final JsonArray lst12 = childArray(cont1, "complexjson:lst12", "lst12");
-                assertNotNull(lst12);
+            final Iterator<JsonElement> iterator = lst12.iterator();
+            assertTrue(iterator.hasNext());
+            final JsonElement lst12Entry1Raw = iterator.next();
+            assertFalse(iterator.hasNext());
 
-                final Iterator<JsonElement> iterator = lst12.iterator();
-                assertTrue(iterator.hasNext());
-                final JsonElement lst12Entry1Raw = iterator.next();
-                assertFalse(iterator.hasNext());
+            assertTrue(lst12Entry1Raw instanceof JsonObject);
+            final JsonObject lst12Entry1 = (JsonObject) lst12Entry1Raw;
+            final JsonPrimitive lf121 = childPrimitive(lst12Entry1, "complexjson:lf121", "lf121");
+            assertNotNull(lf121);
 
-                assertTrue(lst12Entry1Raw instanceof JsonObject);
-                final JsonObject lst12Entry1 = (JsonObject) lst12Entry1Raw;
-                final JsonPrimitive lf121 = childPrimitive(lst12Entry1, "complexjson:lf121", "lf121");
-                assertNotNull(lf121);
+            assertEquals("lf121 value", lf121.getAsString());
 
-                assertEquals("lf121 value", lf121.getAsString());
-
-            }
-        }.validate(jsonOutput);
+        }).validate(jsonOutput);
 
     }
 
index d3acbe64400e2fe4192722147aa39426f6b7ac12..82a8b923b204ea91900ec90e8b984b8503d951d6 100644 (file)
@@ -16,12 +16,8 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
  * JAXP API.
  */
 public final class XmlUtils {
-    public static final XmlCodecProvider DEFAULT_XML_CODEC_PROVIDER = new XmlCodecProvider() {
-        @Override
-        public TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> codecFor(final TypeDefinition<?> baseType) {
-            return TypeDefinitionAwareCodec.from(baseType);
-        }
-    };
+    public static final XmlCodecProvider DEFAULT_XML_CODEC_PROVIDER =
+            TypeDefinitionAwareCodec::from;
 
     private XmlUtils() {
         throw new UnsupportedOperationException();
index ff8aa82a23f8c46e0d4d709b6bf538e230277a18..84f17d195d462f8bcb7074f6d9b8ab018baa0c7e 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -238,35 +238,30 @@ public abstract class LeafRefPath implements Immutable {
      *         the schema node towards the root.
      */
     public Iterable<QNameWithPredicate> getPathTowardsRoot() {
-        return new Iterable<QNameWithPredicate>() {
+        return () -> new Iterator<QNameWithPredicate>() {
+            private LeafRefPath current = LeafRefPath.this;
+
+            @Override
+            public boolean hasNext() {
+                return current.parent != null;
+            }
+
+            @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");
+                }
+            }
+
             @Override
-            public Iterator<QNameWithPredicate> iterator() {
-                return new Iterator<QNameWithPredicate>() {
-                    private LeafRefPath current = LeafRefPath.this;
-
-                    @Override
-                    public boolean hasNext() {
-                        return current.parent != null;
-                    }
-
-                    @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");
-                        }
-                    }
-
-                    @Override
-                    public void remove() {
-                        throw new UnsupportedOperationException(
-                                "Component removal not supported");
-                    }
-                };
+            public void remove() {
+                throw new UnsupportedOperationException(
+                        "Component removal not supported");
             }
         };
     }
index 6ef48d97f4a59c7f3b1010498eb8a78ef6a3eab1..0950a1ab1250fb863da7acbe2c11bd90350bd434 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlCodecProvider;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.NodeSerializerDispatcher;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
@@ -43,12 +42,7 @@ public class DomSerializerTestUtils {
     static final Document DOC = XmlDocumentUtils.getDocument();
     static final Element DATA = DOC.createElement("data");
     static final NodeSerializerDispatcher MOCK_DISPATCHER = Mockito.mock(NodeSerializerDispatcher.class);
-    static final XmlCodecProvider CODEC_PROVIDER = new XmlCodecProvider() {
-        @Override
-        public TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> codecFor(TypeDefinition<?> baseType) {
-            return TypeDefinitionAwareCodec.from(baseType);
-        }
-    };
+    static final XmlCodecProvider CODEC_PROVIDER = TypeDefinitionAwareCodec::from;
 
     private DomSerializerTestUtils() {
         throw new UnsupportedOperationException("Utility class");
index e1f02a76a9602d491678e89b49dc3508767cc724..7d3be418b0cb356eeb7b669d534dca47694c830c 100644 (file)
@@ -11,7 +11,6 @@ import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.augmenta
 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Lists;
@@ -273,13 +272,10 @@ public class NormalizedNodeXmlTranslationTest {
     List<InputStream> getTestYangs(final String... yangPaths) {
 
         return Lists.newArrayList(Collections2.transform(Lists.newArrayList(yangPaths),
-                new Function<String, InputStream>() {
-                    @Override
-                    public InputStream apply(final String input) {
-                        final InputStream resourceAsStream = NormalizedDataBuilderTest.class.getResourceAsStream(input);
-                        Preconditions.checkNotNull(resourceAsStream, "File %s was null", resourceAsStream);
-                        return resourceAsStream;
-                    }
+                input -> {
+                    final InputStream resourceAsStream = NormalizedDataBuilderTest.class.getResourceAsStream(input);
+                    Preconditions.checkNotNull(resourceAsStream, "File %s was null", resourceAsStream);
+                    return resourceAsStream;
                 }));
     }
 
index 331d80ddeb854266458d076fe179836918ff2e6e..11e8662c7aee888ac407b00cc27a1932db6b2ae3 100644 (file)
@@ -11,7 +11,6 @@ import com.google.common.base.Converter;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
-import java.util.Collection;
 import java.util.List;
 import javax.xml.xpath.XPathExpressionException;
 import org.jaxen.BaseXPath;
@@ -20,7 +19,6 @@ import org.jaxen.JaxenException;
 import org.jaxen.expr.Expr;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.xpath.XPathBooleanResult;
 import org.opendaylight.yangtools.yang.data.api.schema.xpath.XPathDocument;
 import org.opendaylight.yangtools.yang.data.api.schema.xpath.XPathExpression;
@@ -83,34 +81,15 @@ final class JaxenXPath implements XPathExpression {
         }
 
         if (result instanceof String) {
-            return Optional.of(new XPathStringResult() {
-                @Override
-                public String getValue() {
-                    return (String)result;
-                }
-            });
+            return Optional.of((XPathStringResult) () -> (String)result);
         } else if (result instanceof Number) {
-            return Optional.of(new XPathNumberResult() {
-                @Override
-                public Number getValue() {
-                    return (Number) result;
-                }
-            });
+            return Optional.of((XPathNumberResult) () -> (Number) result);
         } else if (result instanceof Boolean) {
-            return Optional.of(new XPathBooleanResult() {
-                @Override
-                public Boolean getValue() {
-                    return (Boolean) result;
-                }
-            });
+            return Optional.of((XPathBooleanResult) () -> (Boolean) result);
         } else if (result != null){
-            return Optional.of(new XPathNodesetResult() {
-                @SuppressWarnings("unchecked")
-                @Override
-                public Collection<NormalizedNode<?, ?>> getValue() {
-                    // XXX: Will this really work, or do we need to perform deep transformation?
-                    return Lists.transform((List<NormalizedNodeContext>) result, NormalizedNodeContext::getNode);
-                }
+            return Optional.of((XPathNodesetResult) () -> {
+                // XXX: Will this really work, or do we need to perform deep transformation?
+                return Lists.transform((List<NormalizedNodeContext>) result, NormalizedNodeContext::getNode);
             });
         } else {
             return Optional.absent();
index a29ad42a4636d1961ad53d950a07d8882eea5dd8..939b0451ecf365a0dd82aec0efdc59ef49a9fe2b 100644 (file)
@@ -13,7 +13,6 @@ import com.google.common.collect.Maps;
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -275,12 +274,8 @@ final class Util {
                     //FIXME: code duplicate
                     File yangDir = new File(file, YangToSourcesProcessor.META_INF_YANG_STRING);
                     if (yangDir.exists() && yangDir.isDirectory()) {
-                        File[] yangFiles = yangDir.listFiles(new FilenameFilter() {
-                            @Override
-                            public boolean accept(File dir, String name) {
-                                return name.endsWith(".yang") && new File(dir, name).isFile();
-                            }
-                        });
+                        File[] yangFiles = yangDir.listFiles(
+                                (dir, name) -> name.endsWith(".yang") && new File(dir, name).isFile());
                         for (final File yangFile : yangFiles) {
                             yangsFromDependencies.add(new YangSourceFromFile(yangFile));
                         }
@@ -344,12 +339,8 @@ final class Util {
                     //FIXME: code duplicate
                     File yangDir = new File(file, YangToSourcesProcessor.META_INF_YANG_STRING);
                     if (yangDir.exists() && yangDir.isDirectory()) {
-                        File[] yangFiles = yangDir.listFiles(new FilenameFilter() {
-                            @Override
-                            public boolean accept(File dir, String name) {
-                                return name.endsWith(".yang") && new File(dir, name).isFile();
-                            }
-                        });
+                        File[] yangFiles = yangDir.listFiles(
+                                (dir, name) -> name.endsWith(".yang") && new File(dir, name).isFile());
 
                         yangsFilesFromDependencies.addAll(Arrays.asList(yangFiles));
                     }
index ea629398f5b1e4b2bc4466dfae2000651f647634..f894fc9b939aa875aac78fe2f64c68845ff63873 100644 (file)
@@ -16,7 +16,6 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.UnmodifiableIterator;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Objects;
@@ -250,28 +249,23 @@ public abstract class SchemaPath implements Immutable {
      *         path from the schema node towards the root.
      */
     public Iterable<QName> getPathTowardsRoot() {
-        return new Iterable<QName>() {
+        return () -> new UnmodifiableIterator<QName>() {
+            private SchemaPath current = SchemaPath.this;
+
+            @Override
+            public boolean hasNext() {
+                return current.parent != null;
+            }
+
             @Override
-            public Iterator<QName> iterator() {
-                return new UnmodifiableIterator<QName>() {
-                    private SchemaPath current = SchemaPath.this;
-
-                    @Override
-                    public boolean hasNext() {
-                        return current.parent != null;
-                    }
-
-                    @Override
-                    public QName next() {
-                        if (current.parent != null) {
-                            final QName ret = current.qname;
-                            current = current.parent;
-                            return ret;
-                        } else {
-                            throw new NoSuchElementException("No more elements available");
-                        }
-                    }
-                };
+            public QName next() {
+                if (current.parent != null) {
+                    final QName ret = current.qname;
+                    current = current.parent;
+                    return ret;
+                } else {
+                    throw new NoSuchElementException("No more elements available");
+                }
             }
         };
     }
index 50740270d0dfea7182f78c51813f455373de6591..4a6236300737be2a514a49df8ee4180cec0b6daf 100644 (file)
@@ -14,7 +14,6 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.UnmodifiableIterator;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.Objects;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
@@ -237,28 +236,23 @@ public abstract class SchemaNodeIdentifier implements Immutable {
      *         path from the schema node towards the root.
      */
     public Iterable<QName> getPathTowardsRoot() {
-        return new Iterable<QName>() {
+        return () -> new UnmodifiableIterator<QName>() {
+            private SchemaNodeIdentifier current = SchemaNodeIdentifier.this;
+
+            @Override
+            public boolean hasNext() {
+                return current.parent != null;
+            }
+
             @Override
-            public Iterator<QName> iterator() {
-                return new UnmodifiableIterator<QName>() {
-                    private SchemaNodeIdentifier current = SchemaNodeIdentifier.this;
-
-                    @Override
-                    public boolean hasNext() {
-                        return current.parent != null;
-                    }
-
-                    @Override
-                    public QName next() {
-                        if (current.parent != null) {
-                            final QName ret = current.qname;
-                            current = current.parent;
-                            return ret;
-                        } else {
-                            throw new NoSuchElementException("No more elements available");
-                        }
-                    }
-                };
+            public QName next() {
+                if (current.parent != null) {
+                    final QName ret = current.qname;
+                    current = current.parent;
+                    return ret;
+                } else {
+                    throw new NoSuchElementException("No more elements available");
+                }
             }
         };
     }
index fd1bb7448c8b0f1e51888a236626c29755ed53d5..1231e7832d9a2492d1266771b601783b290c2e0b 100644 (file)
@@ -24,12 +24,9 @@ import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
 
 final class StmtTestUtils {
 
-    final static FileFilter YANG_FILE_FILTER = new FileFilter() {
-        @Override
-        public boolean accept(File file) {
-            String name = file.getName().toLowerCase();
-            return name.endsWith(".yang") && file.isFile();
-        }
+    final static FileFilter YANG_FILE_FILTER = file -> {
+        String name = file.getName().toLowerCase();
+        return name.endsWith(".yang") && file.isFile();
     };
 
     private StmtTestUtils() {
index 49a2e13ff092743b0fdbd5db6702bab88a037a78..5274352a78d11812204ce91350b6c8192d2884ec 100644 (file)
@@ -99,7 +99,7 @@ public final class FilteringSchemaContextProxy extends AbstractSchemaContext {
     }
 
     private static TreeMultimap<String, Module> getStringModuleTreeMultimap() {
-        return TreeMultimap.create((o1, o2) -> o1.compareTo(o2), REVISION_COMPARATOR);
+        return TreeMultimap.create(String::compareTo, REVISION_COMPARATOR);
     }
 
     private static void processForAdditionalModules(final SchemaContext delegate,
index ec956dbb98d59007ce3f75b28fe2e434622abfb7..a094f91f14d2859e4bc47ac1bddfe6bb1159b1bd 100644 (file)
@@ -21,7 +21,6 @@ import static org.mockito.Mockito.verify;
 
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 
-import com.google.common.base.Function;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
 import com.google.common.collect.Collections2;
@@ -98,12 +97,7 @@ public class FilesystemSchemaSourceCacheTest {
     }
 
     private static Collection<String> filesToFilenamesWithoutRevision(final List<File> storedFiles) {
-        return Collections2.transform(storedFiles, new Function<File, String>() {
-            @Override
-            public String apply(final File input) {
-                return Files.getNameWithoutExtension(input.getName());
-            }
-        });
+        return Collections2.transform(storedFiles, input -> Files.getNameWithoutExtension(input.getName()));
     }
 
     @Test
index 74fdd97c242d39de19ed18762818326a7cfd2635..d4a8219627b4f641889ee641493528dec9b5523f 100644 (file)
@@ -39,9 +39,7 @@ public final class ChoiceEffectiveStatementImpl extends AbstractEffectiveDataSch
      * Comparator based on alphabetical order of local name of SchemaNode's
      * qname.
      */
-    private static final Comparator<SchemaNode> SCHEMA_NODE_COMP = (o1, o2) -> {
-        return o1.getQName().compareTo(o2.getQName());
-    };
+    private static final Comparator<SchemaNode> SCHEMA_NODE_COMP = (o1, o2) -> o1.getQName().compareTo(o2.getQName());
 
     private final ChoiceSchemaNode original;
     private final String defaultCase;
index 2a2fd60f11e88cbfd3eeb18914c5bc0990f3568d..f9dff888633ea5be2aefeda2488fc485ede15044 100644 (file)
@@ -242,12 +242,8 @@ public class SharedSchemaRepositoryTest {
 
         assertEquals(4, listener.registeredSources.size());
 
-        final Function<PotentialSchemaSource<?>, SourceIdentifier> potSourceToSID = new Function<PotentialSchemaSource<?>, SourceIdentifier>() {
-            @Override
-            public SourceIdentifier apply(final PotentialSchemaSource<?> input) {
-                return input.getSourceIdentifier();
-            }
-        };
+        final Function<PotentialSchemaSource<?>, SourceIdentifier> potSourceToSID =
+                PotentialSchemaSource::getSourceIdentifier;
         assertThat(Collections2.transform(listener.registeredSources, potSourceToSID),
                 both(hasItem(RevisionSourceIdentifier.create("test", Optional.absent())))
                         .and(hasItem(RevisionSourceIdentifier.create("test", Optional.of("2012-12-12"))))
index 87b6176750571187e3417b5f12e7eb536e9070c0..5ee247647199d5e0a67f34aa02caefa410372eda 100644 (file)
@@ -36,20 +36,14 @@ import org.slf4j.LoggerFactory;
 
 public class StmtTestUtils {
 
-    final public static FileFilter YANG_FILE_FILTER = new FileFilter() {
-        @Override
-        public boolean accept(File file) {
-            String name = file.getName().toLowerCase();
-            return name.endsWith(".yang") && file.isFile();
-        }
+    final public static FileFilter YANG_FILE_FILTER = file -> {
+        String name = file.getName().toLowerCase();
+        return name.endsWith(".yang") && file.isFile();
     };
 
-    final public static FileFilter YIN_FILE_FILTER = new FileFilter() {
-        @Override
-        public boolean accept(File file) {
-            String name = file.getName().toLowerCase();
-            return name.endsWith(".xml") && file.isFile();
-        }
+    final public static FileFilter YIN_FILE_FILTER = file -> {
+        String name = file.getName().toLowerCase();
+        return name.endsWith(".xml") && file.isFile();
     };
 
     private static final Logger LOG = LoggerFactory.getLogger(StmtTestUtils.class);