From 4ab007201bd177a2fbf46a90b7b73262c5792caf Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 17 Apr 2017 15:53:41 +1200 Subject: Support for optional values --- src/org/traccar/model/Extensible.java | 38 ++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'src/org/traccar/model') diff --git a/src/org/traccar/model/Extensible.java b/src/org/traccar/model/Extensible.java index b8c83bb21..b7953d8a6 100644 --- a/src/org/traccar/model/Extensible.java +++ b/src/org/traccar/model/Extensible.java @@ -40,20 +40,44 @@ public class Extensible { this.attributes = attributes; } - public void set(String key, boolean value) { + 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, Byte value) { + if (value != null) { + attributes.put(key, value.intValue()); + } } - public void set(String key, long value) { - attributes.put(key, value); + public void set(String key, Short value) { + if (value != null) { + attributes.put(key, value.intValue()); + } } - public void set(String key, double value) { - attributes.put(key, value); + public void set(String key, Integer value) { + if (value != null) { + attributes.put(key, value); + } + } + + public void set(String key, Long value) { + if (value != null) { + attributes.put(key, value); + } + } + + public void set(String key, Float value) { + if (value != null) { + attributes.put(key, value.doubleValue()); + } + } + + public void set(String key, Double value) { + if (value != null) { + attributes.put(key, value); + } } public void set(String key, String value) { -- cgit v1.2.3