Skip to content

Commit d26ede8

Browse files
author
Mark
committed
prepare for jdk switch to 1.6
1 parent 3541043 commit d26ede8

File tree

62 files changed

+1777
-1184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1777
-1184
lines changed

src/main/java/com/arangodb/ArangoCollection.java

Lines changed: 194 additions & 163 deletions
Large diffs are not rendered by default.

src/main/java/com/arangodb/ArangoCursor.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.Collection;
2727
import java.util.Iterator;
2828
import java.util.List;
29-
import java.util.Optional;
3029
import java.util.Spliterators;
3130
import java.util.stream.Stream;
3231
import java.util.stream.StreamSupport;
@@ -49,18 +48,18 @@ public class ArangoCursor<T> implements Iterator<T>, Closeable {
4948
private final Class<T> type;
5049
private final ArangoCursorIterator<T> iterator;
5150
private final String id;
52-
private final Optional<Integer> count;
53-
private final Optional<Extras> extra;
51+
private final Integer count;
52+
private final Extras extra;
5453
private final boolean cached;
5554

5655
public ArangoCursor(final ArangoDatabase db, final Class<T> type, final CursorEntity result) {
5756
super();
5857
this.db = db;
5958
this.type = type;
60-
count = Optional.ofNullable(result.getCount());
61-
extra = Optional.ofNullable(result.getExtra());
59+
count = result.getCount();
60+
extra = result.getExtra();
6261
cached = result.getCached().booleanValue();
63-
iterator = new ArangoCursorIterator<>(this, result);
62+
iterator = new ArangoCursorIterator<T>(this, result);
6463
id = result.getId();
6564
}
6665

@@ -72,16 +71,16 @@ public Class<T> getType() {
7271
return type;
7372
}
7473

75-
public Optional<Integer> getCount() {
74+
public Integer getCount() {
7675
return count;
7776
}
7877

79-
public Optional<Stats> getStats() {
80-
return extra.map(e -> e.getStats());
78+
public Stats getStats() {
79+
return extra != null ? extra.getStats() : null;
8180
}
8281

83-
public Optional<Collection<Warning>> getWarnings() {
84-
return extra.map(e -> e.getWarnings());
82+
public Collection<Warning> getWarnings() {
83+
return extra != null ? extra.getWarnings() : null;
8584
}
8685

8786
public boolean isCached() {
@@ -115,8 +114,10 @@ public Stream<T> streamRemaining() {
115114
}
116115

117116
public List<T> asListRemaining() {
118-
final List<T> remaining = new ArrayList<>();
119-
forEachRemaining(remaining::add);
117+
final List<T> remaining = new ArrayList<T>();
118+
while (hasNext()) {
119+
remaining.add(next());
120+
}
120121
return remaining;
121122
}
122123

src/main/java/com/arangodb/ArangoCursorIterator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ public T next() {
6161
return cursor.getDb().deserialize(result.getResult().get(pos++), cursor.getType());
6262
}
6363

64+
@Override
65+
public void remove() {
66+
throw new UnsupportedOperationException();
67+
}
68+
6469
}

src/main/java/com/arangodb/ArangoDB.java

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.arangodb.entity.UserEntity;
3434
import com.arangodb.internal.ArangoDBConstants;
3535
import com.arangodb.internal.CollectionCache;
36+
import com.arangodb.internal.CollectionCache.DBAccess;
3637
import com.arangodb.internal.DocumentCache;
3738
import com.arangodb.internal.velocypack.VPackConfigure;
3839
import com.arangodb.internal.velocystream.Communication;
@@ -48,6 +49,7 @@
4849
import com.arangodb.velocypack.VPackParser;
4950
import com.arangodb.velocypack.VPackSerializer;
5051
import com.arangodb.velocypack.VPackSlice;
52+
import com.arangodb.velocypack.exception.VPackException;
5153
import com.arangodb.velocystream.Request;
5254
import com.arangodb.velocystream.RequestType;
5355
import com.arangodb.velocystream.Response;
@@ -191,8 +193,11 @@ public ArangoDB(final Communication.Builder commBuilder, final VPack vpack, fina
191193
super(commBuilder.build(vpack, collectionCache), vpack, vpackNull, vpackParser, new DocumentCache(),
192194
collectionCache);
193195
final Communication cacheCom = commBuilder.build(vpack, collectionCache);
194-
collectionCache.init(name -> {
195-
return new ArangoDatabase(cacheCom, vpackNull, vpack, vpackParser, documentCache, null, name);
196+
collectionCache.init(new DBAccess() {
197+
@Override
198+
public ArangoDatabase db(final String name) {
199+
return new ArangoDatabase(cacheCom, vpackNull, vpack, vpackParser, documentCache, null, name);
200+
}
196201
});
197202
}
198203

@@ -243,7 +248,12 @@ private Request createDatabaseRequest(final String name) {
243248
}
244249

245250
private ResponseDeserializer<Boolean> createDatabaseResponseDeserializer() {
246-
return response -> response.getBody().get().get(ArangoDBConstants.RESULT).getAsBoolean();
251+
return new ResponseDeserializer<Boolean>() {
252+
@Override
253+
public Boolean deserialize(final Response response) throws VPackException {
254+
return response.getBody().get(ArangoDBConstants.RESULT).getAsBoolean();
255+
}
256+
};
247257
}
248258

249259
/**
@@ -270,10 +280,13 @@ private Request getDatabasesRequest() {
270280
}
271281

272282
private ResponseDeserializer<Collection<String>> getDatabaseResponseDeserializer() {
273-
return response -> {
274-
final VPackSlice result = response.getBody().get().get(ArangoDBConstants.RESULT);
275-
return deserialize(result, new Type<Collection<String>>() {
276-
}.getType());
283+
return new ResponseDeserializer<Collection<String>>() {
284+
@Override
285+
public Collection<String> deserialize(final Response response) throws VPackException {
286+
final VPackSlice result = response.getBody().get(ArangoDBConstants.RESULT);
287+
return ArangoDB.this.deserialize(result, new Type<Collection<String>>() {
288+
}.getType());
289+
}
277290
};
278291
}
279292

@@ -495,10 +508,13 @@ private Request getUsersRequest() {
495508
}
496509

497510
private ResponseDeserializer<Collection<UserEntity>> getUsersResponseDeserializer() {
498-
return (response) -> {
499-
final VPackSlice result = response.getBody().get().get(ArangoDBConstants.RESULT);
500-
return deserialize(result, new Type<Collection<UserEntity>>() {
501-
}.getType());
511+
return new ResponseDeserializer<Collection<UserEntity>>() {
512+
@Override
513+
public Collection<UserEntity> deserialize(final Response response) throws VPackException {
514+
final VPackSlice result = response.getBody().get(ArangoDBConstants.RESULT);
515+
return ArangoDB.this.deserialize(result, new Type<Collection<UserEntity>>() {
516+
}.getType());
517+
}
502518
};
503519
}
504520

@@ -581,7 +597,12 @@ private Request replaceUserRequest(final String user, final UserUpdateOptions op
581597
}
582598

583599
public Response execute(final Request request) {
584-
return executeSync(request, response -> response);
600+
return executeSync(request, new ResponseDeserializer<Response>() {
601+
@Override
602+
public Response deserialize(final Response response) throws VPackException {
603+
return response;
604+
}
605+
});
585606
}
586607

587608
public CompletableFuture<Response> executeAsync(final Request request) {

0 commit comments

Comments
 (0)