diff options
author | snowleo <schneeleo@gmail.com> | 2013-01-01 23:54:22 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2013-01-01 23:54:22 +0100 |
commit | 279e3f6f47a1a6465ba985f85de8579fa26b58cd (patch) | |
tree | 812e0b57bfec134f33da13bc910fef15c6f3487a | |
parent | bca953a96e83788c1135ed0b9f9b26c9ce524ba1 (diff) | |
download | Essentials-279e3f6f47a1a6465ba985f85de8579fa26b58cd.tar Essentials-279e3f6f47a1a6465ba985f85de8579fa26b58cd.tar.gz Essentials-279e3f6f47a1a6465ba985f85de8579fa26b58cd.tar.lz Essentials-279e3f6f47a1a6465ba985f85de8579fa26b58cd.tar.xz Essentials-279e3f6f47a1a6465ba985f85de8579fa26b58cd.zip |
Cleanup
-rw-r--r-- | Essentials/src/net/ess3/converter/EnumConverter.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Essentials/src/net/ess3/converter/EnumConverter.java b/Essentials/src/net/ess3/converter/EnumConverter.java index 309ff3b78..ab45bdfb6 100644 --- a/Essentials/src/net/ess3/converter/EnumConverter.java +++ b/Essentials/src/net/ess3/converter/EnumConverter.java @@ -14,7 +14,7 @@ public class EnumConverter<E extends Enum<E>> implements ArgumentsParser<E>, Ser private static final Pattern REPLACE = Pattern.compile("[_-]"); private final Map<String, E> enumMap = new HashMap<String, E>(); private final Map<E, String> serializedMap; - + private EnumConverter(final Class<E> enumClass) { serializedMap = new EnumMap<E, String>(enumClass); @@ -24,7 +24,7 @@ public class EnumConverter<E extends Enum<E>> implements ArgumentsParser<E>, Ser serializedMap.put(t, prettifyString(t.name())); } } - + public static <T extends Enum<T>> EnumConverter<T> getInstance(final Class<T> enumClass) { synchronized (converterMap) @@ -38,7 +38,7 @@ public class EnumConverter<E extends Enum<E>> implements ArgumentsParser<E>, Ser return converter; } } - + @Override public ParserResult<E> parse(final String... args) { @@ -51,18 +51,20 @@ public class EnumConverter<E extends Enum<E>> implements ArgumentsParser<E>, Ser } return new FirstEntryParserResult<E>(e, args); } - + @Override public String serialize(final E input) { return serializedMap.get(input); } - private String cleanString(final String input) { + private String cleanString(final String input) + { return REPLACE.matcher(input).replaceAll("").toLowerCase(Locale.ENGLISH); } - private String prettifyString(final String input) { - return input.replace("_", "-").toLowerCase(Locale.ENGLISH); + private String prettifyString(final String input) + { + return input.replace('_', '-').toLowerCase(Locale.ENGLISH); } } |