Fix license header violations in sal-dom-xsql
[controller.git] / opendaylight / md-sal / sal-dom-xsql / src / main / java / org / opendaylight / controller / md / sal / dom / xsql / XSQLBluePrintRelation.java
index f6b3a1d83b584df827761cd825a9f4c04e845019..68c8376050444134558e376b500fa7422ca1f4bd 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 package org.opendaylight.controller.md.sal.dom.xsql;
 
 import java.io.Serializable;
@@ -80,60 +88,40 @@ public class XSQLBluePrintRelation implements Serializable {
         }
     }
 
-    public List execute(Object o) {
-        List result = new LinkedList();
+    public List<?> execute(Object o) {
         if (o == null) {
             return null;
         }
 
-        if (Set.class.isAssignableFrom(o.getClass())) {
-            Set<?> lst = (Set<?>) o;
-            for (Object oo : lst) {
+        List<Object> result = new LinkedList<>();
+        if (o instanceof Set) {
+            for (Object oo : (Set<?>) o) {
                 addToResult(result, execute(oo));
             }
-            return result;
-        } else if (List.class.isAssignableFrom(o.getClass())) {
-            List lst = (List) o;
-            for (Object oo : lst) {
+        } else if (o instanceof List) {
+            for (Object oo : (List<?>) o) {
                 addToResult(result, execute(oo));
             }
-            return result;
-        } else if (Map.class.isAssignableFrom(o.getClass())) {
-            Map map = (Map) o;
-            for (Object oo : map.values()) {
+        } else if (o instanceof Map) {
+            for (Object oo : ((Map<?, ?>) o).values()) {
                 addToResult(result, execute(oo));
             }
-            return result;
+        } else {
+            addToResult(result, XSQLCriteria.getValue(o, this.property));
         }
-
-        addToResult(result, XSQLCriteria.getValue(o, this.property));
-
         return result;
     }
 
-    public static void addToResult(List result, Object o) {
-        if (o == null) {
-            return;
-        }
-        if (Set.class.isAssignableFrom(o.getClass())) {
-            Set<?> lst = (Set<?>) o;
-            for (Object oo : lst) {
-                result.add(oo);
-            }
-        } else if (List.class.isAssignableFrom(o.getClass())) {
-            List lst = (List) o;
-            for (Object oo : lst) {
-                result.add(oo);
-            }
-        } else if (Map.class.isAssignableFrom(o.getClass())) {
-            Map map = (Map) o;
-            for (Object oo : map.values()) {
-                result.add(oo);
-            }
-        } else {
+    private static void addToResult(List<Object> result, Object o) {
+        if (o instanceof Set) {
+            result.addAll((Set<?>)o);
+        } else if (o instanceof List) {
+            result.addAll((List<?>)o);
+        } else if (o instanceof Map) {
+            result.addAll(((Map<?, ?>)o).values());
+        } else if (o != null) {
             result.add(o);
         }
     }
-
 }