File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -48,4 +48,24 @@ trait Product extends Any with Equals {
48
48
* @return in the default implementation, the empty string
49
49
*/
50
50
def productPrefix = " "
51
+
52
+ /** The name of the n^th^ element of this product, 0-based.
53
+ * In the default implementation, an empty string.
54
+ *
55
+ * @param n the index of the element name to return
56
+ * @throws IndexOutOfBoundsException
57
+ * @return the name of the specified element
58
+ */
59
+ def productElementName (n : Int ): String =
60
+ if (n >= 0 && n < productArity) " "
61
+ else throw new IndexOutOfBoundsException (n.toString)
62
+
63
+ /** An iterator over the names of all the elements of this product.
64
+ */
65
+ def productElementNames : Iterator [String ] = new scala.collection.AbstractIterator [String ] {
66
+ private [this ] var c : Int = 0
67
+ private [this ] val cmax = productArity
68
+ def hasNext = c < cmax
69
+ def next () = { val result = productElementName(c); c += 1 ; result }
70
+ }
51
71
}
You can’t perform that action at this time.
0 commit comments