Created
September 11, 2018 19:30
-
-
Save kingarchie/18a84bf0e15531da256d9bd49638a22e to your computer and use it in GitHub Desktop.
A simple Profile builder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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