1 package org.djutils.data;
2
3 import org.djunits.Throw;
4 import org.djutils.immutablecollections.ImmutableList;
5
6
7
8
9
10
11
12
13
14
15
16 public abstract class AbstractDataTable implements DataTable
17 {
18
19
20 private final String id;
21
22
23 private final String description;
24
25
26 private final ImmutableList<DataColumn<?>> columns;
27
28
29
30
31
32
33
34
35
36 public AbstractDataTable(final String id, final String description, final ImmutableList<DataColumn<?>> columns)
37 {
38 Throw.whenNull(id, "Id may not be null.");
39 Throw.whenNull(description, "Description may not be null.");
40 Throw.whenNull(columns, "Columns may not be null.");
41 Throw.when(id.length() == 0, IllegalArgumentException.class, "id cannot be empty");
42 Throw.when(columns.size() == 0, IllegalArgumentException.class, "there should be at least one column");
43 this.id = id;
44 this.description = description;
45 this.columns = columns;
46 }
47
48
49 @Override
50 public ImmutableList<DataColumn<?>> getColumns()
51 {
52 return this.columns;
53 }
54
55
56 @Override
57 public String getId()
58 {
59 return this.id;
60 }
61
62
63 @Override
64 public String getDescription()
65 {
66 return this.description;
67 }
68
69 }