/** * Sorts the Services into Path Specificity descending order That is to say that the resultant * sorted list should have the most specific URI's at the top! * * @param other Another Service */ @Override public int compareTo(final RestXqService other) { if (other == null || !(other instanceof RestXqService)) { return 1; } final long pathSpecificityMetric; if (getResourceFunction().getPathAnnotation() != null) { pathSpecificityMetric = getResourceFunction().getPathAnnotation().getPathSpecificityMetric(); } else { pathSpecificityMetric = 0; } final long otherPathSpecificityMetric; if (other.getResourceFunction().getPathAnnotation() != null) { otherPathSpecificityMetric = other.getResourceFunction().getPathAnnotation().getPathSpecificityMetric(); } else { otherPathSpecificityMetric = 0; } long result = otherPathSpecificityMetric - pathSpecificityMetric; if (result > 0) { return 1; } else if (result < 0) { return -1; } else { return 0; } }
/** * Determines if this Service is equal to another Service * * <p>Compares: 1) the URI to the XQuery containing the Resource Function 2) the name of the * Resource Function 3) the arity of the Resource Function */ @Override public boolean equals(final Object obj) { final FunctionSignature fnSignature = getResourceFunction().getFunctionSignature(); if (obj == null) { return false; } if (!(obj instanceof RestXqService)) { return false; } final RestXqService other = ((RestXqService) obj); return other .getResourceFunction() .getXQueryLocation() .equals(getResourceFunction().getXQueryLocation()) && other .getResourceFunction() .getFunctionSignature() .getName() .equals(fnSignature.getName()) && other.getResourceFunction().getFunctionSignature().getArgumentCount() == fnSignature.getArgumentCount(); }