You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2018/10/05 20:34:30 UTC
[juneau] branch master updated: ObjectMap removeX convenience
methods.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 91b5382 ObjectMap removeX convenience methods.
91b5382 is described below
commit 91b5382a3070e4b5f54df3a97e0b270e5cab1465
Author: JamesBognar <ja...@apache.org>
AuthorDate: Fri Oct 5 16:34:16 2018 -0400
ObjectMap removeX convenience methods.
---
.../src/main/java/org/apache/juneau/ObjectMap.java | 68 ++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java
index 8c18aa1..a9ac595 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java
@@ -1270,6 +1270,74 @@ public class ObjectMap extends LinkedHashMap<String,Object> {
return t;
}
+ /**
+ * Equivalent to calling <code>removeWithDefault(key,<jk>null</jk>,String.<jk>class</jk>)</code>.
+ *
+ * @param key The key.
+ * @return The converted value, or <jk>null</jk> if the map contains no mapping for this key.
+ * @throws InvalidDataConversionException If value cannot be converted.
+ */
+ public String removeString(String key) {
+ return removeString(key, null);
+ }
+
+ /**
+ * Equivalent to calling <code>removeWithDefault(key,def,String.<jk>class</jk>)</code>.
+ *
+ * @param key The key.
+ * @param def The default value if the map doesn't contain the specified mapping.
+ * @return The converted value, or the default value if the map contains no mapping for this key.
+ * @throws InvalidDataConversionException If value cannot be converted.
+ */
+ public String removeString(String key, String def) {
+ return removeWithDefault(key, def, String.class);
+ }
+
+ /**
+ * Equivalent to calling <code>removeWithDefault(key,<jk>null</jk>,Integer.<jk>class</jk>)</code>.
+ *
+ * @param key The key.
+ * @return The converted value, or <jk>null</jk> if the map contains no mapping for this key.
+ * @throws InvalidDataConversionException If value cannot be converted.
+ */
+ public Integer removeInt(String key) {
+ return removeInt(key, null);
+ }
+
+ /**
+ * Equivalent to calling <code>removeWithDefault(key,def,Integer.<jk>class</jk>)</code>.
+ *
+ * @param key The key.
+ * @param def The default value if the map doesn't contain the specified mapping.
+ * @return The converted value, or the default value if the map contains no mapping for this key.
+ * @throws InvalidDataConversionException If value cannot be converted.
+ */
+ public Integer removeInt(String key, Integer def) {
+ return removeWithDefault(key, def, Integer.class);
+ }
+
+ /**
+ * Equivalent to calling <code>removeWithDefault(key,<jk>null</jk>,Boolean.<jk>class</jk>)</code>.
+ *
+ * @param key The key.
+ * @return The converted value, or <jk>null</jk> if the map contains no mapping for this key.
+ * @throws InvalidDataConversionException If value cannot be converted.
+ */
+ public Boolean removeBoolean(String key) {
+ return removeBoolean(key, null);
+ }
+
+ /**
+ * Equivalent to calling <code>removeWithDefault(key,def,Boolean.<jk>class</jk>)</code>.
+ *
+ * @param key The key.
+ * @param def The default value if the map doesn't contain the specified mapping.
+ * @return The converted value, or the default value if the map contains no mapping for this key.
+ * @throws InvalidDataConversionException If value cannot be converted.
+ */
+ public Boolean removeBoolean(String key, Boolean def) {
+ return removeWithDefault(key, def, Boolean.class);
+ }
/**
* Convenience method for removing several keys at once.