directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <>
Subject [jira] [Commented] (DIRAPI-292) Add static Instances in SyntaxChecker classes to ease their use
Date Mon, 13 Mar 2017 21:56:41 GMT


Emmanuel Lecharny commented on DIRAPI-292:

Actually, I faced the same issue with tests using the {{TelephoneNumberSyntaxChecker}} that
allows users to add new regexp. Obviously, that breaks the way the static INSTANCE works,
leading to test failures.

The thing is that one can use either the constructor or the static instance, depending on
the requirement. Most of the time, it makes no sense to use the constructor (test are very
specific here), so using INSTANCE is the way to go. When you *know* that you are going to
change something in the instance (like setting a new regexp), then you should use the constructor

Now, it's a bit unpleasant situation, because it may leads to some potential breakage if the
user is not careful. OTOH, {{syntaxCheckers}} are not really supposed to be exposed. At this
point, I think your suggestion about making them immutable would be the right decision. We
might have mutable version of them too.

> Add static Instances in SyntaxChecker classes to ease their use
> ---------------------------------------------------------------
>                 Key: DIRAPI-292
>                 URL:
>             Project: Directory Client API
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Emmanuel Lecharny
>             Fix For: 1.0.0-RC3
> We don't have static instance of {{SyntaxChecker}}s. This is annoying, because we have
to dynamically instanciate them when we need to validate a value. Adding something like :
> {noformat}
> public class BooleanSyntaxChecker extends SyntaxChecker
> {
>     /** A logger for this class */
>     private static final Logger LOG = LoggerFactory.getLogger( BooleanSyntaxChecker.class
>     /**
>      * A public instance of this SyntaxChecker
>      */
>     public static final BooleanSyntaxChecker INSTANCE = new BooleanSyntaxChecker();
> ...
> {noformat}
> would help.

This message was sent by Atlassian JIRA

View raw message