aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/ModalConstraint.java
blob: 7fa98104228cd0fc81820583503e2e4ef2928c4b (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.store.reasoning.literal;

import tools.refinery.store.query.Constraint;
import tools.refinery.store.query.equality.LiteralEqualityHelper;
import tools.refinery.store.query.literal.LiteralReduction;
import tools.refinery.store.query.term.Sort;

import java.util.List;

public record ModalConstraint(Modality modality, Constraint constraint) implements Constraint {
	private static final String FORMAT = "%s %s";

	@Override
	public String name() {
		return FORMAT.formatted(modality, constraint.name());
	}

	@Override
	public List<Sort> getSorts() {
		return constraint.getSorts();
	}

	@Override
	public LiteralReduction getReduction() {
		return constraint.getReduction();
	}

	@Override
	public boolean equals(LiteralEqualityHelper helper, Constraint other) {
		if (getClass() != other.getClass()) {
			return false;
		}
		var otherModalConstraint = (ModalConstraint) other;
		return modality == otherModalConstraint.modality && constraint.equals(helper, otherModalConstraint.constraint);
	}

	@Override
	public String toReferenceString() {
		return FORMAT.formatted(modality, constraint.toReferenceString());
	}

	@Override
	public String toString() {
		return FORMAT.formatted(modality, constraint);
	}
}