From 58704fa8902fb59b78e1a722fcc6df1135d4aa49 Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Sun, 7 Feb 2016 20:54:27 -0500 Subject: [PATCH] Add LiteFullJson interface --- src/main/java/net/frozenorb/apiv3/LiteFullJson.java | 12 ++++++++++++ .../net/frozenorb/apiv3/collections/AuditLog.java | 3 ++- .../frozenorb/apiv3/collections/EmailTemplate.java | 3 ++- .../java/net/frozenorb/apiv3/collections/Grant.java | 3 ++- .../java/net/frozenorb/apiv3/collections/IPBan.java | 3 ++- .../java/net/frozenorb/apiv3/collections/IPLog.java | 3 ++- .../frozenorb/apiv3/collections/MaxMindCache.java | 3 ++- .../frozenorb/apiv3/collections/NotificationLog.java | 3 ++- .../net/frozenorb/apiv3/collections/Punishment.java | 3 ++- .../java/net/frozenorb/apiv3/collections/Server.java | 8 ++------ .../net/frozenorb/apiv3/collections/ServerGroup.java | 3 ++- .../java/net/frozenorb/apiv3/collections/User.java | 3 ++- 12 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 src/main/java/net/frozenorb/apiv3/LiteFullJson.java diff --git a/src/main/java/net/frozenorb/apiv3/LiteFullJson.java b/src/main/java/net/frozenorb/apiv3/LiteFullJson.java new file mode 100644 index 0000000..9e5e923 --- /dev/null +++ b/src/main/java/net/frozenorb/apiv3/LiteFullJson.java @@ -0,0 +1,12 @@ +package net.frozenorb.apiv3; + +import io.vertx.core.json.JsonObject; + +public interface LiteFullJson { + + JsonObject toLiteJson(); + default JsonObject toFullJson() { + return toLiteJson(); + } + +} \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/collections/AuditLog.java b/src/main/java/net/frozenorb/apiv3/collections/AuditLog.java index 24ac36c..7ad21bd 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/AuditLog.java +++ b/src/main/java/net/frozenorb/apiv3/collections/AuditLog.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class AuditLog { +public final class AuditLog implements LiteFullJson { public static final String COLLECTION_NAME = "auditLog"; diff --git a/src/main/java/net/frozenorb/apiv3/collections/EmailTemplate.java b/src/main/java/net/frozenorb/apiv3/collections/EmailTemplate.java index 0acd3b7..cbae10f 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/EmailTemplate.java +++ b/src/main/java/net/frozenorb/apiv3/collections/EmailTemplate.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class EmailTemplate { +public final class EmailTemplate implements LiteFullJson { public static final String COLLECTION_NAME = "emailTemplate"; diff --git a/src/main/java/net/frozenorb/apiv3/collections/Grant.java b/src/main/java/net/frozenorb/apiv3/collections/Grant.java index ed54c37..9382ebd 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/Grant.java +++ b/src/main/java/net/frozenorb/apiv3/collections/Grant.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class Grant { +public final class Grant implements LiteFullJson { public static final String COLLECTION_NAME = "grant"; diff --git a/src/main/java/net/frozenorb/apiv3/collections/IPBan.java b/src/main/java/net/frozenorb/apiv3/collections/IPBan.java index 16bfc7f..e7e6d33 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/IPBan.java +++ b/src/main/java/net/frozenorb/apiv3/collections/IPBan.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class IPBan { +public final class IPBan implements LiteFullJson { public static final String COLLECTION_NAME = "ipBan"; diff --git a/src/main/java/net/frozenorb/apiv3/collections/IPLog.java b/src/main/java/net/frozenorb/apiv3/collections/IPLog.java index 369f7ee..c5ae051 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/IPLog.java +++ b/src/main/java/net/frozenorb/apiv3/collections/IPLog.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class IPLog { +public final class IPLog implements LiteFullJson { public static final String COLLECTION_NAME = "ipLog"; diff --git a/src/main/java/net/frozenorb/apiv3/collections/MaxMindCache.java b/src/main/java/net/frozenorb/apiv3/collections/MaxMindCache.java index ca9120f..8ae51ff 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/MaxMindCache.java +++ b/src/main/java/net/frozenorb/apiv3/collections/MaxMindCache.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class MaxMindCache { +public final class MaxMindCache implements LiteFullJson { public static final String COLLECTION_NAME = "maxMindCache"; diff --git a/src/main/java/net/frozenorb/apiv3/collections/NotificationLog.java b/src/main/java/net/frozenorb/apiv3/collections/NotificationLog.java index fca3c9d..238a78c 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/NotificationLog.java +++ b/src/main/java/net/frozenorb/apiv3/collections/NotificationLog.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class NotificationLog { +public final class NotificationLog implements LiteFullJson { public static final String COLLECTION_NAME = "notificationLog"; diff --git a/src/main/java/net/frozenorb/apiv3/collections/Punishment.java b/src/main/java/net/frozenorb/apiv3/collections/Punishment.java index eede662..11f9500 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/Punishment.java +++ b/src/main/java/net/frozenorb/apiv3/collections/Punishment.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class Punishment { +public final class Punishment implements LiteFullJson { public static final String COLLECTION_NAME = "punishment"; diff --git a/src/main/java/net/frozenorb/apiv3/collections/Server.java b/src/main/java/net/frozenorb/apiv3/collections/Server.java index 1a4bc96..57f85dc 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/Server.java +++ b/src/main/java/net/frozenorb/apiv3/collections/Server.java @@ -7,13 +7,14 @@ import io.vertx.core.json.JsonObject; import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.APIv3; +import net.frozenorb.apiv3.LiteFullJson; import net.frozenorb.apiv3.utils.MongoUtils; import java.time.Instant; import java.util.*; @ToString(exclude={ "secret" }) -public final class Server { +public final class Server implements LiteFullJson { public static final String COLLECTION_NAME = "server"; @@ -55,11 +56,6 @@ public final class Server { } } - public void update() { - this.lastUpdate = Instant.now(); - APIv3.getMongoClient().update(COLLECTION_NAME, new JsonObject().put("_id", id), MongoUtils.set(new JsonObject().put("lastUpdate", lastUpdate)), res -> {}); - } - public JsonObject toLiteJson() { JsonObject json = new JsonObject(); diff --git a/src/main/java/net/frozenorb/apiv3/collections/ServerGroup.java b/src/main/java/net/frozenorb/apiv3/collections/ServerGroup.java index 406f70e..fe6e035 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/ServerGroup.java +++ b/src/main/java/net/frozenorb/apiv3/collections/ServerGroup.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class ServerGroup { +public final class ServerGroup implements LiteFullJson { public static final String COLLECTION_NAME = "serverGroup"; diff --git a/src/main/java/net/frozenorb/apiv3/collections/User.java b/src/main/java/net/frozenorb/apiv3/collections/User.java index c95489b..d7f7e7c 100644 --- a/src/main/java/net/frozenorb/apiv3/collections/User.java +++ b/src/main/java/net/frozenorb/apiv3/collections/User.java @@ -1,9 +1,10 @@ package net.frozenorb.apiv3.collections; import lombok.ToString; +import net.frozenorb.apiv3.LiteFullJson; @ToString -public final class User { +public final class User implements LiteFullJson { public static final String COLLECTION_NAME = "user";