Kv.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package org.zhongzheng.common.utils;
  2. //
  3. // Source code recreated from a .class file by IntelliJ IDEA
  4. // (powered by FernFlower decompiler)
  5. //
  6. import java.sql.Time;
  7. import java.sql.Timestamp;
  8. import java.util.Date;
  9. import java.util.HashMap;
  10. import org.zhongzheng.common.utils.Func;
  11. import org.springframework.util.LinkedCaseInsensitiveMap;
  12. public class Kv extends LinkedCaseInsensitiveMap<Object> {
  13. private Kv() {
  14. }
  15. public static Kv init() {
  16. return new Kv();
  17. }
  18. public static Kv create() {
  19. return new Kv();
  20. }
  21. public static <K, V> HashMap<K, V> newMap() {
  22. return new HashMap(16);
  23. }
  24. public Kv set(String attr, Object value) {
  25. this.put(attr, value);
  26. return this;
  27. }
  28. public Kv setIgnoreNull(String attr, Object value) {
  29. if (null != attr && null != value) {
  30. this.set(attr, value);
  31. }
  32. return this;
  33. }
  34. public Object getObj(String key) {
  35. return super.get(key);
  36. }
  37. public <T> T get(String attr, T defaultValue) {
  38. Object result = this.get(attr);
  39. return result != null ? (T)result : defaultValue;
  40. }
  41. public String getStr(String attr) {
  42. return Func.toStr(this.get(attr), (String)null);
  43. }
  44. public Integer getInt(String attr) {
  45. return Func.toInt(this.get(attr), -1);
  46. }
  47. public Long getLong(String attr) {
  48. return Func.toLong(this.get(attr), -1L);
  49. }
  50. public Float getFloat(String attr) {
  51. return Func.toFloat(this.get(attr), (Float)null);
  52. }
  53. public Double getDouble(String attr) {
  54. return Func.toDouble(this.get(attr), (Double)null);
  55. }
  56. public Boolean getBool(String attr) {
  57. return Func.toBoolean(this.get(attr), (Boolean)null);
  58. }
  59. public byte[] getBytes(String attr) {
  60. return (byte[])this.get(attr, (Object)null);
  61. }
  62. public Date getDate(String attr) {
  63. return (Date)this.get(attr, (Object)null);
  64. }
  65. public Time getTime(String attr) {
  66. return (Time)this.get(attr, (Object)null);
  67. }
  68. public Timestamp getTimestamp(String attr) {
  69. return (Timestamp)this.get(attr, (Object)null);
  70. }
  71. public Number getNumber(String attr) {
  72. return (Number)this.get(attr, (Object)null);
  73. }
  74. public Kv clone() {
  75. Kv clone = new Kv();
  76. clone.putAll(this);
  77. return clone;
  78. }
  79. }