spring-projects / spring-projects/spring-ldap

Make NullDirContextProcessor a public class

Open
#2 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
375
Forks
501
Avg merge
6h 4m
Merged PRs (30d)
63

Description

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)
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating LdapTemplate and its private static nested NullDirContextProcessor class. Extract it into a normal public top-level class while preserving its DirContextProcessor behavior, then verify that callers can instantiate it for the conditional search pattern shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.