Skip to content

Instantly share code, notes, and snippets.

@kingarchie
Created September 11, 2018 19:30
Show Gist options
  • Save kingarchie/18a84bf0e15531da256d9bd49638a22e to your computer and use it in GitHub Desktop.
Save kingarchie/18a84bf0e15531da256d9bd49638a22e to your computer and use it in GitHub Desktop.
A simple Profile builder.
package rip.storm.player;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class Profile {
private Map<UUID, Profile> profiles = new HashMap<>();
private String userName, address, server;
private Long playTime;
private int wins, losses, kills, deaths, score;
public static class Builder {
private final UUID uuid;
private String userName, address, server;
private long playTime;
private int wins, losses, kills, deaths, score;
public Builder(UUID uuid) {
this.uuid = uuid;
}
public Builder name(String userName) {
this.userName = userName;
return this;
}
public Builder address(String address) {
this.address = address;
return this;
}
public Builder server(String server) {
this.server = server;
return this;
}
public Builder playTime(Long playTime) {
this.playTime = playTime;
return this;
}
public Builder wins(int wins) {
this.wins = wins;
return this;
}
public Builder losses(int losses) {
this.losses = losses;
return this;
}
public Builder kills(int kills) {
this.kills = kills;
return this;
}
public Builder deaths(int deaths) {
this.deaths = deaths;
return this;
}
public Builder score(int score) {
this.score = score;
return this;
}
public Profile build() {
return new Profile(this);
}
}
private Profile(Builder builder) {
this.userName = builder.userName;
this.address = builder.address;
this.server = builder.server;
this.playTime = builder.playTime;
this.wins = builder.wins;
this.losses = builder.losses;
this.kills = builder.kills;
this.deaths = builder.deaths;
this.score = builder.score;
profiles.put(builder.uuid, this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment