@@ -255,19 +255,91 @@ static public Optional<Method> findDeclaredMethod(
255255 }
256256
257257
258+ static public void testMethod (
259+ String pkg , String className ,
260+ String methodName , List <Class <?>> parameterTypes ,
261+ Runnable fn
262+ ) {
263+ Utilities .testMethod (FQCN (pkg , className ), methodName , parameterTypes , fn );
264+ }
265+
266+ static public void testMethod (
267+ String fullyQualifiedClassName ,
268+ String methodName , List <Class <?>> parameterTypes ,
269+ Runnable fn
270+ ) {
271+ var classObject = findClass (fullyQualifiedClassName );
272+
273+ if (classObject .isEmpty ()) {
274+ Utilities .throwClassNotFound (fullyQualifiedClassName );
275+ }
276+
277+ Utilities .testMethod (classObject .get (), methodName , parameterTypes , fn );
278+ }
279+
280+ static public void testMethod (Class <?> classObject , String methodName , List <Class <?>> parameterTypes , Runnable fn ) {
281+ Utilities .findMethod (classObject , methodName , parameterTypes .toArray (new Class [0 ])).ifPresent (
282+ method -> Utilities .testMethod (method , fn )
283+ );
284+ }
285+
258286 /** Scoped CLASS */
259287 static public void testMethod (String methodName , List <Class <?>> parameterTypes , Runnable fn ) {
260288 Utilities .findMethod (CLASS .get (), methodName , parameterTypes .toArray (new Class [0 ])).ifPresent (
261289 method -> Utilities .testMethod (method , fn )
262290 );
263291 }
264292
265- /** Scoped METHOD */
266293 static public void testMethod (Method methodObject , Runnable fn ) {
267294 where (Utilities .METHOD , methodObject ).run (fn );
268295 }
269296
270297
298+ static public void testDeclaredMethod (
299+ String pkg , String className ,
300+ String methodName , List <Class <?>> parameterTypes ,
301+ Runnable fn
302+ ) {
303+ Utilities .testDeclaredMethod (FQCN (pkg , className ), methodName , parameterTypes , fn );
304+ }
305+
306+ static public void testDeclaredMethod (
307+ String fullyQualifiedClassName ,
308+ String methodName , List <Class <?>> parameterTypes ,
309+ Runnable fn
310+ ) {
311+ var classObject = findClass (fullyQualifiedClassName );
312+
313+ if (classObject .isEmpty ()) {
314+ Utilities .throwClassNotFound (fullyQualifiedClassName );
315+ }
316+
317+ Utilities .testDeclaredMethod (classObject .get (), methodName , parameterTypes , fn );
318+ }
319+
320+ static public void testDeclaredMethod (
321+ Class <?> classObject ,
322+ String methodName , List <Class <?>> parameters ,
323+ Runnable fn
324+ ) {
325+ var parameterTypes = parameters .toArray (new Class [0 ]);
326+ var methodObject = Utilities .findMethod (classObject , methodName , parameterTypes );
327+
328+ if (methodObject .isEmpty ()) {
329+ Utilities .throwClassMethodNotFound (classObject .getName (), methodName , parameterTypes );
330+ }
331+
332+ Utilities .testMethod (methodObject .get (), fn );
333+ }
334+
335+ /** Scoped CLASS */
336+ static public void testDeclaredMethod (String methodName , List <Class <?>> parameterTypes , Runnable fn ) {
337+ Utilities .findDeclaredMethod (CLASS .get (), methodName , parameterTypes .toArray (new Class [0 ])).ifPresent (
338+ method -> Utilities .testMethod (method , fn )
339+ );
340+ }
341+
342+
271343 static public void testClassMethod (
272344 String pkg , String className ,
273345 String methodName ,
@@ -286,7 +358,7 @@ static public void testClassMethod(
286358
287359 static public void testClassMethod (
288360 String fullyQualifiedClassName ,
289- String methodName , List <Class <?>> parameterTypes ,
361+ String methodName , List <Class <?>> parameters ,
290362 Runnable fn
291363 ) {
292364 var classOptional = Utilities .findClass (fullyQualifiedClassName );
@@ -296,11 +368,11 @@ static public void testClassMethod(
296368 }
297369
298370 where (Utilities .CLASS , classOptional .get ()).run (() -> {
299- var parameters = parameterTypes .toArray (new Class [0 ]);
300- var methodOptional = Utilities .findMethod (CLASS .get (), methodName , parameters );
371+ var parameterTypes = parameters .toArray (new Class [0 ]);
372+ var methodOptional = Utilities .findMethod (CLASS .get (), methodName , parameterTypes );
301373
302374 if (methodOptional .isEmpty ()) {
303- Utilities .throwClassMethodNotFound (fullyQualifiedClassName , methodName , parameters );
375+ Utilities .throwClassMethodNotFound (fullyQualifiedClassName , methodName , parameterTypes );
304376 }
305377
306378 where (Utilities .METHOD , methodOptional .get ()).run (fn );
@@ -518,6 +590,36 @@ static public void testField(Field fieldObject, Runnable fn) {
518590 }
519591
520592
593+ static public void testDeclaredField (String pkg , String className , String fieldName , Runnable fn ) {
594+ Utilities .testDeclaredField (FQCN (pkg , className ), fieldName , fn );
595+ }
596+
597+ static public void testDeclaredField (String fullyQualifiedClassName , String fieldName , Runnable fn ) {
598+ var classObject = Utilities .findClass (fullyQualifiedClassName );
599+
600+ if (classObject .isEmpty ()) {
601+ Utilities .throwClassNotFound (fullyQualifiedClassName );
602+ }
603+
604+ Utilities .testDeclaredField (classObject .get (), fieldName , fn );
605+ }
606+
607+ /** Scoped CLASS */
608+ static public void testDeclaredField (String fieldName , Runnable fn ) {
609+ Utilities .testDeclaredField (CLASS .get (), fieldName , fn );
610+ }
611+
612+ static public void testDeclaredField (Class <?> classObject , String fieldName , Runnable fn ) {
613+ var fieldObject = findField (classObject , fieldName );
614+
615+ if (fieldObject .isEmpty ()) {
616+ Utilities .throwClassFieldNotFound (classObject .getName (), fieldName );
617+ }
618+
619+ Utilities .testField (fieldObject .get (), fn );
620+ }
621+
622+
521623 static public void testClassField (String pkg , String className , String fieldName , Runnable fn ) {
522624 Utilities .testClassField (FQCN (pkg , className ), fieldName , fn );
523625 }
@@ -712,6 +814,7 @@ static private void throwClassFieldNotFound(String fullyQualifiedClassName, Stri
712814 }
713815
714816
817+
715818 ///-----------------------------------------------------------------------------------------------------------------
716819 ///# Note: Private constructor; prevent instantiation of this class as it strictly contains static helper methods
717820 private Utilities () {}
0 commit comments