blob: aacd15ec2549100ad8d9319736abc65e9b03351e (
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
|
package uk.ac.ox.cs.pagoda.util.tuples;
/**
* Allows to create an immutable <tt>Tuple</tt> in a non-atomic way.
* It can create only one <tt>Tuple</tt>.
* */
public class TupleBuilder<T> {
private Tuple tuple = new Tuple();
private boolean building = true;
public boolean add(T t) {
if(building) tuple.elements.add(t);
return building;
}
public Tuple<T> create() {
if(building) {
building = false;
return tuple;
}
return null;
}
}
|