GNPy migration to Aluminium
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / gnpy / utils / ZToAComparator.java
diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/gnpy/utils/ZToAComparator.java b/pce/src/main/java/org/opendaylight/transportpce/pce/gnpy/utils/ZToAComparator.java
new file mode 100644 (file)
index 0000000..5e3021f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2020 Orange, 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.transportpce.pce.gnpy.utils;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.path.description.ztoa.direction.ZToA;
+
+@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
+    value = "SE_NO_SERIALVERSIONID",
+    justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
+public class ZToAComparator implements Comparator<ZToA>, Serializable {
+
+    @Override
+    public int compare(ZToA o1, ZToA o2) {
+        if (o1 == null && o2 == null) {
+            return 0;
+        } else if (o1 == null) {
+            return 1;
+        } else if (o2 == null) {
+            return -1;
+        } else if (o1.getId() == null && o2.getId() == null) {
+            return 0;
+        } else if (o1.getId() == null) {
+            return 1;
+        } else if (o2.getId() == null) {
+            return -1;
+        } else {
+            return Integer.valueOf(o1.getId()).compareTo(Integer.valueOf(o2.getId()));
+        }
+    }
+
+}