Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
Perform string computations once at enum instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB committed Apr 26, 2020
1 parent ae16983 commit 8474e08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ public enum MultipleAchievements implements Category {
private final String langDefault;
private final String configComment;
private final String subcategoryDBName;
private final String dbName;
private final String permName;
private final String langKey;

MultipleAchievements(String categoryName, String langDefault, String configComment, String subcategoryName) {
MultipleAchievements(String categoryName, String langDefault, String configComment, String subcategoryDBName) {
this.categoryName = categoryName;
this.langDefault = langDefault;
this.configComment = configComment;
subcategoryDBName = subcategoryName;
this.subcategoryDBName = subcategoryDBName;
this.dbName = name().toLowerCase();
this.permName = "achievement.count." + categoryName.toLowerCase();
this.langKey = "list-" + name().toLowerCase();
}

/**
Expand All @@ -58,23 +64,23 @@ public String toString() {
*/
@Override
public String toDBName() {
return name().toLowerCase();
return dbName;
}

/**
* {@inheritDoc}
*/
@Override
public String toPermName() {
return "achievement.count." + categoryName.toLowerCase();
return permName;
}

/**
* {@inheritDoc}
*/
@Override
public String toLangKey() {
return "list-" + name().toLowerCase();
return langKey;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ public enum NormalAchievements implements Category {
private final String langName;
private final String langDefault;
private final String configComment;
private final String dbName;
private final String permName;

NormalAchievements(String categoryName, String langName, String langDefault, String configComment) {
this.categoryName = categoryName;
this.langName = langName;
this.langDefault = langDefault;
this.configComment = configComment;
this.dbName = name().toLowerCase();
this.permName = "achievement.count." + categoryName.toLowerCase();
}

/**
Expand All @@ -92,15 +96,15 @@ public String toString() {
*/
@Override
public String toDBName() {
return name().toLowerCase();
return dbName;
}

/**
* {@inheritDoc}
*/
@Override
public String toPermName() {
return "achievement.count." + categoryName.toLowerCase();
return permName;
}

/**
Expand Down

0 comments on commit 8474e08

Please sign in to comment.