Neutron-mapper uses only DTOs from neutron.yang
[groupbasedpolicy.git] / neutron-mapper / src / main / java / org / opendaylight / groupbasedpolicy / neutron / mapper / util / RouterUtils.java
diff --git a/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/util/RouterUtils.java b/neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/util/RouterUtils.java
new file mode 100644 (file)
index 0000000..cb6fe7c
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.neutron.mapper.util;
+
+import javax.annotation.Nullable;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
+
+import com.google.common.base.Optional;
+
+public class RouterUtils {
+
+    public static Optional<Router> findRouter(Uuid uuid, @Nullable Routers routers) {
+        if (routers == null || routers.getRouter() == null) {
+            return Optional.absent();
+        }
+        for (Router router : routers.getRouter()) {
+            if (router.getUuid().equals(uuid)) {
+                return Optional.of(router);
+            }
+        }
+        return Optional.absent();
+    }
+}