2020import java .lang .reflect .InvocationTargetException ;
2121import java .util .Map ;
2222
23+ import org .apache .commons .collections4 .map .ConcurrentReferenceHashMap ;
24+
2325/**
2426 * <p>
2527 * Utility methods for populating JavaBeans properties via reflection.
3234 *
3335 * @see BeanUtilsBean
3436 */
35-
3637public class BeanUtils {
3738
3839 /** An empty class array */
@@ -43,7 +44,7 @@ public class BeanUtils {
4344
4445 /**
4546 * <p>
46- * Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable.
47+ * Clones a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable.
4748 * </p>
4849 *
4950 * <p>
@@ -59,14 +60,12 @@ public class BeanUtils {
5960 * @see BeanUtilsBean#cloneBean
6061 */
6162 public static Object cloneBean (final Object bean ) throws IllegalAccessException , InstantiationException , InvocationTargetException , NoSuchMethodException {
62-
6363 return BeanUtilsBean .getInstance ().cloneBean (bean );
64-
6564 }
6665
6766 /**
6867 * <p>
69- * Copy property values from the origin bean to the destination bean for all cases where the property names are the same.
68+ * Copies property values from the origin bean to the destination bean for all cases where the property names are the same.
7069 * </p>
7170 *
7271 * <p>
@@ -82,7 +81,6 @@ public static Object cloneBean(final Object bean) throws IllegalAccessException,
8281 * @see BeanUtilsBean#copyProperties
8382 */
8483 public static void copyProperties (final Object dest , final Object orig ) throws IllegalAccessException , InvocationTargetException {
85-
8684 BeanUtilsBean .getInstance ().copyProperties (dest , orig );
8785 }
8886
@@ -103,20 +101,20 @@ public static void copyProperties(final Object dest, final Object orig) throws I
103101 * @see BeanUtilsBean#copyProperty
104102 */
105103 public static void copyProperty (final Object bean , final String name , final Object value ) throws IllegalAccessException , InvocationTargetException {
106-
107104 BeanUtilsBean .getInstance ().copyProperty (bean , name , value );
108105 }
109106
110107 /**
111- * Create a cache.
108+ * Creates a cache.
112109 *
113110 * @param <K> the key type of the cache
114111 * @param <V> the value type of the cache
115112 * @return a new cache
116113 * @since 1.8.0
117114 */
118115 public static <K , V > Map <K , V > createCache () {
119- return new WeakFastHashMap <>();
116+ return ConcurrentReferenceHashMap .<K , V >builder ().get ();
117+ // return new ConcurrentHashMap<>();
120118 }
121119
122120 /**
@@ -136,7 +134,6 @@ public static <K, V> Map<K, V> createCache() {
136134 * @see BeanUtilsBean#describe
137135 */
138136 public static Map <String , String > describe (final Object bean ) throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
139-
140137 return BeanUtilsBean .getInstance ().describe (bean );
141138 }
142139
@@ -159,7 +156,6 @@ public static Map<String, String> describe(final Object bean) throws IllegalAcce
159156 */
160157 public static String [] getArrayProperty (final Object bean , final String name )
161158 throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
162-
163159 return BeanUtilsBean .getInstance ().getArrayProperty (bean , name );
164160 }
165161
@@ -182,7 +178,6 @@ public static String[] getArrayProperty(final Object bean, final String name)
182178 */
183179 public static String getIndexedProperty (final Object bean , final String name )
184180 throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
185-
186181 return BeanUtilsBean .getInstance ().getIndexedProperty (bean , name );
187182
188183 }
@@ -206,7 +201,6 @@ public static String getIndexedProperty(final Object bean, final String name)
206201 */
207202 public static String getIndexedProperty (final Object bean , final String name , final int index )
208203 throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
209-
210204 return BeanUtilsBean .getInstance ().getIndexedProperty (bean , name , index );
211205
212206 }
@@ -230,7 +224,6 @@ public static String getIndexedProperty(final Object bean, final String name, fi
230224 */
231225 public static String getMappedProperty (final Object bean , final String name )
232226 throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
233-
234227 return BeanUtilsBean .getInstance ().getMappedProperty (bean , name );
235228
236229 }
@@ -255,7 +248,6 @@ public static String getMappedProperty(final Object bean, final String name)
255248 */
256249 public static String getMappedProperty (final Object bean , final String name , final String key )
257250 throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
258-
259251 return BeanUtilsBean .getInstance ().getMappedProperty (bean , name , key );
260252
261253 }
@@ -280,7 +272,6 @@ public static String getMappedProperty(final Object bean, final String name, fin
280272 */
281273 public static String getNestedProperty (final Object bean , final String name )
282274 throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
283-
284275 return BeanUtilsBean .getInstance ().getNestedProperty (bean , name );
285276
286277 }
@@ -303,7 +294,6 @@ public static String getNestedProperty(final Object bean, final String name)
303294 * @see BeanUtilsBean#getProperty
304295 */
305296 public static String getProperty (final Object bean , final String name ) throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
306-
307297 return BeanUtilsBean .getInstance ().getProperty (bean , name );
308298
309299 }
@@ -327,7 +317,6 @@ public static String getProperty(final Object bean, final String name) throws Il
327317 */
328318 public static String getSimpleProperty (final Object bean , final String name )
329319 throws IllegalAccessException , InvocationTargetException , NoSuchMethodException {
330-
331320 return BeanUtilsBean .getInstance ().getSimpleProperty (bean , name );
332321
333322 }
@@ -348,7 +337,6 @@ public static String getSimpleProperty(final Object bean, final String name)
348337 * @see BeanUtilsBean#populate
349338 */
350339 public static void populate (final Object bean , final Map <String , ? extends Object > properties ) throws IllegalAccessException , InvocationTargetException {
351-
352340 BeanUtilsBean .getInstance ().populate (bean , properties );
353341 }
354342
@@ -369,7 +357,6 @@ public static void populate(final Object bean, final Map<String, ? extends Objec
369357 * @see BeanUtilsBean#setProperty
370358 */
371359 public static void setProperty (final Object bean , final String name , final Object value ) throws IllegalAccessException , InvocationTargetException {
372-
373360 BeanUtilsBean .getInstance ().setProperty (bean , name , value );
374361 }
375362}
0 commit comments