diff options
Diffstat (limited to 'server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java b/server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java index 984ac4cf47..926de395b3 100644 --- a/server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java +++ b/server/src/main/java/com/vaadin/ui/DeclarativeIconGenerator.java @@ -30,16 +30,22 @@ import com.vaadin.server.Resource; */ class DeclarativeIconGenerator<T> implements IconGenerator<T> { + private IconGenerator<T> fallback; private Map<T, Resource> captions = new HashMap<>(); + public DeclarativeIconGenerator(IconGenerator<T> fallback) { + this.fallback = fallback; + } + @Override public Resource apply(T item) { - return captions.get(item); + return captions.containsKey(item) ? captions.get(item) + : fallback.apply(item); } /** * Sets an {@code icon} for the {@code item}. - * + * * @param item * a data item * @param icon |