Hi Mark,

> -----Original Message-----
> From: ma...@apache.org [mailto:ma...@apache.org]
> Sent: Friday, April 25, 2014 9:50 PM

<snip>

> +        @Override
> +        public int compareTo(MatchResult o) {
> +            if (this.getExact() < o.getExact()) {
> +                return -1;
> +            } else if (this.getExact() > o.getExact()) {
> +                return 1;
> +            } else {
> +                if (this.getAssignable() < o.getAssignable()) {
> +                    return -1;
> +                } else if (this.getAssignable() > o.getAssignable()) {
> +                    return 1;
> +                } else {
> +                    if (this.getCoercible() < o.getCoercible()) {
> +                        return -1;
> +                    } else if (this.getCoercible() > o.getCoercible()) {
> +                        return 1;
> +                    } else {
> +                        return 0;
> +                    }
> +                }
> +            }
> +        }

What about using Integer.compare(int, int), e.g.:

        @Override
        public int compareTo(MatchResult o) {
            int cmp = Integer.compare(this.getExact(), o.getExact());
            if (cmp == 0) {
                cmp = Integer.compare(this.getAssignable(), o.getAssignable());
                if (cmp == 0) {
                    cmp = Integer.compare(this.getCoercible(), 
o.getCoercible());
                }
            }
            return cmp;
        }

(but according to Java API documentation, Integer.compare(int, int) is only 
available since Java 1.7)


Regards,
Konstantin Preißer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to