Skip to content

Commit

Permalink
Makes cache attempt unlabeled if labeled was not found
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Nov 27, 2024
1 parent f9f5b17 commit 142d44c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ public boolean contains(TypeTag tag, String label) {
@SuppressWarnings("unchecked")
@Override
public <T> Optional<Tuple<T>> provide(TypeTag tag, Attributes attributes) {
Key key = Key.of(tag, attributes.label);
if (cache.containsKey(key)) {
return Optional.of((Tuple<T>) cache.get(key));
Key first = Key.of(tag, attributes.label);
if (cache.containsKey(first)) {
return Optional.of((Tuple<T>) cache.get(first));
}
Key second = Key.of(tag, null);
if (cache.containsKey(second)) {
return Optional.of((Tuple<T>) cache.get(second));
}
return Optional.empty();
}
Expand Down

0 comments on commit 142d44c

Please sign in to comment.