Get rid of Guava
This commit is contained in:
parent
bbb50e6e5e
commit
8d1800b95b
@ -84,11 +84,6 @@ android {
|
||||
}
|
||||
}
|
||||
}
|
||||
configurations.all {
|
||||
//Fixes Error: Duplicate class: com.google.common.util.concurrent.ListenableFuture
|
||||
exclude(group = "com.google.guava", module = "listenablefuture")
|
||||
exclude(group = "org.apache.httpcomponents", module = "httpclient")
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
[versions]
|
||||
mustache = "0.9.7"
|
||||
guava = "33.1.0-android"
|
||||
jacksonCore = "2.12.7"
|
||||
jacksonDataformatYaml = "2.12.7"
|
||||
minSdk = "26"
|
||||
@ -49,7 +48,6 @@ osmOpeningHours = "0.1.0"
|
||||
mustache-compiler = { module = "com.github.spullara.mustache.java:compiler", version.ref = "mustache" }
|
||||
gradle = { group = "com.android.tools.build", name = "gradle", version.ref = "android-gradle-plugin" }
|
||||
|
||||
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
||||
jackson-core = { module = "com.fasterxml.jackson.core:jackson-core", version.ref = "jacksonCore" }
|
||||
jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jacksonDataformatYaml" }
|
||||
kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
|
||||
|
||||
@ -35,8 +35,8 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.bundles.kotlin)
|
||||
implementation(libs.jackson.core)
|
||||
implementation(libs.jackson.dataformat.yaml)
|
||||
implementation(libs.guava)
|
||||
implementation(libs.mustache.compiler)
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package org.woheller69.AndroidAddressFormatter
|
||||
|
||||
/**
|
||||
* Make Kotlin functions accessible from Java.
|
||||
*/
|
||||
internal object Kt {
|
||||
@JvmStatic
|
||||
inline fun toIntOrNull(string: String): Int? {
|
||||
return string.toIntOrNull()
|
||||
}
|
||||
}
|
||||
@ -8,7 +8,6 @@ import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import com.fasterxml.jackson.databind.type.MapType;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.github.mustachejava.*;
|
||||
import com.google.common.primitives.Ints;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.StringReader;
|
||||
@ -21,7 +20,6 @@ import java.util.HashMap;
|
||||
import java.util.Spliterator;
|
||||
import java.util.Spliterators;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
@ -100,7 +98,7 @@ public class OsmAddressFormatter {
|
||||
for (Map.Entry<String, Object> entry : components.entrySet()) {
|
||||
String field = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
String newField = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, field);
|
||||
String newField = lowerCamelToUnderscore(field);
|
||||
if (!normalizedComponents.containsKey(newField)) {
|
||||
normalizedComponents.put(newField, value);
|
||||
}
|
||||
@ -108,6 +106,13 @@ public class OsmAddressFormatter {
|
||||
return normalizedComponents;
|
||||
}
|
||||
|
||||
private String lowerCamelToUnderscore(String input) {
|
||||
Pattern pattern = Pattern.compile("([a-z])([A-Z])");
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
String result = matcher.replaceAll("$1_$2");
|
||||
return result.toLowerCase();
|
||||
}
|
||||
|
||||
Map<String, Object> determineCountryCode(Map<String, Object> components,
|
||||
String fallbackCountryCode) {
|
||||
String countryCode;
|
||||
@ -194,7 +199,7 @@ public class OsmAddressFormatter {
|
||||
Object country = components.get("country");
|
||||
Object state = components.get("state");
|
||||
|
||||
if (country != null && state != null && Ints.tryParse((String) country) != null) {
|
||||
if (country != null && state != null && Kt.toIntOrNull((String) country) != null) {
|
||||
components.put("country", state);
|
||||
components.remove("state");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user