Modifier (Java SE 10 & JDK 10 )
- java.lang.Object
-
- java.lang.reflect.Modifier
-
public class Modifier extends Object
The Modifier class provides
staticmethods and constants to decode class and member access modifiers. The sets of modifiers are represented as integers with distinct bit positions representing different modifiers. The values for the constants representing the modifiers are taken from the tables in sections 4.1, 4.4, 4.5, and 4.7 of The Java™ Virtual Machine Specification.- Since:
- 1.1
- See Also:
Class.getModifiers(),Member.getModifiers()
-
-
Field Summary
Fields Modifier and Type Field Description static intABSTRACTThe
intvalue representing theabstractmodifier.static intFINALThe
intvalue representing thefinalmodifier.static intINTERFACEThe
intvalue representing theinterfacemodifier.static intNATIVEThe
intvalue representing thenativemodifier.static intPRIVATEThe
intvalue representing theprivatemodifier.static intPROTECTEDThe
intvalue representing theprotectedmodifier.static intPUBLICThe
intvalue representing thepublicmodifier.static intSTATICThe
intvalue representing thestaticmodifier.static intSTRICTThe
intvalue representing thestrictfpmodifier.static intSYNCHRONIZEDThe
intvalue representing thesynchronizedmodifier.static intTRANSIENTThe
intvalue representing thetransientmodifier.static intVOLATILEThe
intvalue representing thevolatilemodifier.
-
Constructor Summary
Constructors Constructor Description Modifier()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intclassModifiers()Return an
intvalue OR-ing together the source language modifiers that can be applied to a class.static intconstructorModifiers()Return an
intvalue OR-ing together the source language modifiers that can be applied to a constructor.static intfieldModifiers()Return an
intvalue OR-ing together the source language modifiers that can be applied to a field.static intinterfaceModifiers()Return an
intvalue OR-ing together the source language modifiers that can be applied to an interface.static booleanisAbstract(int mod)Return
trueif the integer argument includes theabstractmodifier,falseotherwise.static booleanisFinal(int mod)Return
trueif the integer argument includes thefinalmodifier,falseotherwise.static booleanisInterface(int mod)Return
trueif the integer argument includes theinterfacemodifier,falseotherwise.static booleanisNative(int mod)Return
trueif the integer argument includes thenativemodifier,falseotherwise.static booleanisPrivate(int mod)Return
trueif the integer argument includes theprivatemodifier,falseotherwise.static booleanisProtected(int mod)Return
trueif the integer argument includes theprotectedmodifier,falseotherwise.static booleanisPublic(int mod)Return
trueif the integer argument includes thepublicmodifier,falseotherwise.static booleanisStatic(int mod)Return
trueif the integer argument includes thestaticmodifier,falseotherwise.static booleanisStrict(int mod)Return
trueif the integer argument includes thestrictfpmodifier,falseotherwise.static booleanisSynchronized(int mod)Return
trueif the integer argument includes thesynchronizedmodifier,falseotherwise.static booleanisTransient(int mod)Return
trueif the integer argument includes thetransientmodifier,falseotherwise.static booleanisVolatile(int mod)Return
trueif the integer argument includes thevolatilemodifier,falseotherwise.static intmethodModifiers()Return an
intvalue OR-ing together the source language modifiers that can be applied to a method.static intparameterModifiers()Return an
intvalue OR-ing together the source language modifiers that can be applied to a parameter.static StringtoString(int mod)Return a string describing the access modifier flags in the specified modifier.
-
-
-
Field Detail
-
PUBLIC
public static final int PUBLIC
The
intvalue representing thepublicmodifier.- See Also:
- Constant Field Values
-
PRIVATE
public static final int PRIVATE
The
intvalue representing theprivatemodifier.- See Also:
- Constant Field Values
-
PROTECTED
public static final int PROTECTED
The
intvalue representing theprotectedmodifier.- See Also:
- Constant Field Values
-
STATIC
public static final int STATIC
The
intvalue representing thestaticmodifier.- See Also:
- Constant Field Values
-
FINAL
public static final int FINAL
The
intvalue representing thefinalmodifier.- See Also:
- Constant Field Values
-
SYNCHRONIZED
public static final int SYNCHRONIZED
The
intvalue representing thesynchronizedmodifier.- See Also:
- Constant Field Values
-
VOLATILE
public static final int VOLATILE
The
intvalue representing thevolatilemodifier.- See Also:
- Constant Field Values
-
TRANSIENT
public static final int TRANSIENT
The
intvalue representing thetransientmodifier.- See Also:
- Constant Field Values
-
NATIVE
public static final int NATIVE
The
intvalue representing thenativemodifier.- See Also:
- Constant Field Values
-
INTERFACE
public static final int INTERFACE
The
intvalue representing theinterfacemodifier.- See Also:
- Constant Field Values
-
ABSTRACT
public static final int ABSTRACT
The
intvalue representing theabstractmodifier.- See Also:
- Constant Field Values
-
STRICT
public static final int STRICT
The
intvalue representing thestrictfpmodifier.- See Also:
- Constant Field Values
-
-
Method Detail
-
isPublic
public static boolean isPublic(int mod)
Return
trueif the integer argument includes thepublicmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thepublicmodifier;falseotherwise.
-
isPrivate
public static boolean isPrivate(int mod)
Return
trueif the integer argument includes theprivatemodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes theprivatemodifier;falseotherwise.
-
isProtected
public static boolean isProtected(int mod)
Return
trueif the integer argument includes theprotectedmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes theprotectedmodifier;falseotherwise.
-
isStatic
public static boolean isStatic(int mod)
Return
trueif the integer argument includes thestaticmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thestaticmodifier;falseotherwise.
-
isFinal
public static boolean isFinal(int mod)
Return
trueif the integer argument includes thefinalmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thefinalmodifier;falseotherwise.
-
isSynchronized
public static boolean isSynchronized(int mod)
Return
trueif the integer argument includes thesynchronizedmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thesynchronizedmodifier;falseotherwise.
-
isVolatile
public static boolean isVolatile(int mod)
Return
trueif the integer argument includes thevolatilemodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thevolatilemodifier;falseotherwise.
-
isTransient
public static boolean isTransient(int mod)
Return
trueif the integer argument includes thetransientmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thetransientmodifier;falseotherwise.
-
isNative
public static boolean isNative(int mod)
Return
trueif the integer argument includes thenativemodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thenativemodifier;falseotherwise.
-
isInterface
public static boolean isInterface(int mod)
Return
trueif the integer argument includes theinterfacemodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes theinterfacemodifier;falseotherwise.
-
isAbstract
public static boolean isAbstract(int mod)
Return
trueif the integer argument includes theabstractmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes theabstractmodifier;falseotherwise.
-
isStrict
public static boolean isStrict(int mod)
Return
trueif the integer argument includes thestrictfpmodifier,falseotherwise.- Parameters:
mod- a set of modifiers- Returns:
trueifmodincludes thestrictfpmodifier;falseotherwise.
-
toString
public static String toString(int mod)
Return a string describing the access modifier flags in the specified modifier. For example:
public final synchronized strictfp
The modifier names are returned in an order consistent with the suggested modifier orderings given in sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1 of The Java™ Language Specification. The full modifier ordering used by this method is:
public protected private abstract static final transient volatile synchronized native strictfp interfaceThe
interfacemodifier discussed in this class is not a true modifier in the Java language and it appears after all other modifiers listed by this method. This method may return a string of modifiers that are not valid modifiers of a Java entity; in other words, no checking is done on the possible validity of the combination of modifiers represented by the input. Note that to perform such checking for a known kind of entity, such as a constructor or method, first AND the argument oftoStringwith the appropriate mask from a method likeconstructorModifiers()ormethodModifiers().- Parameters:
mod- a set of modifiers- Returns:
- a string representation of the set of modifiers
represented by
mod
-
classModifiers
public static int classModifiers()
Return an
intvalue OR-ing together the source language modifiers that can be applied to a class.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a class. - Since:
- 1.7
- See The Java™ Language Specification:
- 8.1.1 Class Modifiers
-
interfaceModifiers
public static int interfaceModifiers()
Return an
intvalue OR-ing together the source language modifiers that can be applied to an interface.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to an interface. - Since:
- 1.7
- See The Java™ Language Specification:
- 9.1.1 Interface Modifiers
-
constructorModifiers
public static int constructorModifiers()
Return an
intvalue OR-ing together the source language modifiers that can be applied to a constructor.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a constructor. - Since:
- 1.7
- See The Java™ Language Specification:
- 8.8.3 Constructor Modifiers
-
methodModifiers
public static int methodModifiers()
Return an
intvalue OR-ing together the source language modifiers that can be applied to a method.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a method. - Since:
- 1.7
- See The Java™ Language Specification:
- 8.4.3 Method Modifiers
-
fieldModifiers
public static int fieldModifiers()
Return an
intvalue OR-ing together the source language modifiers that can be applied to a field.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a field. - Since:
- 1.7
- See The Java™ Language Specification:
- 8.3.1 Field Modifiers
-
parameterModifiers
public static int parameterModifiers()
Return an
intvalue OR-ing together the source language modifiers that can be applied to a parameter.- Returns:
- an
intvalue OR-ing together the source language modifiers that can be applied to a parameter. - Since:
- 1.8
- See The Java™ Language Specification:
- 8.4.1 Formal Parameters
-
-
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2018, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.