2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.persistence.influxdb.internal;
15 import java.time.Instant;
16 import java.util.Collections;
17 import java.util.HashMap;
20 import org.eclipse.jdt.annotation.DefaultLocation;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
24 * Point data to be stored in InfluxDB
26 * @author Joan Pujol Espinar - Initial contribution
28 @NonNullByDefault({ DefaultLocation.PARAMETER })
29 public class InfluxPoint {
30 private final String measurementName;
31 private final Instant time;
32 private final Object value;
33 private final Map<String, String> tags;
35 private InfluxPoint(Builder builder) {
36 measurementName = builder.measurementName;
38 value = builder.value;
42 public static Builder newBuilder(String measurementName) {
43 return new Builder(measurementName);
46 public String getMeasurementName() {
47 return measurementName;
50 public Instant getTime() {
54 public Object getValue() {
58 public Map<String, String> getTags() {
59 return Collections.unmodifiableMap(tags);
62 public static final class Builder {
63 private final String measurementName;
66 private final Map<String, String> tags = new HashMap<>();
68 private Builder(String measurementName) {
69 this.measurementName = measurementName;
72 public Builder withTime(Instant val) {
77 public Builder withValue(Object val) {
82 public Builder withTag(String name, Object value) {
83 tags.put(name, value.toString());
87 public InfluxPoint build() {
88 return new InfluxPoint(this);
93 public String toString() {
94 return "InfluxPoint{" + "measurementName='" + measurementName + '\'' + ", time=" + time + ", value=" + value
95 + ", tags=" + tags + '}';