aboutsummaryrefslogtreecommitdiff
path: root/jgvariant-tool
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2023-12-07 19:34:42 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2023-12-07 19:35:20 +0100
commit2b24f6c1ce9ecbf05c647473ea7fe3f94cfaf892 (patch)
tree903617751cafbb2ab1de80d02921675164ac277f /jgvariant-tool
parentd1c75b207d9656a6d03b75dea3c17cf78dbc483d (diff)
jgvariant-tool: Remove Guava dependency.
This reduces the uberjar size from 4 MB to 1.2 MB. Change-Id: I06e202fe3c5e942511952f43b8f2c5941027cce9
Diffstat (limited to 'jgvariant-tool')
-rw-r--r--jgvariant-tool/pom.xml6
-rw-r--r--jgvariant-tool/src/main/java/eu/mulk/jgvariant/tool/jsonb/VariantSerializer.java13
-rw-r--r--jgvariant-tool/src/main/java/module-info.java1
3 files changed, 11 insertions, 9 deletions
diff --git a/jgvariant-tool/pom.xml b/jgvariant-tool/pom.xml
index 6e01ade..60db3f3 100644
--- a/jgvariant-tool/pom.xml
+++ b/jgvariant-tool/pom.xml
@@ -73,12 +73,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
</dependency>
-
- <!-- Guava -->
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
</dependencies>
<build>
diff --git a/jgvariant-tool/src/main/java/eu/mulk/jgvariant/tool/jsonb/VariantSerializer.java b/jgvariant-tool/src/main/java/eu/mulk/jgvariant/tool/jsonb/VariantSerializer.java
index 99ff553..311033c 100644
--- a/jgvariant-tool/src/main/java/eu/mulk/jgvariant/tool/jsonb/VariantSerializer.java
+++ b/jgvariant-tool/src/main/java/eu/mulk/jgvariant/tool/jsonb/VariantSerializer.java
@@ -4,13 +4,13 @@
package eu.mulk.jgvariant.tool.jsonb;
-import com.google.common.primitives.Bytes;
import eu.mulk.jgvariant.core.Signature;
import eu.mulk.jgvariant.core.Variant;
import jakarta.json.bind.serializer.JsonbSerializer;
import jakarta.json.bind.serializer.SerializationContext;
import jakarta.json.stream.JsonGenerator;
import java.text.ParseException;
+import java.util.Collection;
import java.util.List;
@SuppressWarnings("java:S6548")
@@ -35,9 +35,18 @@ public final class VariantSerializer implements JsonbSerializer<Variant> {
@SuppressWarnings("unchecked")
public void serialize(Variant obj, JsonGenerator generator, SerializationContext ctx) {
if (obj.signature().equals(byteArraySignature)) {
- byteArraySerializer.serialize(Bytes.toArray((List<Byte>) obj.value()), generator, ctx);
+ byteArraySerializer.serialize(byteArrayOf((List<Byte>) obj.value()), generator, ctx);
} else {
ctx.serialize(obj.value(), generator);
}
}
+
+ private static byte[] byteArrayOf(Collection<Byte> bytes) {
+ byte[] result = new byte[bytes.size()];
+ int i = 0;
+ for (byte b : bytes) {
+ result[i++] = b;
+ }
+ return result;
+ }
}
diff --git a/jgvariant-tool/src/main/java/module-info.java b/jgvariant-tool/src/main/java/module-info.java
index e66981c..add77c0 100644
--- a/jgvariant-tool/src/main/java/module-info.java
+++ b/jgvariant-tool/src/main/java/module-info.java
@@ -4,7 +4,6 @@
module eu.mulk.jgvariant.tool {
requires transitive eu.mulk.jgvariant.ostree;
- requires com.google.common;
requires info.picocli;
requires jakarta.json;
requires jakarta.json.bind;