package uk.ac.ox.cs.pagoda.util.tuples; import java.util.Collections; /** * Allows to create an immutable Tuple in a non-atomic way. * It can create only one Tuple. * */ public class TupleBuilder { private Tuple tuple = new Tuple(); private boolean building = true; public TupleBuilder append(T t) { if(building) { tuple.elements.add(t); return this; } return null; } public TupleBuilder append(T[] t) { if(building) { Collections.addAll(tuple.elements, t); return this; } return null; } public Tuple build() { if(building) { building = false; return tuple; } return null; } }