blob: 0ac195efb5df02a48f55547377b330a68f3caef7 (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.indexinglanguage.expressions;
import com.yahoo.document.DataType;
import com.yahoo.vespa.objects.ObjectOperation;
import com.yahoo.vespa.objects.ObjectPredicate;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/**
* @author Simon Thoresen Hult
*/
public abstract class ExpressionList<T extends Expression> extends CompositeExpression implements Iterable<T> {
private final List<T> expressions = new LinkedList<T>();
protected ExpressionList(Iterable<? extends T> lst, DataType inputType) {
super(inputType);
for (T exp : lst) {
this.expressions.add(exp);
}
}
public int size() {
return expressions.size();
}
public T get(int idx) {
return expressions.get(idx);
}
public boolean isEmpty() {
return expressions.isEmpty();
}
public List<T> asList() {
return Collections.unmodifiableList(expressions);
}
@Override
public Iterator<T> iterator() {
return expressions.iterator();
}
@Override
@SuppressWarnings("rawtypes")
public boolean equals(Object obj) {
if (!(obj instanceof ExpressionList)) {
return false;
}
ExpressionList rhs = (ExpressionList)obj;
if (!expressions.equals(rhs.expressions)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return getClass().hashCode() + expressions.hashCode();
}
@Override
public void selectMembers(ObjectPredicate predicate, ObjectOperation operation) {
for (T exp : expressions) {
exp.select(predicate, operation);
}
}
}
|