protected static boolean isEpPortEqualOrInRange()

in Utils/azure-toolkit-ide-libs/azure-toolkit-ide-common-lib/src/main/java/com/microsoft/azure/toolkit/ide/common/util/ParserXMLUtility.java [221:268]


    protected static boolean isEpPortEqualOrInRange(String oldPort,
                                                    String newPort) {
        boolean isEqual = false;
        try {

            int oldMin = 0;
            int oldMax = 0;
            int newMin = 0;
            int newMax = 0;
            if (oldPort.contains("-")) {
                String[] rang = oldPort.split("-");
                oldMin = Integer.valueOf(rang[0]);
                oldMax = Integer.valueOf(rang[1]);
            } else {
                oldMax = Integer.valueOf(oldPort);
                oldMin = Integer.valueOf(oldPort);
            }

            if (newPort.contains("-")) {
                String[] rang = newPort.split("-");
                newMin = Integer.valueOf(rang[0]);
                newMax = Integer.valueOf(rang[1]);
            } else {
                newMax = Integer.valueOf(newPort);
                newMin = Integer.valueOf(newPort);
            }

            // check for newmin range is in between old range
            if ((newMin == oldMin) || newMin == oldMax
                    || (newMin > oldMin && newMin < oldMax)) {
                isEqual = true;
            } else if ((newMax == oldMin) || newMax == oldMax
                    || (newMax > oldMin && newMax < oldMax)) {
                // check for newmax range is in between old range
                isEqual = true;
            } else if ((oldMin > newMin && oldMin < newMax)) {
                // check for oldnim should not be in new range i.e. check for
                // overlapping
                isEqual = true;
            } else if (oldMax > newMin && oldMax < newMax) {
                isEqual = true;
            }

        } catch (Exception e) {
            isEqual = false;
        }
        return isEqual;
    }