View Javadoc
1   package de.dlr.shepard.data.spatialdata.io;
2   
3   import jakarta.validation.constraints.NotEmpty;
4   import jakarta.validation.constraints.NotNull;
5   import java.time.Instant;
6   import java.util.Map;
7   import lombok.Data;
8   import org.eclipse.microprofile.openapi.annotations.media.Schema;
9   
10  @Data
11  @Schema(name = "SpatialDataPoint")
12  public class SpatialDataPointIO {
13  
14    @Schema(
15      description = "Time in nanoseconds since unix epoch. If no value is provided, the current server time is used."
16    )
17    private Long timestamp;
18  
19    @NotNull
20    @Schema(description = "X Coordinate", required = true)
21    private Double x;
22  
23    @NotNull
24    @Schema(description = "Y Coordinate", required = true)
25    private Double y;
26  
27    @NotNull
28    @Schema(description = "Z Coordinate", required = true)
29    private Double z;
30  
31    @NotEmpty
32    @Schema(description = "measurement", required = true)
33    private Map<String, Object> measurements;
34  
35    @Schema(description = "Data point meta data", required = true)
36    private Map<String, Object> metadata;
37  
38    public SpatialDataPointIO(
39      Long timestamp,
40      @NotNull Double x,
41      @NotNull Double y,
42      @NotNull Double z,
43      Map<String, Object> metadata,
44      @NotEmpty Map<String, Object> measurements
45    ) {
46      this.timestamp = timestamp == null ? Instant.now().toEpochMilli() * 1_000_000 : timestamp;
47      this.x = x;
48      this.y = y;
49      this.z = z;
50      this.metadata = metadata;
51      this.measurements = measurements;
52    }
53  }