blob: 9e4da30544560a1de785113eb9056093880bb6ee (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.vespa;
import com.yahoo.search.grouping.Continuation;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* @author Simon Thoresen Hult
*/
final class CompositeContinuation extends EncodableContinuation implements Iterable<EncodableContinuation> {
private final List<EncodableContinuation> children = new ArrayList<>();
@Override
public CompositeContinuation copy() {
CompositeContinuation copy = new CompositeContinuation();
this.children.forEach(child -> copy.add(child.copy()));
return copy;
}
public CompositeContinuation add(EncodableContinuation child) {
children.add(child);
return this;
}
@Override
public Iterator<EncodableContinuation> iterator() {
return children.iterator();
}
@Override
public int hashCode() {
return children.hashCode();
}
@Override
public boolean equals(Object obj) {
return obj instanceof CompositeContinuation && children.equals(((CompositeContinuation)obj).children);
}
@Override
public void encode(IntegerEncoder out) {
for (EncodableContinuation child : children) {
child.encode(out);
}
}
public static CompositeContinuation decode(IntegerDecoder from) {
CompositeContinuation ret = new CompositeContinuation();
while (from.hasNext()) {
ret.add(OffsetContinuation.decode(from));
}
return ret;
}
}
|