NetworkModelListener: handling TopologyUpdates
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / gnpy / utils / AToZComparator.java
1 /*
2  * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.transportpce.pce.gnpy.utils;
10
11 import java.io.Serializable;
12 import java.util.Comparator;
13 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.atoz.direction.AToZ;
14
15 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
16     value = "SE_NO_SERIALVERSIONID",
17     justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
18 public class AToZComparator implements Comparator<AToZ>, Serializable {
19
20     @Override
21     public int compare(AToZ o1, AToZ o2) {
22         if (o1 == null && o2 == null) {
23             return 0;
24         } else if (o1 == null) {
25             return 1;
26         } else if (o2 == null) {
27             return -1;
28         } else if (o1.getId() == null && o2.getId() == null) {
29             return 0;
30         } else if (o1.getId() == null) {
31             return 1;
32         } else if (o2.getId() == null) {
33             return -1;
34         } else {
35             return Integer.valueOf(o1.getId()).compareTo(Integer.valueOf(o2.getId()));
36         }
37     }
38
39 }