-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTopLevel.java
More file actions
89 lines (79 loc) · 2.64 KB
/
TopLevel.java
File metadata and controls
89 lines (79 loc) · 2.64 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<%page args="all_terms" />
package com.rethinkdb.gen.model;
import com.rethinkdb.model.Arguments;
import com.rethinkdb.model.MapObject;
import com.rethinkdb.gen.ast.Error;
import com.rethinkdb.gen.ast.*;
import com.rethinkdb.gen.exc.ReqlDriverError;
import com.rethinkdb.utils.Internals;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class TopLevel {
public ReqlExpr expr(Object value){
return Internals.toReqlExpr(value);
}
public ReqlExpr row(Object... values) {
throw new ReqlDriverError("r.row is not implemented in the Java driver."+
" Use lambda syntax instead");
}
public Object pathspec(Object... path) {
if (path.length < 2) {
throw new ReqlDriverError("r.pathspec(...) requires at least two parameters.");
}
Object result = path[path.length - 1];
for (int i = path.length - 2; i >= 0; i--) {
result = new MapObject<>().with(path[i], result);
}
return result;
}
public MapObject<Object, Object> hashMap(Object key, Object val){
return new MapObject<>().with(key, val);
}
public MapObject<Object, Object> hashMap() {
return new MapObject<>();
}
% for type in ["Object", "ReqlFunction0", "ReqlFunction1", "ReqlFunction2", "ReqlFunction3", "ReqlFunction4"]:
public List<Object> array(${type} val0, ${type}... vals) {
List<Object> res = new ArrayList<>();
res.add(val0);
Collections.addAll(res, vals);
return res;
}
% endfor
public List<Object> array(){
return new ArrayList<>();
}
%for term in all_terms.values():
%if "TopLevel" in term["include_in"]:
%for methodname in term['methodnames']:
%for sig in term['signatures']:
%if sig['first_arg'] not in ['Db', 'Table']:
public ${term['classname']} ${methodname}(${
', '.join('%s %s' % (arg['type'], arg['var'])
for arg in sig['args'])}) {
% if methodname == 'binary':
<% firstarg = sig['args'][0]['var'] %>
if (${firstarg} instanceof byte[]) {
return new ${term['classname']}((byte[]) ${firstarg});
}else{
%endif
Arguments args = new Arguments();
%for arg in sig['args']:
%if arg['type'] == 'Object...':
args.coerceAndAddAll(${arg['var']});
%else:
args.coerceAndAdd(${arg['var']});
%endif
%endfor
return new ${term['classname']}(args);
% if methodname == 'binary':
}
%endif
}
%endif
%endfor
%endfor
%endif
%endfor
}