Add LiteFullJson interface

This commit is contained in:
Colin McDonald 2016-02-07 20:54:27 -05:00
parent dccbca98bb
commit 58704fa890
12 changed files with 34 additions and 16 deletions

View File

@ -0,0 +1,12 @@
package net.frozenorb.apiv3;
import io.vertx.core.json.JsonObject;
public interface LiteFullJson {
JsonObject toLiteJson();
default JsonObject toFullJson() {
return toLiteJson();
}
}

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class AuditLog { public final class AuditLog implements LiteFullJson {
public static final String COLLECTION_NAME = "auditLog"; public static final String COLLECTION_NAME = "auditLog";

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class EmailTemplate { public final class EmailTemplate implements LiteFullJson {
public static final String COLLECTION_NAME = "emailTemplate"; public static final String COLLECTION_NAME = "emailTemplate";

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class Grant { public final class Grant implements LiteFullJson {
public static final String COLLECTION_NAME = "grant"; public static final String COLLECTION_NAME = "grant";

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class IPBan { public final class IPBan implements LiteFullJson {
public static final String COLLECTION_NAME = "ipBan"; public static final String COLLECTION_NAME = "ipBan";

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class IPLog { public final class IPLog implements LiteFullJson {
public static final String COLLECTION_NAME = "ipLog"; public static final String COLLECTION_NAME = "ipLog";

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class MaxMindCache { public final class MaxMindCache implements LiteFullJson {
public static final String COLLECTION_NAME = "maxMindCache"; public static final String COLLECTION_NAME = "maxMindCache";

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class NotificationLog { public final class NotificationLog implements LiteFullJson {
public static final String COLLECTION_NAME = "notificationLog"; public static final String COLLECTION_NAME = "notificationLog";

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class Punishment { public final class Punishment implements LiteFullJson {
public static final String COLLECTION_NAME = "punishment"; public static final String COLLECTION_NAME = "punishment";

View File

@ -7,13 +7,14 @@ import io.vertx.core.json.JsonObject;
import lombok.Getter; import lombok.Getter;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.APIv3; import net.frozenorb.apiv3.APIv3;
import net.frozenorb.apiv3.LiteFullJson;
import net.frozenorb.apiv3.utils.MongoUtils; import net.frozenorb.apiv3.utils.MongoUtils;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
@ToString(exclude={ "secret" }) @ToString(exclude={ "secret" })
public final class Server { public final class Server implements LiteFullJson {
public static final String COLLECTION_NAME = "server"; 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() { public JsonObject toLiteJson() {
JsonObject json = new JsonObject(); JsonObject json = new JsonObject();

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class ServerGroup { public final class ServerGroup implements LiteFullJson {
public static final String COLLECTION_NAME = "serverGroup"; public static final String COLLECTION_NAME = "serverGroup";

View File

@ -1,9 +1,10 @@
package net.frozenorb.apiv3.collections; package net.frozenorb.apiv3.collections;
import lombok.ToString; import lombok.ToString;
import net.frozenorb.apiv3.LiteFullJson;
@ToString @ToString
public final class User { public final class User implements LiteFullJson {
public static final String COLLECTION_NAME = "user"; public static final String COLLECTION_NAME = "user";