Polish
This commit is contained in:
parent
c809fda4ed
commit
86e02a47fb
|
|
@ -394,22 +394,25 @@ class ClassUtilsTests {
|
||||||
@Test
|
@Test
|
||||||
void getMostSpecificMethod() throws NoSuchMethodException {
|
void getMostSpecificMethod() throws NoSuchMethodException {
|
||||||
Method defaultPrintMethod = ClassUtils.getMethod(MethodsInterface.class, "defaultPrint");
|
Method defaultPrintMethod = ClassUtils.getMethod(MethodsInterface.class, "defaultPrint");
|
||||||
assertThat(ClassUtils.getMostSpecificMethod(defaultPrintMethod, MethodsInterfaceImplementation.class)).isEqualTo(defaultPrintMethod);
|
assertThat(ClassUtils.getMostSpecificMethod(defaultPrintMethod, MethodsInterfaceImplementation.class))
|
||||||
assertThat(ClassUtils.getMostSpecificMethod(defaultPrintMethod, SubMethodsInterfaceImplementation.class)).isEqualTo(defaultPrintMethod);
|
.isEqualTo(defaultPrintMethod);
|
||||||
|
assertThat(ClassUtils.getMostSpecificMethod(defaultPrintMethod, SubMethodsInterfaceImplementation.class))
|
||||||
|
.isEqualTo(defaultPrintMethod);
|
||||||
|
|
||||||
Method printMethod = ClassUtils.getMethod(MethodsInterface.class, "print", String.class);
|
Method printMethod = ClassUtils.getMethod(MethodsInterface.class, "print", String.class);
|
||||||
assertThat(ClassUtils.getMostSpecificMethod(printMethod, MethodsInterfaceImplementation.class)).isNotEqualTo(printMethod);
|
assertThat(ClassUtils.getMostSpecificMethod(printMethod, MethodsInterfaceImplementation.class))
|
||||||
|
.isNotEqualTo(printMethod);
|
||||||
assertThat(ClassUtils.getMostSpecificMethod(printMethod, MethodsInterfaceImplementation.class))
|
assertThat(ClassUtils.getMostSpecificMethod(printMethod, MethodsInterfaceImplementation.class))
|
||||||
.isEqualTo(ClassUtils.getMethod(MethodsInterfaceImplementation.class, "print", String.class));
|
.isEqualTo(ClassUtils.getMethod(MethodsInterfaceImplementation.class, "print", String.class));
|
||||||
assertThat(ClassUtils.getMostSpecificMethod(printMethod, SubMethodsInterfaceImplementation.class))
|
assertThat(ClassUtils.getMostSpecificMethod(printMethod, SubMethodsInterfaceImplementation.class))
|
||||||
.isEqualTo(ClassUtils.getMethod(MethodsInterfaceImplementation.class, "print", String.class));
|
.isEqualTo(ClassUtils.getMethod(MethodsInterfaceImplementation.class, "print", String.class));
|
||||||
|
|
||||||
Method protectedPrintMethod = MethodsInterfaceImplementation.class.getDeclaredMethod("protectedPrint");
|
Method protectedPrintMethod = MethodsInterfaceImplementation.class.getDeclaredMethod("protectedPrint");
|
||||||
assertThat(ClassUtils.getMostSpecificMethod(protectedPrintMethod, MethodsInterfaceImplementation.class)).isEqualTo(protectedPrintMethod);
|
assertThat(ClassUtils.getMostSpecificMethod(protectedPrintMethod, MethodsInterfaceImplementation.class))
|
||||||
|
.isEqualTo(protectedPrintMethod);
|
||||||
assertThat(ClassUtils.getMostSpecificMethod(protectedPrintMethod, SubMethodsInterfaceImplementation.class))
|
assertThat(ClassUtils.getMostSpecificMethod(protectedPrintMethod, SubMethodsInterfaceImplementation.class))
|
||||||
.isEqualTo(SubMethodsInterfaceImplementation.class.getDeclaredMethod("protectedPrint"));
|
.isEqualTo(SubMethodsInterfaceImplementation.class.getDeclaredMethod("protectedPrint"));
|
||||||
|
|
||||||
|
|
||||||
Method packageAccessiblePrintMethod = MethodsInterfaceImplementation.class.getDeclaredMethod("packageAccessiblePrint");
|
Method packageAccessiblePrintMethod = MethodsInterfaceImplementation.class.getDeclaredMethod("packageAccessiblePrint");
|
||||||
assertThat(ClassUtils.getMostSpecificMethod(packageAccessiblePrintMethod, MethodsInterfaceImplementation.class))
|
assertThat(ClassUtils.getMostSpecificMethod(packageAccessiblePrintMethod, MethodsInterfaceImplementation.class))
|
||||||
.isEqualTo(packageAccessiblePrintMethod);
|
.isEqualTo(packageAccessiblePrintMethod);
|
||||||
|
|
@ -585,40 +588,41 @@ class ClassUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private interface MethodsInterface{
|
private interface MethodsInterface {
|
||||||
|
|
||||||
default void defaultPrint(){
|
default void defaultPrint() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(String messages);
|
void print(String messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private class MethodsInterfaceImplementation implements MethodsInterface{
|
private class MethodsInterfaceImplementation implements MethodsInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void print(String message) {
|
public void print(String message) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void protectedPrint(){
|
protected void protectedPrint() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void packageAccessiblePrint(){
|
void packageAccessiblePrint() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private class SubMethodsInterfaceImplementation extends MethodsInterfaceImplementation{
|
private class SubMethodsInterfaceImplementation extends MethodsInterfaceImplementation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void protectedPrint(){
|
protected void protectedPrint() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packageAccessiblePrint(){
|
public void packageAccessiblePrint() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue