aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-query/src/main/java/tools/refinery/store/query/literal/BooleanLiteral.java
blob: fd2f1eec8d9bc5f983616c20406d5a4ee249762d (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
34
35
36
37
package tools.refinery.store.query.literal;

import tools.refinery.store.query.Variable;

import java.util.Map;
import java.util.Set;

public class BooleanLiteral implements Literal {
	public static final BooleanLiteral TRUE = new BooleanLiteral(LiteralReduction.ALWAYS_TRUE);
	public static final BooleanLiteral FALSE = new BooleanLiteral(LiteralReduction.ALWAYS_FALSE);

	private final LiteralReduction reduction;

	private BooleanLiteral(LiteralReduction reduction) {
		this.reduction = reduction;
	}

	@Override
	public void collectAllVariables(Set<Variable> variables) {
		// No variables to collect.
	}

	@Override
	public Literal substitute(Map<Variable, Variable> substitution) {
		// No variables to substitute.
		return this;
	}

	@Override
	public LiteralReduction getReduction() {
		return reduction;
	}

	public static BooleanLiteral fromBoolean(boolean value) {
		return value ? TRUE : FALSE;
	}
}