blob: c0f4a0cfb16dc10f56d9b8b0d69e0c84b39213b3 (
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
52
53
54
55
56
57
58
59
|
package com.modulus.qbar.lang;
import com.modulus.qbar.core.QBFunction;
import com.modulus.qbar.core.QBObject;
import com.modulus.qbar.core.QBStruct;
import com.modulus.qbar.core.exceptions.ExecutionException;
import com.modulus.qbar.integration.QBWrappedObject;
public class QBMaybe {
public static class Maybe extends QBObject{
public static final QBStruct struct = new QBStruct("Maybe");
static{
struct.set("getValue", new QBFunction(1){
@Override
public QBObject execute(QBObject[] args) {
Maybe ths = (Maybe)args[args.length-1];
return QBWrappedObject.wrap(ths.getValue());
}
});
struct.set("isNull", new QBFunction(1){
@Override
public QBObject execute(QBObject[] args) {
Maybe ths = (Maybe)args[args.length-1];
return QBWrappedObject.wrap(ths.isNull());
}
});
}
public Maybe(QBObject value) {
super(struct);
this.value = value;
}
private QBObject value;
public QBObject getValue(){
if(isNull()){
throw new ExecutionException("Attempted te get value of Null Type Maybe!");
}
return value;
}
public boolean isNull(){
return value == null;
}
}
public static QBObject new$0x20Maybe(QBObject obj){
return new Maybe(obj);
}
public static QBObject new$0x20Null(){
return new Maybe(null);
}
}
|