From 9340babe61ac79ca62eb32d40cfbcd652d1e1c56 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Sun, 6 Jun 2021 02:22:47 +0200 Subject: [PATCH] Remove unused class --- .../data/generator/CachedReflection.java | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/main/java/it/cavallium/data/generator/CachedReflection.java diff --git a/src/main/java/it/cavallium/data/generator/CachedReflection.java b/src/main/java/it/cavallium/data/generator/CachedReflection.java deleted file mode 100644 index c5f8e7a..0000000 --- a/src/main/java/it/cavallium/data/generator/CachedReflection.java +++ /dev/null @@ -1,50 +0,0 @@ -package it.cavallium.data.generator; - -import java.lang.reflect.Method; -import java.util.NoSuchElementException; -import java.util.concurrent.CompletionException; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Stream; - -public class CachedReflection { - private static ConcurrentHashMap> classes = new ConcurrentHashMap<>(); - private static ConcurrentHashMap methods = new ConcurrentHashMap<>(); - - public static Class classForName(String str) throws ClassNotFoundException { - try { - return classes.computeIfAbsent(str, (x) -> { - try { - return Class.forName(str); - } catch (ClassNotFoundException e) { - throw new CompletionException(e); - } - }); - } catch (CompletionException ex) { - var cause = ex.getCause(); - if (cause instanceof ClassNotFoundException) { - throw (ClassNotFoundException) cause; - } - throw ex; - } - } - - public static Method getDeclaredMethod(Class type, String name) throws NoSuchElementException, SecurityException { - try { - return methods.computeIfAbsent(type + "$$$" + name, (x) -> { - try { - return Stream.of(type.getDeclaredMethods()).filter(method -> method.getName().equals(name)).findAny().get(); - } catch (NoSuchElementException | SecurityException e) { - throw new CompletionException(e); - } - }); - } catch (CompletionException ex) { - var cause = ex.getCause(); - if (cause instanceof NoSuchElementException) { - throw (NoSuchElementException) cause; - } else if (cause instanceof SecurityException) { - throw (SecurityException) cause; - } - throw ex; - } - } -}