@@ -1205,11 +1205,11 @@ public static String upperFirst(final String string) {
12051205 }
12061206
12071207 public static String capitalize (final String string ) {
1208- return upperFirst (baseToString (string ). toLowerCase () );
1208+ return upperFirst (baseToString (string ));
12091209 }
12101210
12111211 public static String uncapitalize (final String string ) {
1212- return lowerFirst (baseToString (string ). toLowerCase () );
1212+ return lowerFirst (baseToString (string ));
12131213 }
12141214
12151215 private static String baseToString (String value ) {
@@ -1547,6 +1547,34 @@ public static <T> T set(final Map<String, Object> object, final String path, Obj
15471547 return baseGetAndSet (object , path , Optional .of (value ));
15481548 }
15491549
1550+ @ SuppressWarnings ("unchecked" )
1551+ public static Map <String , Object > remove (final Map <String , Object > map , final String key ) {
1552+ Map <String , Object > outMap = newLinkedHashMap ();
1553+ for (Map .Entry <String , Object > entry : map .entrySet ()) {
1554+ if (!entry .getKey ().equals (key )) {
1555+ outMap .put (entry .getKey (), makeObjectForRemove (entry .getValue (), key ));
1556+ }
1557+ }
1558+ return outMap ;
1559+ }
1560+
1561+ @ SuppressWarnings ("unchecked" )
1562+ private static Object makeObjectForRemove (Object value , final String key ) {
1563+ final Object result ;
1564+ if (value instanceof List ) {
1565+ List <Object > values = newArrayList ();
1566+ for (Object item : (List ) value ) {
1567+ values .add (item instanceof Map ? remove ((Map <String , Object >) item , key ) : item );
1568+ }
1569+ result = values ;
1570+ } else if (value instanceof Map ) {
1571+ result = remove ((Map <String , Object >) value , key );
1572+ } else {
1573+ result = value ;
1574+ }
1575+ return result ;
1576+ }
1577+
15501578 public static class FetchResponse {
15511579 private final boolean ok ;
15521580 private final int status ;
@@ -1990,8 +2018,9 @@ public String toJsonJavaString() {
19902018 return Json .toJsonJavaString ((Collection ) getIterable ());
19912019 }
19922020
1993- public static Object fromXml (final String xml ) {
1994- return Xml .fromXml (xml );
2021+ @ SuppressWarnings ("unchecked" )
2022+ public static <T > T fromXml (final String xml ) {
2023+ return (T ) Xml .fromXml (xml );
19952024 }
19962025
19972026 public static Map <String , Object > fromXmlMap (final String xml ) {
@@ -2011,24 +2040,29 @@ public static Map<String, Object> fromXmlMap(final String xml, final Xml.FromTyp
20112040 return result ;
20122041 }
20132042
2014- public static Object fromXml (final String xml , final Xml .FromType fromType ) {
2015- return Xml .fromXml (xml , fromType );
2043+ @ SuppressWarnings ("unchecked" )
2044+ public static <T > T fromXml (final String xml , final Xml .FromType fromType ) {
2045+ return (T ) Xml .fromXml (xml , fromType );
20162046 }
20172047
2018- public static Object fromXmlMakeArrays (final String xml ) {
2019- return Xml .fromXmlMakeArrays (xml );
2048+ @ SuppressWarnings ("unchecked" )
2049+ public static <T > T fromXmlMakeArrays (final String xml ) {
2050+ return (T ) Xml .fromXmlMakeArrays (xml );
20202051 }
20212052
2022- public static Object fromXmlWithoutNamespaces (final String xml ) {
2023- return Xml .fromXmlWithoutNamespaces (xml );
2053+ @ SuppressWarnings ("unchecked" )
2054+ public static <T > T fromXmlWithoutNamespaces (final String xml ) {
2055+ return (T ) Xml .fromXmlWithoutNamespaces (xml );
20242056 }
20252057
2026- public static Object fromXmlWithoutAttributes (final String xml ) {
2027- return Xml .fromXmlWithoutAttributes (xml );
2058+ @ SuppressWarnings ("unchecked" )
2059+ public static <T > T fromXmlWithoutAttributes (final String xml ) {
2060+ return (T ) Xml .fromXmlWithoutAttributes (xml );
20282061 }
20292062
2030- public static Object fromXmlWithoutNamespacesAndAttributes (final String xml ) {
2031- return Xml .fromXmlWithoutNamespacesAndAttributes (xml );
2063+ @ SuppressWarnings ("unchecked" )
2064+ public static <T > T fromXmlWithoutNamespacesAndAttributes (final String xml ) {
2065+ return (T ) Xml .fromXmlWithoutNamespacesAndAttributes (xml );
20322066 }
20332067
20342068 public static String toXml (Collection collection ) {
@@ -2039,8 +2073,9 @@ public static String toXml(Map map) {
20392073 return Xml .toXml (map );
20402074 }
20412075
2042- public static Object fromJson (String string ) {
2043- return Json .fromJson (string );
2076+ @ SuppressWarnings ("unchecked" )
2077+ public static <T > T fromJson (String string ) {
2078+ return (T ) Json .fromJson (string );
20442079 }
20452080
20462081 public Object fromJson () {
0 commit comments