package net.frozenorb.apiv3.collections; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import lombok.Getter; import lombok.ToString; import net.frozenorb.apiv3.LiteFullJson; import net.frozenorb.apiv3.utils.MongoUtils; import java.util.List; @ToString public final class Grant implements LiteFullJson { public static final String COLLECTION_NAME = "grant"; @Getter private String id; public static void findAll(Handler>> callback) { MongoUtils.findManyAndTransform(COLLECTION_NAME, new JsonObject(), Grant::new, callback); } public static void findById(String id, Handler> callback) { MongoUtils.findOneAndTransform(COLLECTION_NAME, new JsonObject().put("_id", id), Grant::new, callback); } private Grant(JsonObject json) { this.id = json.getString("_id"); } public JsonObject toLiteJson() { JsonObject json = new JsonObject(); json.put("_id", id); return json; } public JsonObject toFullJson() { JsonObject json = toLiteJson(); return json; } }