]> git.basschouten.com Git - openhab-addons.git/blob
90225d4f7aab30e2cf4d4d306afa67ee592e69a0
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.surepetcare.internal.dto;
14
15 import java.time.ZonedDateTime;
16 import java.util.HashMap;
17 import java.util.Map;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20
21 /**
22  * The {@link SurePetcareBaseObject} is the Java class used as a base DTO for other primary JSON objects.
23  *
24  * @author Rene Scherer - Initial contribution
25  */
26 @NonNullByDefault
27 public class SurePetcareBaseObject {
28
29     public Long id = 0L;
30     public String version = "";
31     public ZonedDateTime createdAt = ZonedDateTime.now();
32     public ZonedDateTime updatedAt = ZonedDateTime.now();
33
34     public Map<String, String> getThingProperties() {
35         Map<String, String> properties = new HashMap<String, String>();
36         properties.put("id", id.toString());
37         properties.put("version", version);
38         properties.put("createdAt", createdAt.toString());
39         properties.put("updatedAt", updatedAt.toString());
40         return properties;
41     }
42
43     public SurePetcareBaseObject assign(SurePetcareBaseObject newdev) {
44         this.id = newdev.id;
45         this.version = newdev.version;
46         this.createdAt = newdev.createdAt;
47         this.updatedAt = newdev.updatedAt;
48         return this;
49     }
50 }