Changeset 18877 in josm for trunk/src/org


Ignore:
Timestamp:
2023-10-24T17:29:11+02:00 (13 months ago)
Author:
taylor.smock
Message:

See #23220: Use jakarta.annotation instead of javax.annotation (JSR305)

jsr305 should be removed in June 2024 to give plugins time to migrate.

Some lint issues were also fixed.

Location:
trunk/src/org/openstreetmap/josm
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/notes/Note.java

    r18479 r18877  
    1212import org.openstreetmap.josm.data.coor.LatLon;
    1313
    14 import javax.annotation.Nullable;
     14import jakarta.annotation.Nullable;
    1515
    1616/**
  • trunk/src/org/openstreetmap/josm/data/osm/pbf/Blob.java

    r18698 r18877  
    77import java.util.zip.InflaterInputStream;
    88
    9 import javax.annotation.Nonnull;
    10 import javax.annotation.Nullable;
     9import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
    1110
    12 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
     11import jakarta.annotation.Nonnull;
     12import jakarta.annotation.Nullable;
    1313
    1414/**
  • trunk/src/org/openstreetmap/josm/data/osm/pbf/BlobHeader.java

    r18702 r18877  
    22package org.openstreetmap.josm.data.osm.pbf;
    33
    4 import javax.annotation.Nonnull;
    5 import javax.annotation.Nullable;
     4import jakarta.annotation.Nonnull;
     5import jakarta.annotation.Nullable;
    66
    77/**
  • trunk/src/org/openstreetmap/josm/data/osm/pbf/HeaderBlock.java

    r18697 r18877  
    22package org.openstreetmap.josm.data.osm.pbf;
    33
    4 import javax.annotation.Nonnull;
    5 import javax.annotation.Nullable;
     4import org.openstreetmap.josm.data.osm.BBox;
    65
    7 import org.openstreetmap.josm.data.osm.BBox;
     6import jakarta.annotation.Nonnull;
     7import jakarta.annotation.Nullable;
    88
    99/**
  • trunk/src/org/openstreetmap/josm/data/osm/pbf/Info.java

    r18702 r18877  
    22package org.openstreetmap.josm.data.osm.pbf;
    33
    4 import javax.annotation.Nullable;
     4import jakarta.annotation.Nullable;
    55
    66/**
  • trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java

    r18852 r18877  
    2727import java.util.regex.PatternSyntaxException;
    2828import java.util.stream.Collectors;
    29 
    30 import javax.annotation.Nonnull;
    31 import javax.annotation.Nullable;
    3229
    3330import org.openstreetmap.josm.data.Bounds;
     
    5956import org.openstreetmap.josm.tools.date.DateUtils;
    6057
     58import jakarta.annotation.Nonnull;
     59import jakarta.annotation.Nullable;
     60
    6161/**
    6262 * Implements a google-like search.
     
    8585    private final boolean caseSensitive;
    8686    private final boolean regexSearch;
    87     private static final String rxErrorMsg = marktr("The regex \"{0}\" had a parse error at offset {1}, full error:\n\n{2}");
    88     private static final String rxErrorMsgNoPos = marktr("The regex \"{0}\" had a parse error, full error:\n\n{1}");
     87    private static final String REGEX_ERROR_MESSAGE = marktr("The regex \"{0}\" had a parse error at offset {1}, full error:\n\n{2}");
     88    private static final String REGEX_ERROR_MESSAGE_NO_POSITION = marktr("The regex \"{0}\" had a parse error, full error:\n\n{1}");
     89    private static final String RANGE_OF_NUMBERS_EXPECTED = marktr("Range of numbers expected");
    8990    private final PushbackTokenizer tokenizer;
    9091    private static final Map<String, SimpleMatchFactory> simpleMatchFactoryMap = new HashMap<>();
    9192    private static final Map<String, UnaryMatchFactory> unaryMatchFactoryMap = new HashMap<>();
    9293    private static final Map<String, BinaryMatchFactory> binaryMatchFactoryMap = new HashMap<>();
     94
     95    // Common literals
     96    private static final String AREA_SIZE = "areasize";
     97    private static final String CHANGESET = "changeset";
     98    private static final String CLOSED = "closed";
     99    private static final String DELETED = "deleted";
     100    private static final String INCOMPLETE = "incomplete";
     101    private static final String IN_DOWNLOADED_AREA = "indownloadedarea";
     102    private static final String ALL_IN_DOWNLOADED_AREA = "all" + IN_DOWNLOADED_AREA;
     103    private static final String MEMBERS = "members";
     104    private static final String MODIFIED = "modified";
     105    private static final String NODES = "nodes";
     106    private static final String SELECTED = "selected";
     107    private static final String TIMESTAMP = "timestamp";
     108    private static final String UNTAGGED = "untagged";
     109    private static final String VERSION = "version";
     110    private static final String WAYS = "ways";
     111    private static final String WAY_LENGTH = "waylength";
    93112
    94113    static {
     
    134153     */
    135154    public static class CoreSimpleMatchFactory implements SimpleMatchFactory {
    136         private final Collection<String> keywords = Arrays.asList("id", "version", "type", "user", "role",
    137                 "changeset", "nodes", "ways", "members", "tags", "areasize", "waylength", "modified", "deleted", "selected",
    138                 "incomplete", "untagged", "closed", "new", "indownloadedarea",
    139                 "allindownloadedarea", "timestamp", "nth", "nth%", "hasRole", "preset");
     155        private final Collection<String> keywords = Arrays.asList("id", VERSION, "type", "user", "role",
     156                CHANGESET, NODES, WAYS, MEMBERS, "tags", AREA_SIZE, WAY_LENGTH, MODIFIED, DELETED, SELECTED,
     157                INCOMPLETE, UNTAGGED, CLOSED, "new", IN_DOWNLOADED_AREA,
     158                ALL_IN_DOWNLOADED_AREA, TIMESTAMP, "nth", "nth%", "hasRole", "preset");
    140159
    141160        @Override
    142161        public Match get(String keyword, boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer) throws SearchParseError {
    143162            switch(keyword) {
    144             case "modified":
     163            case MODIFIED:
    145164                return new Modified();
    146             case "deleted":
     165            case DELETED:
    147166                return new Deleted();
    148             case "selected":
     167            case SELECTED:
    149168                return new Selected();
    150             case "incomplete":
     169            case INCOMPLETE:
    151170                return new Incomplete();
    152             case "untagged":
     171            case UNTAGGED:
    153172                return new Untagged();
    154             case "closed":
     173            case CLOSED:
    155174                return new Closed();
    156175            case "new":
    157176                return new New();
    158             case "indownloadedarea":
     177            case IN_DOWNLOADED_AREA:
    159178                return new InDataSourceArea(false);
    160             case "allindownloadedarea":
     179            case ALL_IN_DOWNLOADED_AREA:
    161180                return new InDataSourceArea(true);
    162181            default:
     
    174193                case "id":
    175194                    return new Id(tokenizer);
    176                 case "version":
     195                case VERSION:
    177196                    return new Version(tokenizer);
    178197                case "type":
     
    184203                case "role":
    185204                    return new RoleMatch(tokenizer.readTextOrNumber());
    186                 case "changeset":
     205                case CHANGESET:
    187206                    return new ChangesetId(tokenizer);
    188                 case "nodes":
     207                case NODES:
    189208                    return new NodeCountRange(tokenizer);
    190                 case "ways":
     209                case WAYS:
    191210                    return new WayCountRange(tokenizer);
    192                 case "members":
     211                case MEMBERS:
    193212                    return new MemberCountRange(tokenizer);
    194213                case "tags":
    195214                    return new TagCountRange(tokenizer);
    196                 case "areasize":
     215                case AREA_SIZE:
    197216                    return new AreaSize(tokenizer);
    198                 case "waylength":
     217                case WAY_LENGTH:
    199218                    return new WayLength(tokenizer);
    200219                case "nth":
     
    204223                case "hasRole":
    205224                    return new HasRole(tokenizer);
    206                 case "timestamp":
     225                case TIMESTAMP:
    207226                    // add leading/trailing space in order to get expected split (e.g. "a--" => {"a", ""})
    208227                    String rangeS = ' ' + tokenizer.readTextOrNumber() + ' ';
     
    370389                return Pattern.compile(regex, flags);
    371390            } catch (PatternSyntaxException e) {
    372                 throw new SearchParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
     391                throw new SearchParseError(tr(REGEX_ERROR_MESSAGE, e.getPattern(), e.getIndex(), e.getMessage()), e);
    373392            } catch (IllegalArgumentException | StringIndexOutOfBoundsException e) {
    374393                // StringIndexOutOfBoundsException caught because of https://bugs.openjdk.java.net/browse/JI-9044959
    375394                // See #13870: To remove after we switch to a version of Java which resolves this bug
    376                 throw new SearchParseError(tr(rxErrorMsgNoPos, regex, e.getMessage()), e);
     395                throw new SearchParseError(tr(REGEX_ERROR_MESSAGE_NO_POSITION, regex, e.getMessage()), e);
    377396            }
    378397        }
     
    707726        @Override
    708727        protected String getString() {
    709             return "changeset";
     728            return CHANGESET;
    710729        }
    711730    }
     
    730749        @Override
    731750        protected String getString() {
    732             return "version";
     751            return VERSION;
    733752        }
    734753    }
     
    783802        private String getMv(Tagged osm) {
    784803            String mv;
    785             if ("timestamp".equals(key) && osm instanceof OsmPrimitive) {
     804            if (TIMESTAMP.equals(key) && osm instanceof OsmPrimitive) {
    786805                mv = ((OsmPrimitive) osm).getInstant().toString();
    787806            } else {
     
    14291448
    14301449        NodeCountRange(PushbackTokenizer tokenizer) throws SearchParseError {
    1431             this(tokenizer.readRange(tr("Range of numbers expected")));
     1450            this(tokenizer.readRange(tr(RANGE_OF_NUMBERS_EXPECTED)));
    14321451        }
    14331452
     
    14451464        @Override
    14461465        protected String getString() {
    1447             return "nodes";
     1466            return NODES;
    14481467        }
    14491468    }
     
    14581477
    14591478        WayCountRange(PushbackTokenizer tokenizer) throws SearchParseError {
    1460             this(tokenizer.readRange(tr("Range of numbers expected")));
     1479            this(tokenizer.readRange(tr(RANGE_OF_NUMBERS_EXPECTED)));
    14611480        }
    14621481
     
    14871506
    14881507        MemberCountRange(PushbackTokenizer tokenizer) throws SearchParseError {
    1489             this(tokenizer.readRange(tr("Range of numbers expected")));
     1508            this(tokenizer.readRange(tr(RANGE_OF_NUMBERS_EXPECTED)));
    14901509        }
    14911510
     
    15021521        @Override
    15031522        protected String getString() {
    1504             return "members";
     1523            return MEMBERS;
    15051524        }
    15061525    }
     
    15151534
    15161535        TagCountRange(PushbackTokenizer tokenizer) throws SearchParseError {
    1517             this(tokenizer.readRange(tr("Range of numbers expected")));
     1536            this(tokenizer.readRange(tr(RANGE_OF_NUMBERS_EXPECTED)));
    15181537        }
    15191538
     
    15661585        @Override
    15671586        protected String getString() {
    1568             return "timestamp";
     1587            return TIMESTAMP;
    15691588        }
    15701589    }
     
    16271646        @Override
    16281647        public String toString() {
    1629             return "modified";
     1648            return MODIFIED;
    16301649        }
    16311650    }
     
    16421661        @Override
    16431662        public String toString() {
    1644             return "deleted";
     1663            return DELETED;
    16451664        }
    16461665    }
     
    16571676        @Override
    16581677        public String toString() {
    1659             return "selected";
     1678            return SELECTED;
    16601679        }
    16611680    }
     
    16741693        @Override
    16751694        public String toString() {
    1676             return "incomplete";
     1695            return INCOMPLETE;
    16771696        }
    16781697    }
     
    16911710        @Override
    16921711        public String toString() {
    1693             return "untagged";
     1712            return UNTAGGED;
    16941713        }
    16951714    }
     
    17061725        @Override
    17071726        public String toString() {
    1708             return "closed";
     1727            return CLOSED;
    17091728        }
    17101729    }
     
    17671786
    17681787        AreaSize(PushbackTokenizer tokenizer) throws SearchParseError {
    1769             this(tokenizer.readRange(tr("Range of numbers expected")));
     1788            this(tokenizer.readRange(tr(RANGE_OF_NUMBERS_EXPECTED)));
    17701789        }
    17711790
     
    17781797        @Override
    17791798        protected String getString() {
    1780             return "areasize";
     1799            return AREA_SIZE;
    17811800        }
    17821801    }
     
    17921811
    17931812        WayLength(PushbackTokenizer tokenizer) throws SearchParseError {
    1794             this(tokenizer.readRange(tr("Range of numbers expected")));
     1813            this(tokenizer.readRange(tr(RANGE_OF_NUMBERS_EXPECTED)));
    17951814        }
    17961815
     
    18051824        @Override
    18061825        protected String getString() {
    1807             return "waylength";
     1826            return WAY_LENGTH;
    18081827        }
    18091828    }
     
    18781897        @Override
    18791898        public String toString() {
    1880             return all ? "allindownloadedarea" : "indownloadedarea";
     1899            return all ? ALL_IN_DOWNLOADED_AREA : IN_DOWNLOADED_AREA;
    18811900        }
    18821901    }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/viewers/projections/Equirectangular.java

    r18604 r18877  
    1313import java.util.Set;
    1414
    15 import javax.annotation.Nonnull;
    16 import javax.annotation.Nullable;
    17 
    1815import org.openstreetmap.josm.data.imagery.street_level.Projections;
    1916import org.openstreetmap.josm.gui.layer.geoimage.ImageDisplay;
     
    2118import org.openstreetmap.josm.gui.util.imagery.CameraPlane;
    2219import org.openstreetmap.josm.gui.util.imagery.Vector3D;
     20
     21import jakarta.annotation.Nonnull;
     22import jakarta.annotation.Nullable;
    2323
    2424/**
  • trunk/src/org/openstreetmap/josm/gui/util/imagery/CameraPlane.java

    r18398 r18877  
    1111import java.awt.image.DataBufferInt;
    1212import java.util.stream.IntStream;
    13 import javax.annotation.Nullable;
     13
     14import org.openstreetmap.josm.tools.Logging;
     15
     16import jakarta.annotation.Nullable;
    1417
    1518/**
     
    129132            res = rotate(vectors[x][y]);
    130133        } catch (Exception e) {
     134            Logging.trace(e);
    131135            res = Vector3D.DEFAULT_VECTOR_3D;
    132136        }
     
    150154     * @param p Point within current plane.
    151155     */
    152     public void setRotation(final Point p) {
     156    public synchronized void setRotation(final Point p) {
    153157        setRotation(getVector3D(p));
    154158    }
     
    181185     * @param vec vector pointing new view position.
    182186     */
    183     public void setRotation(Vector3D vec) {
     187    public synchronized void setRotation(Vector3D vec) {
    184188        setRotation(vec.getPolarAngle(), vec.getAzimuthalAngle());
    185189    }
  • trunk/src/org/openstreetmap/josm/io/OsmPbfReader.java

    r18826 r18877  
    1616import java.util.Set;
    1717
    18 import javax.annotation.Nonnull;
    19 import javax.annotation.Nullable;
     18import jakarta.annotation.Nonnull;
     19import jakarta.annotation.Nullable;
    2020
    2121import org.apache.commons.compress.utils.CountingInputStream;
  • trunk/src/org/openstreetmap/josm/io/auth/CredentialsAgent.java

    r18650 r18877  
    66import java.net.PasswordAuthentication;
    77
    8 import javax.annotation.Nullable;
    9 
    108import org.openstreetmap.josm.data.oauth.IOAuthToken;
    119import org.openstreetmap.josm.data.oauth.OAuthToken;
     10
     11import jakarta.annotation.Nullable;
    1212
    1313/**
Note: See TracChangeset for help on using the changeset viewer.