77
88import java .lang .reflect .ParameterizedType ;
99import java .util .Arrays ;
10- import java .util .HashMap ;
11- import java .util .Map ;
1210
1311
1412public class ControllerUtils {
1513
1614 private static final String FINALIZER_NAME_SUFFIX = "/finalizer" ;
1715
18- // this is just to support testing, this way we don't try to create class multiple times in memory with same name.
19- // note that other solution is to add a random string to doneable class name
20- private static Map <Class <? extends CustomResource >, Class <? extends CustomResourceDoneable <? extends CustomResource >>>
21- doneableClassCache = new HashMap <>();
22-
2316 static String getFinalizer (ResourceController controller ) {
2417 final String annotationFinalizerName = getAnnotation (controller ).finalizerName ();
2518 if (!Controller .NULL .equals (annotationFinalizerName )) {
2619 return annotationFinalizerName ;
2720 }
28- final String crdName = getAnnotation (controller ).crdName () + FINALIZER_NAME_SUFFIX ;
29- return crdName ;
21+ return getAnnotation (controller ).crdName () + FINALIZER_NAME_SUFFIX ;
3022 }
3123
32- static boolean getGenerationEventProcessing (ResourceController controller ) {
24+ static boolean getGenerationEventProcessing (ResourceController <?> controller ) {
3325 return getAnnotation (controller ).generationAwareEventProcessing ();
3426 }
3527
3628 static <R extends CustomResource > Class <R > getCustomResourceClass (ResourceController <R > controller ) {
37- final Class < R > type = Arrays
29+ return Arrays
3830 .stream (controller .getClass ().getGenericInterfaces ())
3931 .filter (i -> i instanceof ParameterizedType )
4032 .map (i -> (ParameterizedType ) i )
4133 .findFirst ()
4234 .map (i -> (Class <R >) i .getActualTypeArguments ()[0 ])
4335 .get ();
44- return type ;
4536 }
4637
4738 static String getCrdName (ResourceController controller ) {
@@ -60,7 +51,7 @@ static String getCrdName(ResourceController controller) {
6051 }
6152 }
6253
63- private static Controller getAnnotation (ResourceController controller ) {
54+ private static Controller getAnnotation (ResourceController <?> controller ) {
6455 return controller .getClass ().getAnnotation (Controller .class );
6556 }
6657
0 commit comments