remove lombok from api and attach sources

This commit is contained in:
Luck
2016-08-15 16:09:16 +02:00
Unverified
parent 9a3eeca411
commit ca9037461a
12 changed files with 236 additions and 46 deletions
@@ -22,8 +22,6 @@
package me.lucko.luckperms;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import me.lucko.luckperms.api.LuckPermsApi;
import java.util.Optional;
@@ -31,12 +29,9 @@ import java.util.Optional;
/**
* Static access to LuckPerms
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class LuckPerms {
private static LuckPermsApi api = null;
/**
* Gets an instance of {@link LuckPermsApi}
* @return an api instance
@@ -66,4 +61,8 @@ public final class LuckPerms {
api = null;
}
private LuckPerms() {
throw new UnsupportedOperationException("This class cannot be instantiated.");
}
}
@@ -22,25 +22,44 @@
package me.lucko.luckperms.api;
import lombok.*;
import java.util.UUID;
@Getter
@Builder
@ToString
@EqualsAndHashCode
@AllArgsConstructor
public final class LogEntry implements Comparable<LogEntry> {
public static LogEntryBuilder builder() {
return new LogEntryBuilder();
}
private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s";
@NonNull private final long timestamp;
@NonNull private final UUID actor;
@NonNull private final String actorName;
@NonNull private final char type;
private final long timestamp;
private final UUID actor;
private final String actorName;
private final char type;
private final UUID acted;
@NonNull private final String actedName;
@NonNull private final String action;
private final String actedName;
private final String action;
public LogEntry(long timestamp, UUID actor, String actorName, char type, UUID acted, String actedName, String action) {
if (actor == null) {
throw new NullPointerException("actor");
}
if (actorName == null) {
throw new NullPointerException("actorName");
}
if (actedName == null) {
throw new NullPointerException("actedName");
}
if (action == null) {
throw new NullPointerException("action");
}
this.timestamp = timestamp;
this.actor = actor;
this.actorName = actorName;
this.type = type;
this.acted = acted;
this.actedName = actedName;
this.action = action;
}
@Override
public int compareTo(LogEntry o) {
@@ -55,10 +74,146 @@ public final class LogEntry implements Comparable<LogEntry> {
public String getFormatted() {
return String.format(FORMAT,
getActorName(),
Character.toString(getType()),
getActedName(),
getAction()
actorName,
Character.toString(type),
actedName,
action
);
}
public long getTimestamp() {
return timestamp;
}
public UUID getActor() {
return actor;
}
public String getActorName() {
return actorName;
}
public char getType() {
return type;
}
public UUID getActed() {
return acted;
}
public String getActedName() {
return actedName;
}
public String getAction() {
return action;
}
@Override
public String toString() {
return "LogEntry(timestamp=" + this.getTimestamp() + ", actor=" + this.getActor() + ", actorName=" +
this.getActorName() + ", type=" + this.getType() + ", acted=" + this.getActed() + ", actedName=" +
this.getActedName() + ", action=" + this.getAction() + ")";
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof LogEntry)) return false;
final LogEntry other = (LogEntry) o;
if (this.getTimestamp() != other.getTimestamp()) return false;
final Object this$actor = this.getActor();
final Object other$actor = other.getActor();
if (this$actor == null ? other$actor != null : !this$actor.equals(other$actor)) return false;
final Object this$actorName = this.getActorName();
final Object other$actorName = other.getActorName();
if (this$actorName == null ? other$actorName != null : !this$actorName.equals(other$actorName)) return false;
if (this.getType() != other.getType()) return false;
final Object this$acted = this.getActed();
final Object other$acted = other.getActed();
if (this$acted == null ? other$acted != null : !this$acted.equals(other$acted)) return false;
final Object this$actedName = this.getActedName();
final Object other$actedName = other.getActedName();
if (this$actedName == null ? other$actedName != null : !this$actedName.equals(other$actedName)) return false;
final Object this$action = this.getAction();
final Object other$action = other.getAction();
return this$action == null ? other$action == null : this$action.equals(other$action);
}
@Override
public int hashCode() {
final int PRIME = 59;
int result = 1;
final long $timestamp = this.getTimestamp();
result = result * PRIME + (int) ($timestamp >>> 32 ^ $timestamp);
final Object $actor = this.getActor();
result = result * PRIME + ($actor == null ? 43 : $actor.hashCode());
final Object $actorName = this.getActorName();
result = result * PRIME + ($actorName == null ? 43 : $actorName.hashCode());
result = result * PRIME + this.getType();
final Object $acted = this.getActed();
result = result * PRIME + ($acted == null ? 43 : $acted.hashCode());
final Object $actedName = this.getActedName();
result = result * PRIME + ($actedName == null ? 43 : $actedName.hashCode());
final Object $action = this.getAction();
result = result * PRIME + ($action == null ? 43 : $action.hashCode());
return result;
}
public static class LogEntryBuilder {
private long timestamp;
private UUID actor;
private String actorName;
private char type;
private UUID acted;
private String actedName;
private String action;
public LogEntryBuilder timestamp(long timestamp) {
this.timestamp = timestamp;
return this;
}
public LogEntryBuilder actor(UUID actor) {
this.actor = actor;
return this;
}
public LogEntryBuilder actorName(String actorName) {
this.actorName = actorName;
return this;
}
public LogEntryBuilder type(char type) {
this.type = type;
return this;
}
public LogEntryBuilder acted(UUID acted) {
this.acted = acted;
return this;
}
public LogEntryBuilder actedName(String actedName) {
this.actedName = actedName;
return this;
}
public LogEntryBuilder action(String action) {
this.action = action;
return this;
}
public LogEntry build() {
return new LogEntry(timestamp, actor, actorName, type, acted, actedName, action);
}
@Override
public String toString() {
return "LogEntry.LogEntryBuilder(timestamp=" + this.timestamp + ", actor=" + this.actor + ", actorName=" +
this.actorName + ", type=" + this.type + ", acted=" + this.acted + ", actedName=" + this.actedName +
", action=" + this.action + ")";
}
}
}
@@ -22,8 +22,6 @@
package me.lucko.luckperms.api.data;
import lombok.NonNull;
import java.util.function.Consumer;
public interface Callback<T> {
@@ -34,11 +32,17 @@ public interface Callback<T> {
return t -> {};
}
static <T> Callback<T> of(@NonNull Runnable runnable) {
static <T> Callback<T> of(Runnable runnable) {
if (runnable == null) {
throw new NullPointerException("runnable");
}
return t -> runnable.run();
}
static <T> Callback<T> of(@NonNull Consumer<T> consumer) {
static <T> Callback<T> of(Consumer<T> consumer) {
if (consumer == null) {
throw new NullPointerException("consumer");
}
return consumer::accept;
}