blob: b4fa5b5d55e796ff17da94f656c5395a44dfd959 (
plain)
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
|
package shcm.shsupercm.fabric.citresewn.cit.builtin.conditions;
import shcm.shsupercm.fabric.citresewn.cit.CITCondition;
import shcm.shsupercm.fabric.citresewn.cit.CITContext;
import shcm.shsupercm.fabric.citresewn.cit.CITParsingException;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue;
/**
* Common condition type with no parsing for constant true/false testing output.
*/
public abstract class ConstantCondition extends CITCondition {
/**
* Constant condition that always tests positive.
*/
public static final ConstantCondition TRUE = new ConstantCondition(true) {
@Override
public boolean test(CITContext context) {
return true;
}
};
/**
* Constant condition that always tests negative.
*/
public static final ConstantCondition FALSE = new ConstantCondition(false) {
@Override
public boolean test(CITContext context) {
return false;
}
};
/**
* @return constant condition for the given boolean value
*/
public static ConstantCondition of(boolean value) {
return value ? TRUE : FALSE;
}
/**
* What testing contexts will always result in.
*/
public final boolean value;
private ConstantCondition(boolean value) {
this.value = value;
}
@Override
public void load(PropertyValue value, PropertyGroup properties) throws CITParsingException { }
}
|