Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
call-workflow:
strategy:
matrix:
josm-revision: ["", "r18723"]
josm-revision: ["", "r18877"]
uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v1
with:
java-version: 17
josm-revision: ${{ matrix.josm-revision }}
plugin-jar-name: 'mapwithai'
perform-revision-tagging: ${{ github.repository == 'JOSM/MapWithAI' && github.ref_type == 'branch' && github.ref_name == 'master' && github.event_name != 'schedule' && github.event_name != 'pull_request' && matrix.josm-revision == 'r18723' }}
perform-revision-tagging: ${{ matrix.josm-revision == 'r18877' && github.repository == 'JOSM/MapWithAI' && github.ref_type == 'branch' && github.ref_name == 'master' && github.event_name != 'schedule' && github.event_name != 'pull_request' }}
secrets: inherit

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# The minimum JOSM version this plugin is compatible with (can be any numeric version
plugin.main.version = 18723
plugin.main.version = 18877
# The JOSM version this plugin is currently compiled against
# Please make sure this version is available at https://josm.openstreetmap.de/download
# The special values "latest" and "tested" are also possible here, but not recommended.
plugin.compile.version = 18724
plugin.compile.version = 18877
plugin.canloadatruntime = true
plugin.author = Taylor Smock
plugin.class = org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

import static org.openstreetmap.josm.tools.I18n.tr;

import javax.swing.JMenuItem;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.swing.JMenuItem;

import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.actions.PreferencesAction;
import org.openstreetmap.josm.data.validation.OsmValidator;
Expand All @@ -29,6 +29,7 @@
import org.openstreetmap.josm.plugins.PluginInformation;
import org.openstreetmap.josm.plugins.mapwithai.backend.DownloadListener;
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIAction;
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer;
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIMoveAction;
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIObject;
Expand Down Expand Up @@ -135,7 +136,8 @@ public MapWithAIPlugin(PluginInformation info) {
MainApplication.worker.execute(() -> UpdateProd.doProd(info.mainversion));
// Preload the MapWithAILayerInfo for the JOSM download window
// This reduces the amount of time taken for first button click by 100ms.
MainApplication.worker.execute(MapWithAILayerInfo::getInstance);
// Don't use the worker thread to avoid blocking user downloads
MapWithAIDataUtils.getForkJoinPool().execute(MapWithAILayerInfo::getInstance);

destroyables.add(new MapWithAICopyProhibit());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class DataAvailability {
static final Map<String, String> POSSIBLE_DATA_POINTS = new TreeMap<>();

private static final String PROVIDES = "provides";
private static final String EMPTY_STRING = "";
private static final int SEVEN_DAYS_IN_SECONDS = 604_800;

/**
Expand Down Expand Up @@ -150,7 +149,7 @@ private static void parseCountriesObject(Map<String, Map<String, Boolean>> count
* @return A string that doesn't have quotes at the beginning or end
*/
public static String stripQuotes(String string) {
return string.replaceAll("((^\")|(\"$))", EMPTY_STRING);
return string.replaceAll("((^\")|(\"$))", "");
}

/**
Expand Down Expand Up @@ -224,7 +223,7 @@ public String getUrl() {
* @return The url or ""
*/
public String getTermsOfUseUrl() {
return EMPTY_STRING;
return "";
}

/**
Expand All @@ -247,11 +246,10 @@ public static List<String> getTermsOfUse() {
DATA_SOURCES.stream().map(clazz -> {
try {
return clazz.getConstructor().newInstance().getTermsOfUseUrl();
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
} catch (ReflectiveOperationException e) {
Logging.debug(e);
}
return EMPTY_STRING;
return "";
})).filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty())
.collect(Collectors.toList());
}
Expand All @@ -267,11 +265,10 @@ public static List<String> getPrivacyPolicy() {
DATA_SOURCES.stream().map(clazz -> {
try {
return clazz.getConstructor().newInstance().getPrivacyPolicyUrl();
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
} catch (ReflectiveOperationException e) {
Logging.debug(e);
}
return EMPTY_STRING;
return "";
}))
.filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty()).distinct()
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ public DataSet compute() {
if (!monitor.isCanceled()) {
if (bounds.size() == MAX_NUMBER_OF_BBOXES_TO_PROCESS) {
final var temporaryDataSet = getDataReal(bounds.get(0), monitor);
synchronized (this.dataSet) {
dataSet.mergeFrom(temporaryDataSet);
}
this.dataSet.update(() -> dataSet.mergeFrom(temporaryDataSet));
} else {
final Collection<GetDataRunnable> tasks = bounds.stream()
.map(bound -> new GetDataRunnable(bound, dataSet, monitor.createSubTaskMonitor(0, true)))
Expand Down Expand Up @@ -250,10 +248,10 @@ public DataSet compute() {
* @param info The information used to download the data
*/
public static void cleanup(DataSet dataSet, Bounds bounds, MapWithAIInfo info) {
realCleanup(dataSet, bounds, info);
dataSet.update(() -> realCleanup(dataSet, bounds, info));
}

private static synchronized void realCleanup(DataSet dataSet, Bounds bounds, MapWithAIInfo info) {
private static void realCleanup(DataSet dataSet, Bounds bounds, MapWithAIInfo info) {
final Bounds boundsToUse;
if (bounds == null && !dataSet.getDataSourceBounds().isEmpty()) {
boundsToUse = new Bounds(dataSet.getDataSourceBounds().get(0));
Expand All @@ -277,7 +275,7 @@ private static synchronized void realCleanup(DataSet dataSet, Bounds bounds, Map
}
(boundsToUse.isCollapsed() || boundsToUse.isOutOfTheWorld() ? dataSet.getWays()
: dataSet.searchWays(boundsToUse.toBBox())).stream().filter(way -> !way.isDeleted())
.forEach(GetDataRunnable::cleanupArtifacts);
.forEach(GetDataRunnable::cleanupArtifacts);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,21 +320,21 @@ public static void createBadDataNotification() {
private record OsmComparator(
Collection<OsmPrimitive> previousSelection) implements Comparator<OsmPrimitive>, Serializable {

@Override
public int compare(OsmPrimitive o1, OsmPrimitive o2) {
if (previousSelection.contains(o1) == previousSelection.contains(o2)) {
if (o1.isTagged() == o2.isTagged()) {
return o1.compareTo(o2);
} else if (o1.isTagged()) {
return -1;
}
return 1;
}
if (previousSelection.contains(o1)) {
@Override
public int compare(OsmPrimitive o1, OsmPrimitive o2) {
if (previousSelection.contains(o1) == previousSelection.contains(o2)) {
if (o1.isTagged() == o2.isTagged()) {
return o1.compareTo(o2);
} else if (o1.isTagged()) {
return -1;
}
return 1;
}
if (previousSelection.contains(o1)) {
return -1;
}
return 1;
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@

import static org.openstreetmap.josm.tools.I18n.tr;

import javax.annotation.Nullable;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.openstreetmap.josm.command.Command;
Expand All @@ -17,6 +14,8 @@
import org.openstreetmap.josm.data.osm.Relation;
import org.openstreetmap.josm.data.osm.Way;

import jakarta.annotation.Nullable;

/**
* This is similar to the ReplaceGeometryUtils.buildUpgradeNodeCommand method
*
Expand Down Expand Up @@ -46,19 +45,19 @@ public static Command buildUpgradeNodeCommand(Node subjectNode, OsmPrimitive ref

private static Node getNewOrNoTagNode(OsmPrimitive referenceObject) {
List<Node> nodes;
if (referenceObject instanceof Way) {
nodes = ((Way) referenceObject).getNodes();
} else if (referenceObject instanceof Relation) {
nodes = ((Relation) referenceObject).getMemberPrimitives().stream().flatMap(o -> {
if (o instanceof Way) {
return ((Way) o).getNodes().stream();
} else if (o instanceof Node) {
return Stream.of((Node) o);
if (referenceObject instanceof Way way) {
nodes = way.getNodes();
} else if (referenceObject instanceof Relation relation) {
nodes = relation.getMemberPrimitives().stream().flatMap(o -> {
if (o instanceof Way way) {
return way.getNodes().stream();
} else if (o instanceof Node node) {
return Stream.of(node);
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toList());
} else if (referenceObject instanceof Node) {
nodes = Collections.singletonList((Node) referenceObject);
}).filter(Objects::nonNull).toList();
} else if (referenceObject instanceof Node node) {
nodes = Collections.singletonList(node);
} else {
throw new IllegalArgumentException(tr("Unknown OsmPrimitive type"));
}
Expand Down
Loading