2 * Copyright © 2020 AT&T, Inc. and others. All rights reserved.
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
8 package org.opendaylight.transportpce.common.mapping;
10 import java.io.Serializable;
11 import java.util.Comparator;
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.Port;
15 * Class to compare two String containing integer.
17 * @author Martial Coulibaly (martial.coulibaly@gfi.com) on behalf of Orange
20 @SuppressWarnings("serial")
21 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
22 value = "SE_NO_SERIALVERSIONID",
23 justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
24 public class SortPort710ByName implements Comparator<Port>, Serializable {
27 public int compare(Port port1, Port port2) {
28 return extractInt(port1) - extractInt(port2);
31 private int extractInt(Port port) {
32 String num = port.getPortName().replaceAll("\\D", "");
33 return num.isEmpty() ? 0 : Integer.parseInt(num);