Skip to content

Commit

Permalink
Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
albertus82 committed May 1, 2015
1 parent 131ee46 commit 6709f4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/it/albertus/router/RouterLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void loadThresholds() {
continue;
}
final String thresholdKey = configuration.getProperty(THRESHOLD_PREFIX + '.' + thresholdName + '.' + THRESHOLD_SUFFIX_KEY);
final Type thresholdType = Type.findByName(configuration.getProperty(THRESHOLD_PREFIX + '.' + thresholdName + '.' + THRESHOLD_SUFFIX_TYPE));
final Type thresholdType = Type.getEnum(configuration.getProperty(THRESHOLD_PREFIX + '.' + thresholdName + '.' + THRESHOLD_SUFFIX_TYPE));
final String thresholdValue = configuration.getProperty(THRESHOLD_PREFIX + '.' + thresholdName + '.' + THRESHOLD_SUFFIX_VALUE);
if (thresholdKey == null || "".equals(thresholdKey) || thresholdValue == null || thresholdType == null) {
throw new IllegalArgumentException("Threshold misconfigured: \"" + thresholdName + "\".");
Expand Down
6 changes: 3 additions & 3 deletions src/it/albertus/router/Threshold.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public String toString() {
return description;
}

public static Type findByName(String name) {
if (name != null) {
public static Type getEnum(String abbreviation) {
if (abbreviation != null) {
for (Type type : Type.values()) {
if (type.name().equalsIgnoreCase(name.trim()) || type.abbreviations.contains(name.trim().toLowerCase())) {
if (type.name().equalsIgnoreCase(abbreviation.trim()) || type.abbreviations.contains(abbreviation.trim().toLowerCase())) {
return type;
}
}
Expand Down

0 comments on commit 6709f4e

Please sign in to comment.