summaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/trygvis/rules/network/Ipv4Cidr.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java b/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java
index 34b3a0b..6e1dde9 100644
--- a/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java
+++ b/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java
@@ -1,10 +1,17 @@
package io.trygvis.rules.network;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
+@JsonSerialize(using = Ipv4Cidr.Serializer.class)
public class Ipv4Cidr {
public final int network;
public final int netmask;
@@ -37,4 +44,13 @@ public class Ipv4Cidr {
return addresses;
}
+
+ public static class Serializer extends JsonSerializer<Ipv4Cidr> {
+ @Override
+ public void serialize(Ipv4Cidr value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeStartObject();
+ gen.writeObjectField("value", value.toString());
+ gen.writeEndObject();
+ }
+ }
}