Bug 4098 - ofoverlay-renderer failure in jdk8
[groupbasedpolicy.git] / neutron-ovsdb / src / main / java / org / opendaylight / groupbasedpolicy / neutron / ovsdb / AbstractTunnelType.java
index 15825c508acd1d55bd3c868b496c21f23bc02933..c04820c8630ff96a2da07eba1d5458fcec1ccda6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 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,
@@ -22,51 +22,62 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsBuilder;
 
 public abstract class AbstractTunnelType {
+
+    protected static final String DESTPORT_KEY = "dst_port";
     protected static final String REMOTE_IP_KEY = "remote_ip";
     protected static final String REMOTE_IP_VALUE = "flow";
     protected static final String VNID_KEY = "key";
     protected static final String VNID_VALUE = "flow";
 
     protected List<Options> createOptionsList(Map<String, String> optionsMap) {
-               List<Options> options = new ArrayList<Options>();
+        List<Options> options = new ArrayList<Options>();
         OptionsBuilder ob = new OptionsBuilder();
-        for (Entry<String, String> entry: optionsMap.entrySet()) {
+        for (Entry<String, String> entry : optionsMap.entrySet()) {
             ob.setOption(entry.getKey());
             ob.setValue(entry.getValue());
             options.add(ob.build());
         }
         return Collections.unmodifiableList(options);
-       }
+    }
 
-    protected boolean hasTunnelOptions(OvsdbTerminationPointAugmentation tpAugmentation,
-            Map<String, String> optionsMap) {
+    protected boolean hasTunnelOptions(OvsdbTerminationPointAugmentation tpAugmentation, Map<String, String> optionsMap) {
 
         Map<String, String> foundOpts = new HashMap<String, String>();
         List<Options> options = tpAugmentation.getOptions();
         if (options != null) {
-            for (Options opt: options) {
+            for (Options opt : options) {
                 // skip invalid options
-                if (opt.getOption() == null
-                    || opt.getValue() == null) continue;
+                if (opt.getOption() == null || opt.getValue() == null)
+                    continue;
 
-                if (optionsMap.containsKey(opt.getOption())
-                         && optionsMap.get(opt.getOption())
-                                   .equals(opt.getValue())) {
+                if (optionsMap.containsKey(opt.getOption()) && optionsMap.get(opt.getOption()).equals(opt.getValue())) {
                     foundOpts.put(opt.getOption(), opt.getValue());
                 }
             }
-            if ((foundOpts.size() == optionsMap.size())
-                    && (options.size() == foundOpts.size())) {
+            if ((foundOpts.size() == optionsMap.size()) && (options.size() == foundOpts.size())) {
                 return true;
             }
         }
         return false;
     }
 
+    protected String getDestPort(OvsdbTerminationPointAugmentation tpAugmentation) {
+        List<Options> options = tpAugmentation.getOptions();
+        if (options == null) {
+            return null;
+        }
+        for (Options opt : options) {
+            if (DESTPORT_KEY.equals(opt.getOption())) {
+                return opt.getValue();
+            }
+        }
+        return null;
+    }
+
     /**
-     * Return the {@link List<Options>} valid for this tunnel type
+     * Return the list of {@link Options} valid for this tunnel type
      *
-     * @return {@link List<Options>} for the tunnel, null if not supported
+     * @return list of {@link Options} for the tunnel, null if not supported
      */
     public abstract List<Options> getOptions();
 
@@ -74,7 +85,7 @@ public abstract class AbstractTunnelType {
      * Check if a TerminationPoint is a tunnel port that meets
      * requirements
      *
-     * @param tpAugmentation
+     * @param tpAugmentation the {@link OvsdbTerminationPointAugmentation}
      * @return String of the tunnel port name (null if not found)
      */
     public abstract boolean isValidTunnelPort(OvsdbTerminationPointAugmentation tpAugmentation);