blob: 261ceaa58c05edc076effa8a8ef47aa35af4d890 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.store.query.valuation;
import tools.refinery.store.query.term.AnyDataVariable;
import tools.refinery.store.query.term.DataVariable;
import java.util.Map;
record MapBasedValuation(Map<AnyDataVariable, Object> values) implements Valuation {
@Override
public <T> T getValue(DataVariable<T> variable) {
if (!values.containsKey(variable)) {
throw new IllegalArgumentException("No value for variable %s".formatted(variable));
}
var value = values.get(variable);
return variable.getType().cast(value);
}
}
|