Ignore:
Timestamp:
2016-05-29T16:33:08+02:00 (8 years ago)
Author:
Don-vip
Message:

sonar - Performance - Method passes constant String of length 1 to character overridden method + add unit tests/javadoc

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java

    r10208 r10299  
    319319            defaultExtension,
    320320            description + (!extensionsForDescription.isEmpty()
    321                 ? (" (" + Utils.join(", ", extensionsForDescription) + ")")
     321                ? (" (" + Utils.join(", ", extensionsForDescription) + ')')
    322322                : "")
    323323            );
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r10220 r10299  
    244244
    245245    public interface BinaryMatchFactory extends MatchFactory {
    246         BinaryMatch get(String keyword, Match lhs, Match rhs, PushbackTokenizer tokenizer) throws ParseError;
     246        AbstractBinaryMatch get(String keyword, Match lhs, Match rhs, PushbackTokenizer tokenizer) throws ParseError;
    247247    }
    248248
     
    337337     * A binary search operator which may take data parameters.
    338338     */
    339     public abstract static class BinaryMatch extends Match {
     339    public abstract static class AbstractBinaryMatch extends Match {
    340340
    341341        protected final Match lhs;
    342342        protected final Match rhs;
    343343
    344         public BinaryMatch(Match lhs, Match rhs) {
     344        /**
     345         * Constructs a new {@code BinaryMatch}.
     346         * @param lhs Left hand side
     347         * @param rhs Right hand side
     348         */
     349        public AbstractBinaryMatch(Match lhs, Match rhs) {
    345350            this.lhs = lhs;
    346351            this.rhs = rhs;
    347352        }
    348353
    349         public Match getLhs() {
     354        /**
     355         * Returns left hand side.
     356         * @return left hand side
     357         */
     358        public final Match getLhs() {
    350359            return lhs;
    351360        }
    352361
    353         public Match getRhs() {
     362        /**
     363         * Returns right hand side.
     364         * @return right hand side
     365         */
     366        public final Match getRhs() {
    354367            return rhs;
    355368        }
     
    438451     * Matches if both left and right expressions match.
    439452     */
    440     public static class And extends BinaryMatch {
     453    public static class And extends AbstractBinaryMatch {
     454        /**
     455         * Constructs a new {@code And} match.
     456         * @param lhs left hand side
     457         * @param rhs right hand side
     458         */
    441459        public And(Match lhs, Match rhs) {
    442460            super(lhs, rhs);
     
    455473        @Override
    456474        public String toString() {
    457             return (lhs instanceof BinaryMatch && !(lhs instanceof And) ? "(" + lhs + ")" : lhs) + " && "
    458                     + (rhs instanceof BinaryMatch && !(rhs instanceof And) ? "(" + rhs + ")" : rhs);
     475            return (lhs instanceof AbstractBinaryMatch && !(lhs instanceof And) ? ("(" + lhs + ')') : lhs) + " && "
     476                    + (rhs instanceof AbstractBinaryMatch && !(rhs instanceof And) ? ("(" + rhs + ')') : rhs);
    459477        }
    460478    }
     
    463481     * Matches if the left OR the right expression match.
    464482     */
    465     public static class Or extends BinaryMatch {
     483    public static class Or extends AbstractBinaryMatch {
     484        /**
     485         * Constructs a new {@code Or} match.
     486         * @param lhs left hand side
     487         * @param rhs right hand side
     488         */
    466489        public Or(Match lhs, Match rhs) {
    467490            super(lhs, rhs);
     
    480503        @Override
    481504        public String toString() {
    482             return (lhs instanceof BinaryMatch && !(lhs instanceof Or) ? "(" + lhs + ")" : lhs) + " || "
    483                     + (rhs instanceof BinaryMatch && !(rhs instanceof Or) ? "(" + rhs + ")" : rhs);
     505            return (lhs instanceof AbstractBinaryMatch && !(lhs instanceof Or) ? ("(" + lhs + ')') : lhs) + " || "
     506                    + (rhs instanceof AbstractBinaryMatch && !(rhs instanceof Or) ? ("(" + rhs + ')') : rhs);
    484507        }
    485508    }
     
    488511     * Matches if the left OR the right expression match, but not both.
    489512     */
    490     public static class Xor extends BinaryMatch {
     513    public static class Xor extends AbstractBinaryMatch {
     514        /**
     515         * Constructs a new {@code Xor} match.
     516         * @param lhs left hand side
     517         * @param rhs right hand side
     518         */
    491519        public Xor(Match lhs, Match rhs) {
    492520            super(lhs, rhs);
     
    505533        @Override
    506534        public String toString() {
    507             return (lhs instanceof BinaryMatch && !(lhs instanceof Xor) ? "(" + lhs + ")" : lhs) + " ^ "
    508                     + (rhs instanceof BinaryMatch && !(rhs instanceof Xor) ? "(" + rhs + ")" : rhs);
     535            return (lhs instanceof AbstractBinaryMatch && !(lhs instanceof Xor) ? ("(" + lhs + ')') : lhs) + " ^ "
     536                    + (rhs instanceof AbstractBinaryMatch && !(rhs instanceof Xor) ? ("(" + rhs + ')') : rhs);
    509537        }
    510538    }
     
    17551783        final String forKey = '"' + escapeStringForSearch(key) + '"' + '=';
    17561784        if (value == null || value.isEmpty()) {
    1757             return forKey + "*";
     1785            return forKey + '*';
    17581786        } else {
    17591787            return forKey + '"' + escapeStringForSearch(value) + '"';
Note: See TracChangeset for help on using the changeset viewer.