forked from Steven/DeepJ
I'm Bored so I made a Builder
This commit is contained in:
parent
9781caea90
commit
c0f3cb5e95
@ -28,6 +28,14 @@ public class Translator {
|
||||
request = new Request(globalAPIKey);
|
||||
}
|
||||
}
|
||||
public Translator(bool silent) {
|
||||
//GAK (SILENCABLE)
|
||||
if (globalAPIKey == null && !silent) {
|
||||
System.out.println("\n[DeepJ] You are currently using the Global API Key Translator Constructor." +"\n[DeepJ] If you are trying to use global API keys, Call the method \"Translator.setGlobalAuthKey(String key)\" and then re-use this contructor." + "\n[DeepJ] If you want to define an different authkey every time do: \"new Translator(String authKey)\"\n");
|
||||
} else {
|
||||
request = new Request(globalAPIKey);
|
||||
}
|
||||
}
|
||||
public Translator(String authKey) {
|
||||
//NORMAL REQUEST (GAK Notice) (NO SILENCE)
|
||||
if (!Objects.equals(globalAPIKey, "null")) {
|
||||
@ -124,6 +132,35 @@ public class Translator {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TranslatorBuilder {
|
||||
private boolean silent = false;
|
||||
private String authKey = null;
|
||||
private boolean GAK = false;
|
||||
|
||||
public Translator build() {
|
||||
if (GAK) {
|
||||
return new Translator(silent);
|
||||
} else {
|
||||
return new Translator(authKey, silent)
|
||||
}
|
||||
}
|
||||
|
||||
public TranslatorBuilder useGAK(boolean bool) {
|
||||
this.GAK = bool;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TranslatorBuilder setAuthKey(String authKey) {
|
||||
this.authKey = authKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TranslatorBuilder setSilent(boolean silent) {
|
||||
this.silent = silent;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
//DEEPL LANGUAGES
|
||||
public enum Language {
|
||||
Bulgarian("BG"),
|
||||
|
Loading…
Reference in New Issue
Block a user