tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Preißer <kpreis...@apache.org>
Subject RE: svn commit: r1590120 - in /tomcat/trunk: java/javax/el/Util.java java/org/apache/el/util/ReflectionUtil.java test/javax/el/TestUtil.java webapps/docs/changelog.xml
Date Fri, 25 Apr 2014 20:41:01 GMT
Hi Mark,

> -----Original Message-----
> From: markt@apache.org [mailto:markt@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message