1 package org.djutils.data;
2
3 import java.util.Arrays;
4
5
6
7
8
9
10
11
12
13
14
15 public class Row
16 {
17
18
19 private final Table table;
20
21
22 private final Object[] values;
23
24
25
26
27
28
29 public Row(final Table table, final Object[] values)
30 {
31 this.table = table;
32 this.values = values;
33 }
34
35
36
37
38
39
40
41 @SuppressWarnings("unchecked")
42 public <T> T getValue(final Column<T> column)
43 {
44 return (T) this.values[this.table.getColumnNumber(column)];
45 }
46
47
48
49
50
51
52 public Object getValue(final String id)
53 {
54 return this.values[this.table.getColumnNumber(id)];
55 }
56
57
58
59
60
61
62 public Object getValue(final int columnNumber)
63 {
64 return this.values[columnNumber];
65 }
66
67
68
69
70
71 public Object[] getValues()
72 {
73 return this.values;
74 }
75
76 @Override
77 public int hashCode()
78 {
79 final int prime = 31;
80 int result = 1;
81 result = prime * result + Arrays.deepHashCode(this.values);
82 return result;
83 }
84
85 @Override
86 public boolean equals(final Object obj)
87 {
88 if (this == obj)
89 {
90 return true;
91 }
92 if (obj == null)
93 {
94 return false;
95 }
96 if (getClass() != obj.getClass())
97 {
98 return false;
99 }
100 Row other = (Row) obj;
101 return Arrays.deepEquals(this.values, other.values);
102 }
103
104 @Override
105 public String toString()
106 {
107 return "Row " + Arrays.toString(this.values);
108 }
109
110 }