Javatuples 简明教程
JavaTuples - Overview
Tuple
元组是对象序列,这些对象可能相同类型,也可能不同类型。请考虑以下示例 −
Tuple is a sequence of objects which may or may not be of same type. Consider the following example −
[12,"TutorialsPoint", java.sql.Connection@li757b]
上面的对象是一个包含三个元素的元组,一个整数、一个字符串和一个连接对象。
Above object is a tuple of three elements, an Integer, a string and a Connection Object.
JavaTuple
JavaTuples 是一个非常简单的库,它提供了十个不同的元组类,这些类足以处理大多数与元组相关的需求。
JavaTuples is a very simple library which offers ten different tuple classses which are sufficient to handle most of the tuple related requirements.
-
Unit<A> - 1 element
-
Pair<A,B> - 2 elements
-
Triplet<A,B,C> - 3 elements
-
Quartet<A,B,C,D> - 4 elements
-
Quintet<A,B,C,D,E> - 5 elements
-
Sextet<A,B,C,D,E,F> - 6 elements
-
Septet<A,B,C,D,E,F,G> - 7 elements
-
Octet<A,B,C,D,E,F,G,H> - 8 elements
-
Ennead<A,B,C,D,E,F,G,H,I> - 9 elements
-
Decade<A,B,C,D,E,F,G,H,I,J> - 10 elements
除了这些元组类之外,JavaTuples 还出于语义原因提供了另外两个类。
Apart from these tuple classes, JavaTuples also provides two additional classes for semantics sake.
-
KeyValue<A,B>
-
LabelValue<A,B>
所有元组类都是类型安全的并且是不可变的,并且实现了以下接口和方法。
All tuple classes are typesafe and immutable and implements following interfaces and methods.
-
Iterable
-
Serializable
-
Comparable<Tuple>
-
equals()
-
hashCode()
-
toString()