Skip to content

Commit 834a1a5

Browse files
committed
drop Java 8 code, fix Javadoc
1 parent 2942f30 commit 834a1a5

File tree

5 files changed

+13
-48
lines changed

5 files changed

+13
-48
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
/out/
88
/checkstyle-josm-wikipedia.xml
99
/findbugs-josm-wikipedia.xml
10+
/dependency-reduced-pom.xml
11+
/target/
12+
/test/config/

src/main/java/org/wikipedia/data/WikipediaEntry.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.openstreetmap.josm.tools.AlphanumComparator;
1212
import org.openstreetmap.josm.tools.Utils;
1313
import org.wikipedia.WikipediaApp;
14-
import org.wikipedia.tools.FunctionalUtil;
1514

1615
public class WikipediaEntry implements Comparable<WikipediaEntry> {
1716

@@ -34,11 +33,10 @@ public WikipediaEntry(String lang, String article, LatLon coordinate) {
3433
}
3534

3635
public static Optional<WikipediaEntry> fromUrl(final String value) {
37-
return FunctionalUtil.or(
38-
Optional.ofNullable(value)
36+
return Optional.ofNullable(value)
3937
.map(WIKIPEDIA_FULL_URL_PATTERN::matcher)
4038
.filter(Matcher::matches)
41-
.map(it -> new WikipediaEntry(it.group(3), Utils.decodeUrl(it.group(5)).replace('_', ' '))),
39+
.map(it -> new WikipediaEntry(it.group(3), Utils.decodeUrl(it.group(5)).replace('_', ' '))).or(
4240
() -> Optional.ofNullable(value)
4341
.map(WIKIPEDIA_ALTERNATIVE_URL_PATTERN::matcher)
4442
.filter(Matcher::matches)

src/main/java/org/wikipedia/tools/FunctionalUtil.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/main/java/org/wikipedia/tools/RegexUtil.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ private RegexUtil() {
1515
}
1616

1717
/**
18-
* Note: For values > {@link Integer#MAX_VALUE}, the Mediawiki API will return with an error instead of reporting an entity as missing.
18+
* Check if value is a valid property Id
19+
* Note: For values &gt; {@link Integer#MAX_VALUE}, the Mediawiki API will return with an error instead of reporting an entity as missing.
20+
* @param value id to check
21+
* @return {@code true} or {@code false}
1922
*/
2023
public static boolean isValidPropertyId(final String value) {
2124
return isValidId(PROPERTY_ID_PATTERN, value);

src/main/java/org/wikipedia/validator/WikipediaValueFormat.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.wikipedia.api.wikidata_action.WikidataActionApiQuery;
2727
import org.wikipedia.api.wikidata_action.json.SitematrixResult;
2828
import org.wikipedia.data.WikipediaEntry;
29-
import org.wikipedia.tools.FunctionalUtil;
3029
import org.wikipedia.tools.OsmTagConstants;
3130

3231
public class WikipediaValueFormat extends Test.TagTest {
@@ -59,15 +58,13 @@ public WikipediaValueFormat() {
5958
@Override
6059
public void check(OsmPrimitive p) {
6160
Optional.of(OsmTagConstants.Key.WIKIPEDIA).flatMap(k -> Optional.ofNullable(p.get(k)).map(v -> new Tag(k, v))).flatMap(tag ->
62-
FunctionalUtil.or(
63-
getFullUrlCheckError(p, tag.getKey(), tag.getValue()),
61+
getFullUrlCheckError(p, tag.getKey(), tag.getValue()).or(
6462
() -> getLanguageArticleFormatError(p, tag.getKey(), tag.getValue())
6563
)
6664
// checkUrlDecode() is tested by core
6765
).ifPresent(it -> errors.add(it.build()));
6866
p.keySet().stream().filter(Objects::nonNull).filter(it -> it.endsWith(":wikipedia")).collect(Collectors.toMap(it -> it, p::get)).forEach((key, value) -> {
69-
FunctionalUtil.or(
70-
getFullUrlCheckError(p, key, value),
67+
getFullUrlCheckError(p, key, value).or(
7168
() -> getLanguageArticleFormatError(p, key, value)
7269
).ifPresent(it -> errors.add(it.build()));
7370
checkUrlDecode(p, key, value);
@@ -130,8 +127,7 @@ private Optional<TestError.Builder> getFullUrlCheckError(final OsmPrimitive p, f
130127
}
131128

132129
private Optional<TestError.Builder> getFullUrlCheckError(final OsmPrimitive p, final String key, final String value, final String message, final Function<WikipediaEntry, Optional<Tag>> newTagGetter) {
133-
return FunctionalUtil.or(
134-
WikipediaEntry.fromUrl(value).map(newTagGetter).flatMap(newTag ->
130+
return WikipediaEntry.fromUrl(value).map(newTagGetter).flatMap(newTag ->
135131
Optional.of(
136132
AllValidationTests.WIKIPEDIA_TAG_VALUE_IS_FULL_URL.getBuilder(this)
137133
.primitives(p)
@@ -144,7 +140,7 @@ private Optional<TestError.Builder> getFullUrlCheckError(final OsmPrimitive p, f
144140
newTag.map(it -> it.getKey() + "=" + it.getValue()).orElse(I18n.tr("a new value (manual intervention needed due to language conflict)"))
145141
)
146142
)
147-
),
143+
).or(
148144
() -> Optional.ofNullable(
149145
CONTAINS_URL_PATTERN.matcher(value).matches()
150146
? AllValidationTests.WIKIPEDIA_TAG_VALUE_CONTAINS_URL.getBuilder(this)

0 commit comments

Comments
 (0)