|
|
|
|
|
by vips7L
637 days ago
|
|
You can enforce some invariants during construction: record Point(int x, int y) {
Point {
if (x < 0) throw new IllegalArgumentException()
}
}
or if you want to assert something is not null: record Person(String name) {
Person {
requireNonNull(name);
}
}
|
|