20
20
21
21
package com .arangodb .internal ;
22
22
23
- import java .util .HashMap ;
24
23
import java .util .Map ;
25
- import java .util .Map .Entry ;
26
24
27
25
import com .arangodb .ArangoRoute ;
28
26
import com .arangodb .internal .ArangoExecutor .ResponseDeserializer ;
29
27
import com .arangodb .velocypack .exception .VPackException ;
30
- import com .arangodb .velocystream .Request ;
31
28
import com .arangodb .velocystream .RequestType ;
32
29
import com .arangodb .velocystream .Response ;
33
30
38
35
public class ArangoRouteImpl extends InternalArangoRoute <ArangoDBImpl , ArangoDatabaseImpl , ArangoExecutorSync >
39
36
implements ArangoRoute {
40
37
41
- private final Map <String , String > queryParam ;
42
- private final Map <String , String > headerParam ;
43
- private Object body ;
44
-
45
38
protected ArangoRouteImpl (final ArangoDatabaseImpl db , final String path , final Map <String , String > headerParam ) {
46
- super (db , path );
47
- queryParam = new HashMap <String , String >();
48
- this .headerParam = new HashMap <String , String >();
49
- this .headerParam .putAll (headerParam );
39
+ super (db , path , headerParam );
50
40
}
51
41
52
42
@ Override
@@ -56,38 +46,24 @@ public ArangoRoute route(final String... path) {
56
46
57
47
@ Override
58
48
public ArangoRoute withHeader (final String key , final Object value ) {
59
- if (value != null ) {
60
- headerParam .put (key , value .toString ());
61
- }
49
+ _withHeader (key , value );
62
50
return this ;
63
51
}
64
52
65
53
@ Override
66
54
public ArangoRoute withQueryParam (final String key , final Object value ) {
67
- if (value != null ) {
68
- queryParam .put (key , value .toString ());
69
- }
55
+ _withQueryParam (key , value );
70
56
return this ;
71
57
}
72
58
73
59
@ Override
74
60
public ArangoRoute withBody (final Object body ) {
75
- this . body = body ;
61
+ _withBody ( body ) ;
76
62
return this ;
77
63
}
78
64
79
65
private Response request (final RequestType requestType ) {
80
- final Request request = request (db .name (), requestType , path );
81
- for (final Entry <String , String > param : headerParam .entrySet ()) {
82
- request .putHeaderParam (param .getKey (), param .getValue ());
83
- }
84
- for (final Entry <String , String > param : queryParam .entrySet ()) {
85
- request .putQueryParam (param .getKey (), param .getValue ());
86
- }
87
- if (body != null ) {
88
- request .setBody (util ().serialize (body ));
89
- }
90
- return executor .execute (request , new ResponseDeserializer <Response >() {
66
+ return executor .execute (createRequest (requestType ), new ResponseDeserializer <Response >() {
91
67
@ Override
92
68
public Response deserialize (final Response response ) throws VPackException {
93
69
return response ;
0 commit comments