Class ModifierUtil

java.lang.Object
cloud.opencode.base.core.reflect.ModifierUtil

public final class ModifierUtil extends Object
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 Type
    Method
    Description
    static boolean
    isAbstract(int modifiers)
    Checks if the modifier is abstract 检查是否为 abstract
    static boolean
    isAbstract(Class<?> clazz)
    Checks if the modifier is abstract 检查是否为 abstract
    static boolean
    isFinal(int modifiers)
    Checks if the modifier is final 检查是否为 final
    static boolean
    isFinal(Class<?> clazz)
    Checks if the modifier is final 检查是否为 final
    static boolean
    isFinal(Member member)
    Checks if the modifier is final 检查是否为 final
    static boolean
    isInterface(int modifiers)
    Checks if the modifier is interface 检查是否为 interface
    static boolean
    isInterface(Class<?> clazz)
    Checks if the modifier is interface 检查是否为 interface
    static boolean
    isNative(int modifiers)
    Checks if the modifier is native 检查是否为 native
    static boolean
    isPackagePrivate(int modifiers)
    Checks if the modifier is package-private (no access modifier) 检查是否为包可见(无访问修饰符)
    static boolean
    Checks if the modifier is package-private 检查是否为包可见
    static boolean
    isPrivate(int modifiers)
    Checks if the modifier is private 检查是否为 private
    static boolean
    isPrivate(Member member)
    Checks if the modifier is private 检查是否为 private
    static boolean
    isProtected(int modifiers)
    Checks if the modifier is protected 检查是否为 protected
    static boolean
    Checks if the modifier is protected 检查是否为 protected
    static boolean
    isPublic(int modifiers)
    Checks if the modifier is public 检查是否为 public
    static boolean
    isPublic(Class<?> clazz)
    Checks if the modifier is public 检查是否为 public
    static boolean
    isPublic(Member member)
    Checks if the modifier is public 检查是否为 public
    static boolean
    isStatic(int modifiers)
    Checks if the modifier is static 检查是否为 static
    static boolean
    isStatic(Member member)
    Checks if the modifier is static 检查是否为 static
    static boolean
    isStrict(int modifiers)
    Checks if the modifier is strict (strictfp) 检查是否为 strict (strictfp)
    static boolean
    isSynchronized(int modifiers)
    Checks if the modifier is synchronized 检查是否为 synchronized
    static boolean
    isTransient(int modifiers)
    Checks if the modifier is transient 检查是否为 transient
    static boolean
    isVolatile(int modifiers)
    Checks if the modifier is volatile 检查是否为 volatile
    static String
    toString(int modifiers)
    Gets the string representation of the modifiers 获取修饰符字符串表示
    static String
    toString(Class<?> clazz)
    Gets the modifier string of a class 获取类的修饰符字符串
    static String
    toString(Member member)
    Gets the modifier string of a member 获取成员的修饰符字符串

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isPublic

      public static boolean isPublic(int modifiers)
      Checks if the modifier is public 检查是否为 public
    • isPublic

      public static boolean isPublic(Member member)
      Checks if the modifier is public 检查是否为 public
    • isPublic

      public static boolean isPublic(Class<?> clazz)
      Checks if the modifier is public 检查是否为 public
    • isPrivate

      public static boolean isPrivate(int modifiers)
      Checks if the modifier is private 检查是否为 private
    • isPrivate

      public static boolean isPrivate(Member member)
      Checks if the modifier is private 检查是否为 private
    • isProtected

      public static boolean isProtected(int modifiers)
      Checks if the modifier is protected 检查是否为 protected
    • isProtected

      public static boolean isProtected(Member member)
      Checks if the modifier is protected 检查是否为 protected
    • isStatic

      public static boolean isStatic(int modifiers)
      Checks if the modifier is static 检查是否为 static
    • isStatic

      public static boolean isStatic(Member member)
      Checks if the modifier is static 检查是否为 static
    • isFinal

      public static boolean isFinal(int modifiers)
      Checks if the modifier is final 检查是否为 final
    • isFinal

      public static boolean isFinal(Member member)
      Checks if the modifier is final 检查是否为 final
    • isFinal

      public static boolean isFinal(Class<?> clazz)
      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

      public static boolean isInterface(Class<?> clazz)
      Checks if the modifier is interface 检查是否为 interface
    • isAbstract

      public static boolean isAbstract(int modifiers)
      Checks if the modifier is abstract 检查是否为 abstract
    • isAbstract

      public static boolean isAbstract(Class<?> clazz)
      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

      public static boolean isPackagePrivate(Member member)
      Checks if the modifier is package-private 检查是否为包可见
    • toString

      public static String toString(int modifiers)
      Gets the string representation of the modifiers 获取修饰符字符串表示
    • toString

      public static String toString(Class<?> clazz)
      Gets the modifier string of a class 获取类的修饰符字符串
    • toString

      public static String toString(Member member)
      Gets the modifier string of a member 获取成员的修饰符字符串