spring-ldap icon indicating copy to clipboard operation
spring-ldap copied to clipboard

Make NullDirContextProcessor a public class

Open Derbeth opened this issue 12 years ago • 1 comments
trafficstars

Currently NullDirContextProcessor is a private static nested class of LdapTemplate. I would like to see it as a normal top-level public class.

The reason is that sometimes rather then writing

public List mySearch(String filter, boolean fancySearch) {
    if (fancySearch) {
        return this.ldapTemplate.search(this.defaultSearchBase, filter,
            SearchControls.SUBTREE_SCOPE, this.mapper, new FancyControlsDirContextProcessor())
    } else {
        return this.ldapTemplate.search(this.defaultSearchBase, filter, this.mapper);
    }
}

it would be more readable and maintainable (less copy-and-paste) to write

public List mySearch(String filter, boolean fancySearch) {
    DirContextProcessor dirContextProcessor = fancySearch ?
        new FancyControlsDirContextProcessor() : new NullDirContextProcessor();
    return this.ldapTemplate.search(this.defaultSearchBase, filter,
        SearchControls.SUBTREE_SCOPE, this.mapper, dirContextProcessor)
}

Derbeth avatar Oct 09 '13 09:10 Derbeth