Closed lance-purple-unboundid closed 3 years ago
I wonder if we could try a slightly different approach? Using an enum to configure the Parser might limit us if a future need to custom-configure it arises:
Maybe you could use something like a ParserConfig class, instead...
public final class ParserConfig
{
private final Set<Character> allowedCharacters = new HashSet<>();
public void setAdditionalAllowedCharacters(final Character... allowedCharacters)
{
Arrays.stream(allowedCharacters).filter(Objects::nonNull).forEach(this.allowedCharacters::add);
}
public void clearAdditionalAllowedCharacters()
{
allowedCharacters.clear();
}
public Set<Character> getAdditionalAllowedCharacters()
{
return allowedCharacters;
}
// It should be possible to use a regex Pattern to define the allowed characters instead
// of a Set<Character>, too
// Other methods can be added as needed in the future
}
... then assign if to a ThreadLocal in Parser...
private static final ThreadLocal<ParserConfig> threadLocalConfig =
ThreadLocal.withInitial(ParserConfig::new);
... and expose it to the API user with a public static ParserConfig getParserConfig()
method on the Parser class.
public static ParserConfig getConfiguration()
{
return Parser.threadLocalConfig.get();
}
Internally, the Parser class would call Parser.threadLocalConfig.get().getAdditionalAllowedCharacters()
to get the set of additional allowed characters, if any.
One other thing: Can you add a blurb about this change to CHANGELOG.md?
… names.
This is needed by the Ping Directory REST API, in order to support filtering and retrieval of SCIM resources by LDAP attribute names, which may include semicolon-delimited attribute options (see RFC2251 section 4.1.5 for details).
JIRA issue: DS-37117