Enum JModifier
- java.lang.Object
-
- java.lang.Enum<JModifier>
-
- net.sourceforge.pmd.lang.java.ast.JModifier
-
- All Implemented Interfaces:
Serializable
,Comparable<JModifier>
public enum JModifier extends Enum<JModifier>
A Java modifier. The ordering of constants respects the ordering recommended by the JLS.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static @NonNull JModifier
fromToken(@NonNull String token)
Gets a modifier from its name.int
getReflectMod()
Returns the constant of java.lang.reflect.Modifier that this modifier corresponds to.String
getToken()
Returns how the modifier is written in source.static int
toReflect(Collection<JModifier> mods)
String
toString()
static JModifier
valueOf(String name)
Returns the enum constant of this type with the specified name.static JModifier[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
PUBLIC
public static final JModifier PUBLIC
-
PROTECTED
public static final JModifier PROTECTED
-
PRIVATE
public static final JModifier PRIVATE
-
SEALED
public static final JModifier SEALED
Modifier"sealed"
(since Java 17).
-
NON_SEALED
public static final JModifier NON_SEALED
Modifier"non-sealed"
(since Java 17).
-
ABSTRACT
public static final JModifier ABSTRACT
-
STATIC
public static final JModifier STATIC
-
FINAL
public static final JModifier FINAL
-
SYNCHRONIZED
public static final JModifier SYNCHRONIZED
-
NATIVE
public static final JModifier NATIVE
-
DEFAULT
public static final JModifier DEFAULT
-
STRICTFP
public static final JModifier STRICTFP
-
TRANSIENT
public static final JModifier TRANSIENT
-
VOLATILE
public static final JModifier VOLATILE
-
-
Method Detail
-
values
public static JModifier[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (JModifier c : JModifier.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static JModifier valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getReflectMod
public int getReflectMod()
Returns the constant of java.lang.reflect.Modifier that this modifier corresponds to. Be aware that the following constants are source-level modifiers only, for which this method returns 0:DEFAULT
: this doesn't exist at the class file level. A default method is a non-static non-abstract public method declared in an interface (JExecutableSymbol.isDefaultMethod()
.SEALED
: a sealed class has an attributePermittedSubclasses
with a non-zero length (in the compiled class file). (JClassSymbol.isSealed()
)NON_SEALED
: this doesn't exist at the class file level at all. But a class must have the non-sealed modifier in source if it is neither sealed, nor final, and appears in thePermittedSubclasses
attribute of some direct supertype.
-
getToken
public String getToken()
Returns how the modifier is written in source.
-
toReflect
public static int toReflect(Collection<JModifier> mods)
-
fromToken
public static @NonNull JModifier fromToken(@NonNull String token)
Gets a modifier from its name.- Throws:
IllegalArgumentException
- if the name is incorrect
-
-