diff options
Diffstat (limited to 'src/org/traccar/model/Extensible.java')
-rw-r--r-- | src/org/traccar/model/Extensible.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/org/traccar/model/Extensible.java b/src/org/traccar/model/Extensible.java new file mode 100644 index 000000000..b4052dbda --- /dev/null +++ b/src/org/traccar/model/Extensible.java @@ -0,0 +1,56 @@ +package org.traccar.model; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class Extensible { + + private long id; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + private Map<String, Object> attributes = new LinkedHashMap<>(); + + public Map<String, Object> getAttributes() { + return attributes; + } + + public void setAttributes(Map<String, Object> attributes) { + this.attributes = attributes; + } + + public void set(String key, boolean value) { + attributes.put(key, value); + } + + public void set(String key, int value) { + attributes.put(key, value); + } + + public void set(String key, long value) { + attributes.put(key, value); + } + + public void set(String key, double value) { + attributes.put(key, value); + } + + public void set(String key, String value) { + if (value != null && !value.isEmpty()) { + attributes.put(key, value); + } + } + + public void add(Map.Entry<String, Object> entry) { + if (entry != null && entry.getValue() != null) { + attributes.put(entry.getKey(), entry.getValue()); + } + } + +} |