minor simplification in INeutronRequest 72/76772/2
authorMichael Vorburger <vorburger@redhat.com>
Mon, 8 Oct 2018 22:01:35 +0000 (00:01 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Mon, 29 Oct 2018 16:04:04 +0000 (16:04 +0000)
let isSingleton() delegate to getSingleton()

PS: Looking at this, I have an idea for a more fundamental improvement.

Change-Id: I84d87f9d687af213f08b89dd5fe6c6a3f5044e05
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/INeutronRequest.java

index c6c61ad0327e0ab9ea5740ff61b3343649c0bd31..f03c00bf2f53fa336ff636ef5021d21e7eb74024 100644 (file)
@@ -13,8 +13,9 @@ import java.util.List;
 import org.opendaylight.neutron.spi.INeutronObject;
 
 public interface INeutronRequest<T extends INeutronObject<T>> {
+
     default T getSingleton() {
-        // return this.sinleton
+        // return this.singleton
         Class<?> cls = getClass();
         try {
             Field field = cls.getDeclaredField("singleton");
@@ -27,14 +28,7 @@ public interface INeutronRequest<T extends INeutronObject<T>> {
     }
 
     default boolean isSingleton() {
-        // return this.sinleton != null
-        Class<?> cls = getClass();
-        try {
-            Field field = cls.getDeclaredField("singleton");
-            return field.get(this) != null;
-        } catch (IllegalAccessException | NoSuchFieldException e) {
-            throw new IllegalArgumentException(e);
-        }
+        return getSingleton() != null;
     }
 
     default List<T> getBulk() {