Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 28, 2018
1 parent 0470efa commit 207fc4d
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*
*/
class AddonModuleIdentifierCache
{
private final Map<Addon, ModuleIdentifier> map = new HashMap<Addon, ModuleIdentifier>();
private final Map<Addon, ModuleIdentifier> map = new HashMap<>();

public void clear(Addon addon)
{
Expand All @@ -36,9 +35,8 @@ public void dispose()

public ModuleIdentifier getModuleId(Addon addon)
{
if (!map.containsKey(addon))
map.put(addon, ModuleIdentifier.fromString(toModuleId(addon.getId()) + "_" + UUID.randomUUID().toString()));
return map.get(addon);
return map.computeIfAbsent(addon,
a -> ModuleIdentifier.fromString(toModuleId(a.getId()) + "_" + UUID.randomUUID().toString()));
}

private String toModuleId(AddonId id)
Expand Down

0 comments on commit 207fc4d

Please sign in to comment.