Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleThreadsafe getName() implementation
 public String getName (String key) {
        String name = (String) this.names.get(key);
        
        if (name == null) {
            // cached name not found, get name from underlying DAO.
            name = primGetName(key);
            // cache the name
            this.names.put(key, name);
        }
        return  name;
    }

Exceptions

While the IEntityNameFinder interface entitles us to throw Exception, we don't actually need to throw any checked Exceptions. So the local methods here are not declared to throw exceptions. Anyone accessing us as a PersonDirNameFinder, rather than as an IEntityNameFinder won't have to deal with these exceptions.

Refactored factory

And here's a refactored version of the factory:

...