APIv3/src/main/java/net/frozenorb/apiv3/models/Rank.java
2016-04-26 20:46:34 -04:00

43 lines
1.2 KiB
Java

package net.frozenorb.apiv3.models;
import lombok.Getter;
import net.frozenorb.apiv3.APIv3;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import java.util.List;
@Entity(value = "ranks", noClassnameStored = true)
public final class Rank {
@Getter @Id private String id;
@Getter private int weight;
@Getter private String displayName;
@Getter private String gameColor;
@Getter private String websiteColor;
@Getter private boolean staffRank;
public static Rank byId(String id) {
return APIv3.getDatastore().createQuery(Rank.class).field("id").equalIgnoreCase(id).get();
}
public static List<Rank> values() {
return APIv3.getDatastore().createQuery(Rank.class).asList();
}
public Rank() {} // For Morphia
public Rank(String id, int weight, String displayName, String gameColor, String websiteColor, boolean staffRank) {
this.id = id;
this.weight = weight;
this.displayName = displayName;
this.gameColor = gameColor;
this.websiteColor = websiteColor;
this.staffRank = staffRank;
}
public void delete() {
APIv3.getDatastore().delete(this);
}
}