rwinch / spring-security-jira-to-gh

0 stars 0 forks source link

LDAP-272: Make NullDirContextProcessor a public class #251

Closed rwinch closed 11 years ago

rwinch commented 11 years ago

Migrated from LDAP-272

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)
}
rwinch commented 11 years ago

Mattias Hellborg Arthursson said:

Made the class public. It's still nested though.