Created
September 20, 2013 17:45
-
-
Save johngmyers/6641152 to your computer and use it in GitHub Desktop.
Config value class that parses a comma-separated set
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
public static final class StringSet extends ForwardingSet<String> | |
{ | |
private final Set<String> delegate; | |
private StringSet(Set<String> delegate) | |
{ | |
this.delegate = ImmutableSet.copyOf(delegate); | |
} | |
public static StringSet of(String... strings) | |
{ | |
return new StringSet(ImmutableSet.copyOf(strings)); | |
} | |
public static StringSet valueOf(String string) | |
{ | |
return of(string.split("\\s*,\\s*")); | |
} | |
@Override | |
protected Set<String> delegate() | |
{ | |
return delegate; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment