(String value, Class type)
| 306 | static Map<Class, Map<String, Object>> enumCache = new HashMap<>(); |
| 307 | |
| 308 | @SuppressWarnings("all") |
| 309 | public static Object findClosestEnumConstant(String value, Class type) { |
| 310 | Map<String, Object> enumConstants = enumCache.get(type); |
| 311 | if (enumConstants == null) { |
| 312 | Object[] constants = type.getEnumConstants(); |
| 313 | enumConstants = new HashMap<>(); |
| 314 | for (Object o : constants) { |
| 315 | enumConstants.put(o.toString(), o); |
| 316 | } |
| 317 | enumCache.put(type, enumConstants); |
| 318 | } |
| 319 | |
| 320 | String key = findBestMatch(value, enumConstants.keySet()); |
| 321 | if (key == null) { |
| 322 | return null; |
| 323 | } |
| 324 | return enumConstants.get(key); |
| 325 | } |
| 326 | |
| 327 | @SuppressWarnings("all") |
| 328 | public static Object deserializeString(String value, Class type, boolean hex) { |
no test coverage detected