@@ -1205,11 +1205,11 @@ public static String upperFirst(final String string) {
1205
1205
}
1206
1206
1207
1207
public static String capitalize (final String string ) {
1208
- return upperFirst (baseToString (string ). toLowerCase () );
1208
+ return upperFirst (baseToString (string ));
1209
1209
}
1210
1210
1211
1211
public static String uncapitalize (final String string ) {
1212
- return lowerFirst (baseToString (string ). toLowerCase () );
1212
+ return lowerFirst (baseToString (string ));
1213
1213
}
1214
1214
1215
1215
private static String baseToString (String value ) {
@@ -1547,6 +1547,34 @@ public static <T> T set(final Map<String, Object> object, final String path, Obj
1547
1547
return baseGetAndSet (object , path , Optional .of (value ));
1548
1548
}
1549
1549
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
+
1550
1578
public static class FetchResponse {
1551
1579
private final boolean ok ;
1552
1580
private final int status ;
@@ -1990,8 +2018,9 @@ public String toJsonJavaString() {
1990
2018
return Json .toJsonJavaString ((Collection ) getIterable ());
1991
2019
}
1992
2020
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 );
1995
2024
}
1996
2025
1997
2026
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
2011
2040
return result ;
2012
2041
}
2013
2042
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 );
2016
2046
}
2017
2047
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 );
2020
2051
}
2021
2052
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 );
2024
2056
}
2025
2057
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 );
2028
2061
}
2029
2062
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 );
2032
2066
}
2033
2067
2034
2068
public static String toXml (Collection collection ) {
@@ -2039,8 +2073,9 @@ public static String toXml(Map map) {
2039
2073
return Xml .toXml (map );
2040
2074
}
2041
2075
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 );
2044
2079
}
2045
2080
2046
2081
public Object fromJson () {
0 commit comments