blob: f991f87f26321e302175f8a7b9883e3b6bbe7f29 (
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
|
package tools.refinery.store.reasoning.literal;
import tools.refinery.store.query.literal.CallLiteral;
public final class PartialLiterals {
private PartialLiterals() {
throw new IllegalStateException("This is a static utility class and should not be instantiated directly");
}
public static CallLiteral may(CallLiteral literal) {
return addModality(literal, Modality.MAY);
}
public static CallLiteral must(CallLiteral literal) {
return addModality(literal, Modality.MUST);
}
public static CallLiteral current(CallLiteral literal) {
return addModality(literal, Modality.CURRENT);
}
public static CallLiteral addModality(CallLiteral literal, Modality modality) {
var target = literal.getTarget();
if (target instanceof ModalConstraint) {
throw new IllegalArgumentException("Literal %s already has modality".formatted(literal));
}
var polarity = literal.getPolarity();
var modalTarget = new ModalConstraint(modality.commute(polarity), target);
return new CallLiteral(polarity, modalTarget, literal.getArguments());
}
}
|