Class ModifierUtil
java.lang.Object
cloud.opencode.base.core.reflect.ModifierUtil
Modifier Utility Class - Java modifier checking operations
修饰符工具类 - Java 修饰符检查操作
Provides utilities for checking Java modifiers on classes, methods, and fields.
提供类、方法和字段的 Java 修饰符检查工具。
Features | 主要功能:
- Access modifiers (public, private, protected, package) - 访问修饰符
- Class modifiers (abstract, final, interface) - 类修饰符
- Member modifiers (static, final, volatile, transient) - 成员修饰符
- Method modifiers (synchronized, native, strict) - 方法修饰符
Usage Examples | 使用示例:
// Check access modifier - 检查访问修饰符
boolean isPub = ModifierUtil.isPublic(field);
// Check class modifier - 检查类修饰符
boolean isAbstract = ModifierUtil.isAbstract(MyClass.class);
// Get modifier string - 获取修饰符字符串
String modStr = ModifierUtil.toString(method);
Security | 安全性:
- Thread-safe: Yes (stateless) - 线程安全: 是 (无状态)
- Null-safe: No - 空值安全: 否
Performance | 性能特性:
- Time complexity: O(1) per check - 每次检查 O(1)
- Space complexity: O(1) - O(1)
- Since:
- JDK 25, opencode-base-core V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisAbstract(int modifiers) Checks if the modifier is abstract 检查是否为 abstractstatic booleanisAbstract(Class<?> clazz) Checks if the modifier is abstract 检查是否为 abstractstatic booleanisFinal(int modifiers) Checks if the modifier is final 检查是否为 finalstatic booleanChecks if the modifier is final 检查是否为 finalstatic booleanChecks if the modifier is final 检查是否为 finalstatic booleanisInterface(int modifiers) Checks if the modifier is interface 检查是否为 interfacestatic booleanisInterface(Class<?> clazz) Checks if the modifier is interface 检查是否为 interfacestatic booleanisNative(int modifiers) Checks if the modifier is native 检查是否为 nativestatic booleanisPackagePrivate(int modifiers) Checks if the modifier is package-private (no access modifier) 检查是否为包可见(无访问修饰符)static booleanisPackagePrivate(Member member) Checks if the modifier is package-private 检查是否为包可见static booleanisPrivate(int modifiers) Checks if the modifier is private 检查是否为 privatestatic booleanChecks if the modifier is private 检查是否为 privatestatic booleanisProtected(int modifiers) Checks if the modifier is protected 检查是否为 protectedstatic booleanisProtected(Member member) Checks if the modifier is protected 检查是否为 protectedstatic booleanisPublic(int modifiers) Checks if the modifier is public 检查是否为 publicstatic booleanChecks if the modifier is public 检查是否为 publicstatic booleanChecks if the modifier is public 检查是否为 publicstatic booleanisStatic(int modifiers) Checks if the modifier is static 检查是否为 staticstatic booleanChecks if the modifier is static 检查是否为 staticstatic booleanisStrict(int modifiers) Checks if the modifier is strict (strictfp) 检查是否为 strict (strictfp)static booleanisSynchronized(int modifiers) Checks if the modifier is synchronized 检查是否为 synchronizedstatic booleanisTransient(int modifiers) Checks if the modifier is transient 检查是否为 transientstatic booleanisVolatile(int modifiers) Checks if the modifier is volatile 检查是否为 volatilestatic StringtoString(int modifiers) Gets the string representation of the modifiers 获取修饰符字符串表示static StringGets the modifier string of a class 获取类的修饰符字符串static StringGets the modifier string of a member 获取成员的修饰符字符串
-
Method Details
-
isPublic
public static boolean isPublic(int modifiers) Checks if the modifier is public 检查是否为 public -
isPublic
Checks if the modifier is public 检查是否为 public -
isPublic
Checks if the modifier is public 检查是否为 public -
isPrivate
public static boolean isPrivate(int modifiers) Checks if the modifier is private 检查是否为 private -
isPrivate
Checks if the modifier is private 检查是否为 private -
isProtected
public static boolean isProtected(int modifiers) Checks if the modifier is protected 检查是否为 protected -
isProtected
Checks if the modifier is protected 检查是否为 protected -
isStatic
public static boolean isStatic(int modifiers) Checks if the modifier is static 检查是否为 static -
isStatic
Checks if the modifier is static 检查是否为 static -
isFinal
public static boolean isFinal(int modifiers) Checks if the modifier is final 检查是否为 final -
isFinal
Checks if the modifier is final 检查是否为 final -
isFinal
Checks if the modifier is final 检查是否为 final -
isSynchronized
public static boolean isSynchronized(int modifiers) Checks if the modifier is synchronized 检查是否为 synchronized -
isVolatile
public static boolean isVolatile(int modifiers) Checks if the modifier is volatile 检查是否为 volatile -
isTransient
public static boolean isTransient(int modifiers) Checks if the modifier is transient 检查是否为 transient -
isNative
public static boolean isNative(int modifiers) Checks if the modifier is native 检查是否为 native -
isInterface
public static boolean isInterface(int modifiers) Checks if the modifier is interface 检查是否为 interface -
isInterface
Checks if the modifier is interface 检查是否为 interface -
isAbstract
public static boolean isAbstract(int modifiers) Checks if the modifier is abstract 检查是否为 abstract -
isAbstract
Checks if the modifier is abstract 检查是否为 abstract -
isStrict
public static boolean isStrict(int modifiers) Checks if the modifier is strict (strictfp) 检查是否为 strict (strictfp) -
isPackagePrivate
public static boolean isPackagePrivate(int modifiers) Checks if the modifier is package-private (no access modifier) 检查是否为包可见(无访问修饰符) -
isPackagePrivate
Checks if the modifier is package-private 检查是否为包可见 -
toString
Gets the string representation of the modifiers 获取修饰符字符串表示 -
toString
-
toString
-