Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 14fbe42

Browse files
authored
[DE-595] Cloneable AqlQueryOptions (#509)
* updated docker images * made AqlQueryOptions cloneable
1 parent 685bcc8 commit 14fbe42

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed

‎.github/workflows/maven.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ jobs:
3535
user-language:
3636
- en
3737
include:
38-
- docker-img: docker.io/arangodb/arangodb:3.10.5
38+
- docker-img: docker.io/arangodb/arangodb-preview:3.11.0-beta.1
3939
topology: single
4040
db-ext-names: true
4141
java-version: 11
4242
user-language: tr
43-
- docker-img: docker.io/arangodb/enterprise:3.10.5
43+
- docker-img: docker.io/arangodb/enterprise-preview:3.11.0-beta.1
4444
topology: cluster
4545
db-ext-names: true
4646
java-version: 17

‎src/main/java/com/arangodb/model/AqlQueryOptions.java‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @see <a href="https://www.arangodb.com/docs/stable/http/aql-query-cursor-accessing-cursors.html#create-cursor">API
3535
* Documentation</a>
3636
*/
37-
public class AqlQueryOptions implements Serializable {
37+
public class AqlQueryOptions implements Serializable, Cloneable {
3838

3939
private static final long serialVersionUID = 1L;
4040

@@ -432,7 +432,18 @@ private Options getOptions() {
432432
return options;
433433
}
434434

435-
public static class Options implements Serializable {
435+
@Override
436+
public AqlQueryOptions clone() {
437+
try {
438+
AqlQueryOptions clone = (AqlQueryOptions) super.clone();
439+
clone.options = options != null ? options.clone() : null;
440+
return clone;
441+
} catch (CloneNotSupportedException e) {
442+
throw new AssertionError();
443+
}
444+
}
445+
446+
public static class Options implements Serializable, Cloneable {
436447

437448
private static final long serialVersionUID = 1L;
438449

@@ -467,10 +478,32 @@ protected Collection<String> getShardIds() {
467478
return shardIds;
468479
}
469480

481+
@Override
482+
public Options clone() {
483+
try {
484+
Options clone = (Options) super.clone();
485+
clone.optimizer = optimizer != null ? optimizer.clone() : null;
486+
clone.shardIds = shardIds != null ? new ArrayList<>(shardIds) : null;
487+
return clone;
488+
} catch (CloneNotSupportedException e) {
489+
throw new AssertionError();
490+
}
491+
}
470492
}
471493

472-
public static class Optimizer {
494+
public static class Optimizer implementsCloneable{
473495
private Collection<String> rules;
496+
497+
@Override
498+
public Optimizer clone() {
499+
try {
500+
Optimizer clone = (Optimizer) super.clone();
501+
clone.rules = rules != null ? new ArrayList<>(rules) : null;
502+
return clone;
503+
} catch (CloneNotSupportedException e) {
504+
throw new AssertionError();
505+
}
506+
}
474507
}
475508

476509
/**
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.arangodb.model;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
import static org.assertj.core.api.Assertions.assertThat;
9+
10+
class AqlQueryOptionsTest {
11+
12+
@Test
13+
void cloneable() {
14+
List<String> rules = Arrays.asList("foo", "bar");
15+
AqlQueryOptions options = new AqlQueryOptions()
16+
.cache(true)
17+
.stream(true)
18+
.rules(rules)
19+
.shardIds("a", "b");
20+
AqlQueryOptions clone = options.clone();
21+
assertThat(clone.getCache()).isEqualTo(options.getCache());
22+
assertThat(clone.getStream()).isEqualTo(options.getStream());
23+
assertThat(clone.getRules())
24+
.isEqualTo(options.getRules())
25+
.isNotSameAs(options.getRules());
26+
assertThat(clone.getShardIds())
27+
.isEqualTo(options.getShardIds())
28+
.isNotSameAs(options.getShardIds());
29+
}
30+
31+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /