diff --git a/README.md b/README.md
index c62d1d39..42873baa 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ Both of these features ensure that our library can be seamlessly integrated into
To include in your project:
##### Gradle
```
-implementation 'com.cedarsoftware:java-util:2.7.0'
+implementation 'com.cedarsoftware:java-util:2.8.0'
```
##### Maven
@@ -34,7 +34,7 @@ implementation 'com.cedarsoftware:java-util:2.7.0'
com.cedarsoftware
java-util
- 2.7.0
+ 2.8.0
```
---
diff --git a/changelog.md b/changelog.md
index cf2eb749..f1cd2a74 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,7 @@
### Revision History
+* 2.8.0
+ * Added `ClassUtilities.doesOneWrapTheOther()` API so that it is easy to test if one class is wrapping the other.
+ * Added `StringBuilder` and `StringBuffer` to `Strings` to the `Converter.` Eliminates special cases for `.toString()` calls where generalized `convert(src, type)` is being used.
* 2.7.0
* Added `ConcurrentHashList,` which implements a thread-safe `List.` Provides all API support except for `listIterator(),` however, it implements `iterator()` which returns an iterator to a snapshot copy of the `List.`
* Added `ConcurrentHashSet,` a true `Set` which is a bit easier to use than `ConcurrentSkipListSet,` which as a `NaviableSet` and `SortedSet,` requires each element to be `Comparable.`
diff --git a/pom.xml b/pom.xml
index 71b2acbc..4967e13e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.cedarsoftware
java-util
bundle
- 2.7.0
+ 2.8.0
Java Utilities
https://github.com/jdereg/java-util
diff --git a/src/main/java/com/cedarsoftware/util/ClassUtilities.java b/src/main/java/com/cedarsoftware/util/ClassUtilities.java
index 3be94c9e..37f7950b 100644
--- a/src/main/java/com/cedarsoftware/util/ClassUtilities.java
+++ b/src/main/java/com/cedarsoftware/util/ClassUtilities.java
@@ -40,9 +40,9 @@
public class ClassUtilities
{
private static final Set> prims = new HashSet<>();
-
private static final Map, Class>> primitiveToWrapper = new HashMap<>(20, .8f);
private static final Map> nameToClass = new HashMap<>();
+ private static final Map, Class>> wrapperMap = new HashMap<>();
static
{
@@ -76,6 +76,23 @@ public class ClassUtilities
primitiveToWrapper.put(byte.class, Byte.class);
primitiveToWrapper.put(short.class, Short.class);
primitiveToWrapper.put(void.class, Void.class);
+
+ wrapperMap.put(int.class, Integer.class);
+ wrapperMap.put(Integer.class, int.class);
+ wrapperMap.put(char.class, Character.class);
+ wrapperMap.put(Character.class, char.class);
+ wrapperMap.put(byte.class, Byte.class);
+ wrapperMap.put(Byte.class, byte.class);
+ wrapperMap.put(short.class, Short.class);
+ wrapperMap.put(Short.class, short.class);
+ wrapperMap.put(long.class, Long.class);
+ wrapperMap.put(Long.class, long.class);
+ wrapperMap.put(float.class, Float.class);
+ wrapperMap.put(Float.class, float.class);
+ wrapperMap.put(double.class, Double.class);
+ wrapperMap.put(Double.class, double.class);
+ wrapperMap.put(boolean.class, Boolean.class);
+ wrapperMap.put(Boolean.class, boolean.class);
}
/**
@@ -178,7 +195,6 @@ private static int comparePrimitiveToWrapper(Class> source, Class> destinati
}
}
-
/**
* Given the passed in String class name, return the named JVM class.
* @param name String name of a JVM class.
@@ -333,5 +349,7 @@ public static Class> toPrimitiveWrapperClass(Class> primitiveClass) {
return c;
}
-
+ public static boolean doesOneWrapTheOther(Class> x, Class> y) {
+ return wrapperMap.get(x) == y;
+ }
}
diff --git a/src/main/java/com/cedarsoftware/util/convert/Converter.java b/src/main/java/com/cedarsoftware/util/convert/Converter.java
index 3349ae18..36e6f3e6 100644
--- a/src/main/java/com/cedarsoftware/util/convert/Converter.java
+++ b/src/main/java/com/cedarsoftware/util/convert/Converter.java
@@ -658,7 +658,9 @@ private static void buildFactoryConversions() {
CONVERSION_DB.put(pair(URL.class, String.class), StringConversions::toString);
CONVERSION_DB.put(pair(URI.class, String.class), StringConversions::toString);
CONVERSION_DB.put(pair(TimeZone.class, String.class), TimeZoneConversions::toString);
-
+ CONVERSION_DB.put(pair(StringBuilder.class, String.class), StringBuilderConversions::toString);
+ CONVERSION_DB.put(pair(StringBuffer.class, String.class), StringBufferConversions::toString);
+
// URL conversions
CONVERSION_DB.put(pair(Void.class, URL.class), VoidConversions::toNull);
CONVERSION_DB.put(pair(URL.class, URL.class), Converter::identity);
diff --git a/src/main/java/com/cedarsoftware/util/convert/StringBufferConversions.java b/src/main/java/com/cedarsoftware/util/convert/StringBufferConversions.java
new file mode 100644
index 00000000..6b6286c9
--- /dev/null
+++ b/src/main/java/com/cedarsoftware/util/convert/StringBufferConversions.java
@@ -0,0 +1,27 @@
+package com.cedarsoftware.util.convert;
+
+/**
+ * @author John DeRegnaucourt (jdereg@gmail.com)
+ *
+ * Copyright (c) Cedar Software LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * License
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+final class StringBufferConversions {
+
+ private StringBufferConversions() {}
+
+ static String toString(Object from, Converter converter) {
+ return from.toString();
+ }
+}
diff --git a/src/main/java/com/cedarsoftware/util/convert/StringBuilderConversions.java b/src/main/java/com/cedarsoftware/util/convert/StringBuilderConversions.java
new file mode 100644
index 00000000..d6494e59
--- /dev/null
+++ b/src/main/java/com/cedarsoftware/util/convert/StringBuilderConversions.java
@@ -0,0 +1,27 @@
+package com.cedarsoftware.util.convert;
+
+/**
+ * @author John DeRegnaucourt (jdereg@gmail.com)
+ *
+ * Copyright (c) Cedar Software LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * License
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+final class StringBuilderConversions {
+
+ private StringBuilderConversions() {}
+
+ static String toString(Object from, Converter converter) {
+ return from.toString();
+ }
+}