IntLists
factory を使う
import org.eclipse.collections.impl.factory.primitive.IntLists
def list = IntLists.mutable.of(1,2,3,4)
// -> [1, 2, 3, 4]
MutableCollection#withAll(Iterable<T>)
を使う
def list = Lists.mutable.of('foo', 'bar')
def another = Lists.immutable.of('baz', 'qux')
def result = list.withAll(another)
// -> [foo, bar, baz, qux]
これは Java 標準のAPI でやる場合の次のコードと同等
def list = ['foo', 'bar']
def another = ['baz', 'qux']
list.addAll(another)
list
つまり、 Collector
を作る時の combiner
の指定を1行のラムダに変更できる
標準API
(left, right) -> {
left.addAll(right);
return left;
}
eclipse collections
MutableList::withAll