blob: 0e46a795f573ce68315b01e02eca1f37137ba868 (
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
|
/*
* 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.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());
}
}
|