|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.staccatocommons.lang.tuple.AbstractTuple
@Value
@Conditionally(value={net.sf.staccatocommons.restrictions.value.Immutable.class,java.io.Serializable.class})
public abstract class AbstractTuple
A AbstractTuple is a fixed size sequence of heterogeneous objects.
They are ConditionallyImmutable and ConditionallySerializable
. They are comparable, as long as they components are, too.
Tuples are aimed to be used in those situations where an object that just
relates others together is needed. Such object does not encapsulate any
business concept nor any specific behavior except of
Object.toString(), Object.equals(Object),
Object.hashCode() and Comparable#compareTo(Object, Object).
Tuples are thus not intended to be used everywhere nor extended, but there
are some concrete scenarios where they are useful:
Tuple2<Integer, Integer> divMod(int x, int y)Tuples named _. Although
it looks odd at first glance, combining it with static imports produces quite
clean code. For example, using again the divMod method:
import static net.sf.staccatocommons.lang.tuple._; ... Tuple2<Integer, Integer> divMod(int x, int y) return _(x/y, x%y) ...
Tuple2,
Tuple3,
Quadruple,
Serialized Form| Nested Class Summary | |
|---|---|
protected static class |
AbstractTuple.TupleState<A>
|
| Method Summary | |
|---|---|
abstract Object[] |
toArray()
Converts this tuple into an array |
List<Object> |
toList()
Gets an unmodifiable list containing each components of this tuple as elements |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
@NonNull public abstract Object[] toArray()
@NonNull public List<Object> toList()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||