com.vaadin.ui.DeclarativeValueProvider Maven / Gradle / Ivy
/*
* Copyright (C) 2000-2024 Vaadin Ltd
*
* This program is available under Vaadin Commercial License and Service Terms.
*
* See for the full
* license.
*/
package com.vaadin.ui;
import java.util.IdentityHashMap;
import java.util.Map;
import com.vaadin.data.ValueProvider;
/**
* Value provider class for declarative support.
*
* Provides a straightforward mapping between an item and its value.
*
* @param
* item type
*/
class DeclarativeValueProvider implements ValueProvider {
private final Map values = new IdentityHashMap<>();
@Override
public String apply(T t) {
return values.get(t);
}
/**
* Sets a {@code value} for the item {@code t}.
*
* @param t
* a data item
* @param value
* a value for the item {@code t}
*/
void addValue(T t, String value) {
values.put(t, value);
}
}