mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
ModifierUtil明确注释,并增加hasAllModifiers方法
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class ModifierUtilTest {
|
||||
|
||||
@Test
|
||||
@@ -16,6 +18,36 @@ public class ModifierUtilTest {
|
||||
ModifierUtil.ModifierType.STATIC)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasModifierTest2() throws NoSuchMethodException {
|
||||
Method method = ModifierUtilTest.class.getDeclaredMethod("ddd");
|
||||
assertTrue(ModifierUtil.hasModifier(method, ModifierUtil.ModifierType.PRIVATE));
|
||||
assertTrue(ModifierUtil.hasModifier(method,
|
||||
ModifierUtil.ModifierType.PRIVATE,
|
||||
ModifierUtil.ModifierType.ABSTRACT)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void issueIAQ2U0Test() throws NoSuchMethodException {
|
||||
final Method method = ModifierUtilTest.class.getDeclaredMethod("ddd");
|
||||
|
||||
Assertions.assertTrue(ModifierUtil.hasModifier(method,
|
||||
ModifierUtil.ModifierType.PRIVATE,
|
||||
ModifierUtil.ModifierType.STATIC,
|
||||
// 不存在
|
||||
ModifierUtil.ModifierType.TRANSIENT
|
||||
));
|
||||
|
||||
Assertions.assertFalse(ModifierUtil.hasAllModifiers(method,
|
||||
ModifierUtil.ModifierType.PRIVATE,
|
||||
ModifierUtil.ModifierType.STATIC,
|
||||
// 不存在
|
||||
ModifierUtil.ModifierType.TRANSIENT
|
||||
));
|
||||
}
|
||||
|
||||
private static void ddd() {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user