aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/actions/ActionLiterals.java
blob: 275e1e25650322f7ebc97ac89f1eea226d233586 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.store.dse.transition.actions;

import tools.refinery.store.query.term.NodeVariable;
import tools.refinery.store.representation.Symbol;

import java.util.List;
import java.util.Objects;

public final class ActionLiterals {
	private ActionLiterals() {
		throw new IllegalArgumentException("This is a static utility class and should not be instantiated directly");
	}

	public static <T> PutActionLiteral<T> put(Symbol<T> symbol, T value, NodeVariable... parameters) {
		return new PutActionLiteral<>(symbol, value, List.of(parameters));
	}

	public static PutActionLiteral<Boolean> add(Symbol<Boolean> symbol, NodeVariable... parameters) {
		if (!Objects.equals(symbol.defaultValue(), false)) {
			throw new IllegalArgumentException("Use put to add a value to symbols other than two-valued logic");
		}
		return put(symbol, true, parameters);
	}

	public static <T> PutActionLiteral<T> remove(Symbol<T> symbol, NodeVariable... parameters) {
		return put(symbol, symbol.defaultValue(), parameters);
	}
}