Skip to content

Commit 35aabc5

Browse files
committed
Re-order and mark scoped methods
1 parent ac7e7d0 commit 35aabc5

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

src/test/java/assignment/testing/framework/Utilities.java

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ static public boolean methodReturns(
168168
var methodObject = Utilities.findMethod(fullyQualifiedClassName, methodName, parameterTypes.toArray(new Class[0]));
169169

170170
return methodObject.map(method -> method.getReturnType().equals(returnType)).orElse(false);
171-
172171
}
173172

174173
static public boolean methodReturns(Method methodObject, Class<?> returnType) {
@@ -233,6 +232,7 @@ static public boolean fieldExists(String fullyQualifiedClassName, String fieldNa
233232
return Utilities.findField(fullyQualifiedClassName, fieldName).isPresent();
234233
}
235234

235+
236236
public String fieldType(Type type) {
237237
if (type instanceof ParameterizedType parameterizedType) {
238238
return fieldParameterizedType(parameterizedType);
@@ -242,6 +242,7 @@ public String fieldType(Type type) {
242242
}
243243
}
244244

245+
245246
public String fieldParameterizedType(ParameterizedType type) {
246247
StringBuilder output = new StringBuilder();
247248

@@ -368,20 +369,22 @@ static public void testClassMethod(
368369
});
369370
}
370371

372+
371373
//__________________________________________________________________________________________________________________
372374
//### Scoped method
373-
/** SCOPED CLASS */
375+
/** Scoped CLASS */
374376
static public void testMethod(String methodName, List<Class<?>> parameterTypes, Runnable fn) {
375377
Utilities.findMethod(CLASS.get(), methodName, parameterTypes.toArray(new Class[0])).ifPresent(
376378
method -> Utilities.testMethod(method, fn)
377379
);
378380
}
379381

380-
/** SCOPED METHOD */
382+
/** Scoped METHOD */
381383
static public void testMethod(Method methodObject, Runnable fn) {
382384
where(Utilities.METHOD, methodObject).run(fn);
383385
}
384386

387+
385388
//__________________________________________________________________________________________________________________
386389
//### Scoped field
387390
static public void testField(
@@ -403,6 +406,10 @@ static public void testField(
403406
});
404407
}
405408

409+
static public void testField(String fieldName, Runnable fn) {
410+
Utilities.testField(CLASS.get(), fieldName, fn);
411+
}
412+
406413
static public void testField(Class<?> classObject, String fieldName, Runnable fn) {
407414
Utilities.findField(classObject, fieldName).ifPresent(field -> Utilities.testField(field, fn));
408415
}
@@ -414,7 +421,7 @@ static public void testField(Field fieldObject, Runnable fn) {
414421

415422
//------------------------------------------------------------------------------------------------------------------
416423
//## Classes
417-
/** SCOPED CLASS */
424+
/** Scoped CLASS */
418425
static public boolean classInheritsFrom(Class<?> classObject) {
419426
var superClass = CLASS.get().getSuperclass();
420427

@@ -429,7 +436,7 @@ static public boolean classInheritsFrom(Class<?> classObject) {
429436
return false;
430437
}
431438

432-
/** SCOPED CLASS */
439+
/** Scoped CLASS */
433440
static public Object classCreateInstance(Object... parameterValues) {
434441
return Utilities.classCreateInstance(CLASS.get(), parameterValues);
435442
}
@@ -450,6 +457,7 @@ static public Object classCreateInstance(Class<?> classObject, Object... paramet
450457
}
451458
}
452459

460+
/** Scoped CLASS */
453461
static public void classInstanceInvokeMethod(Object instance, String methodName, Object... parameterValues) {
454462
var signature = Arrays.stream(parameterValues).map(Object::getClass).toArray();
455463

@@ -469,41 +477,48 @@ static public void classInstanceInvokeMethod(Object instance, String methodName,
469477

470478
//------------------------------------------------------------------------------------------------------------------
471479
//## Methods
472-
/** SCOPED CLASS+METHOD */
480+
/** Scoped CLASS+METHOD */
473481
static public boolean methodReturns(Class<?> returnType) {
474482
return Utilities.methodReturns(METHOD.get(), returnType);
475483
}
476484

477-
/** SCOPED CLASS */
485+
/** Scoped CLASS */
478486
static public boolean methodExists(String method, Class<?>... parameterTypes) {
479487
return findMethod(CLASS.get(), method, parameterTypes).isPresent();
480488
}
481489

482490

491+
/** Scoped METHOD */
483492
static public boolean methodIsPublic() {
484493
return (METHOD.get().getModifiers() & Modifier.PUBLIC) != 0;
485494
}
486495

496+
/** Scoped METHOD */
487497
static public boolean methodIsProtected() {
488498
return (METHOD.get().getModifiers() & Modifier.PROTECTED) != 0;
489499
}
490500

501+
/** Scoped METHOD */
491502
static public boolean methodIsPrivate() {
492503
return (METHOD.get().getModifiers() & Modifier.PRIVATE) != 0;
493504
}
494505

506+
/** Scoped METHOD */
495507
static public boolean methodIsAbstract() {
496508
return (METHOD.get().getModifiers() & Modifier.ABSTRACT) != 0;
497509
}
498510

511+
/** Scoped METHOD */
499512
static public boolean methodIsStatic() {
500513
return (METHOD.get().getModifiers() & Modifier.STATIC) != 0;
501514
}
502515

516+
/** Scoped METHOD */
503517
static public boolean methodIsFinal() {
504518
return (METHOD.get().getModifiers() & Modifier.FINAL) != 0;
505519
}
506520

521+
/** Scoped METHOD */
507522
static public boolean methodHasModifiers(AccessFlag... flags) {
508523
return Utilities.methodHasModifiers(METHOD.get(), flags);
509524
}
@@ -523,26 +538,32 @@ static public boolean methodHasModifiers(Method methodObject, AccessFlag... flag
523538

524539
//------------------------------------------------------------------------------------------------------------------
525540
//## Fields
541+
/** Scoped FIELD */
526542
static public boolean fieldIsPublic() {
527543
return (FIELD.get().getModifiers() & Modifier.PUBLIC) != 0;
528544
}
529545

546+
/** Scoped FIELD */
530547
static public boolean fieldIsProtected() {
531548
return (FIELD.get().getModifiers() & Modifier.PROTECTED) != 0;
532549
}
533550

551+
/** Scoped FIELD */
534552
static public boolean fieldIsPrivate() {
535553
return (FIELD.get().getModifiers() & Modifier.PRIVATE) != 0;
536554
}
537555

556+
/** Scoped FIELD */
538557
static public boolean fieldIsStatic() {
539558
return (FIELD.get().getModifiers() & Modifier.STATIC) != 0;
540559
}
541560

561+
/** Scoped FIELD */
542562
static public boolean fieldIsFinal() {
543563
return (FIELD.get().getModifiers() & Modifier.FINAL) != 0;
544564
}
545565

566+
/** Scoped FIELD */
546567
static public boolean fieldHasModifiers(AccessFlag... flags) {
547568
return Utilities.fieldHasModifiers(FIELD.get(), flags);
548569
}

0 commit comments

Comments
 (0)