Code example for MapMaker

0
 
  private final PermissionFactory delegate;
 
  @Inject 
  public InstanceCachingPermissionFactory(@Named("wildcard") final PermissionFactory delegate) {
    this.instances = new MapMaker().weakValues().makeMap();
    this.delegate = delegate;
  } 
 
  @Override 
  public Permission create(final String permission) {
    return getOrCreate(permission);
  } 
 
  // == 
 
  protected Permission getOrCreate(final String permission) {
    Permission result = instances.get(permission);
    if (result == null) { 
      Permission newPermission = delegateCreate(permission);
Contextual code suggestions in your IDE  Get Codota for Java