|
@@ -0,0 +1,117 @@
|
|
|
+package com.xynet.marketing.utils.collections.map;
|
|
|
+
|
|
|
+import java.io.Serializable;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.sql.Timestamp;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * HashMap
|
|
|
+ */
|
|
|
+public class JHashMap<K, V> extends HashMap<K, V> implements JMap<K, V>, Serializable {
|
|
|
+
|
|
|
+ public JHashMap() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public JHashMap(int initialCapacity) {
|
|
|
+ super(initialCapacity);
|
|
|
+ }
|
|
|
+
|
|
|
+ public JHashMap(Map<K, V> map) {
|
|
|
+ super(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JMap<K, V> set(K key, V value) {
|
|
|
+ this.put(key, value);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JMap<K, V> set(boolean condition, K key, V value) {
|
|
|
+ if (condition) {
|
|
|
+ this.put(key, value);
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public V setIfAbsent(K key, V value) {
|
|
|
+ return this.putIfAbsent(key, value);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JMap<K, V> setAll(Map<K, V> map) {
|
|
|
+ this.putAll(map);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JMap<K, V> setAll(boolean condition, Map<K, V> map) {
|
|
|
+ if (condition) {
|
|
|
+ this.putAll(map);
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public V del(K key) {
|
|
|
+ return this.remove(key);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getString(K key) {
|
|
|
+ return this.get(key) == null ? null : this.get(key).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer getInt(K key) {
|
|
|
+ return this.get(key) == null ? null : Integer.parseInt(this.get(key).toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long getLong(K key) {
|
|
|
+ return this.get(key) == null ? null : Long.parseLong(this.get(key).toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Double getDouble(K key) {
|
|
|
+ return this.get(key) == null ? null : Double.parseDouble(this.get(key).toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BigDecimal getBigDecimal(K key) {
|
|
|
+ return this.get(key) == null ? null : new BigDecimal(this.get(key).toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean getBoolean(K key) {
|
|
|
+ return this.get(key) == null ? null : Boolean.parseBoolean(this.get(key).toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public LocalDateTime getLocalDateTime(K key) {
|
|
|
+ return this.get(key) == null ? null : (LocalDateTime) this.get(key);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Timestamp getTimestamp(K key) {
|
|
|
+ return this.get(key) == null ? null : (Timestamp) this.get(key);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public V get(K key, Class<V> t) {
|
|
|
+ V v = this.get(key);
|
|
|
+ return v == null ? null : v;
|
|
|
+ }
|
|
|
+}
|