1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.bremersee.geojson.model;
18
19 import static java.util.Objects.isNull;
20
21 import io.swagger.v3.oas.annotations.media.Schema;
22 import java.io.Serial;
23 import java.io.Serializable;
24 import java.math.BigDecimal;
25 import java.util.ArrayList;
26 import lombok.EqualsAndHashCode;
27 import lombok.ToString;
28
29
30
31
32
33
34 @Schema(description = "The first two elements are longitude and latitude.")
35 @EqualsAndHashCode(callSuper = true)
36 @ToString(callSuper = true)
37 public class Position extends ArrayList<BigDecimal> implements Serializable {
38
39 @Serial
40 private static final long serialVersionUID = 1L;
41
42
43
44
45 public Position() {
46 super(3);
47 }
48
49
50
51
52
53
54
55 public Position(BigDecimal x, BigDecimal y) {
56 this(x, y, null);
57 }
58
59
60
61
62
63
64
65
66 public Position(BigDecimal x, BigDecimal y, BigDecimal z) {
67 super(isNull(z) ? 2 : 3);
68 if (isNull(x)) {
69 throw new IllegalArgumentException("X (longitude) must not be null.");
70 }
71 if (isNull(y)) {
72 throw new IllegalArgumentException("Y (latitude) must not be null.");
73 }
74 add(x);
75 add(y);
76 if (!isNull(z)) {
77 add(z);
78 }
79 }
80
81 }
82