Package org.eclipse.jdt.core.dom
Class Modifier
- java.lang.Object
-
- org.eclipse.jdt.core.dom.ASTNode
-
- org.eclipse.jdt.core.dom.Modifier
-
- All Implemented Interfaces:
IExtendedModifier
public final class Modifier extends ASTNode implements IExtendedModifier
Modifier node.Modifier: public protected private static abstract final native synchronized transient volatile strictfp defaultThe numeric values of these flags match the ones for class files as described in the Java Virtual Machine Specification (except for
DEFAULT). Note that the Java model classFlagsalso provides the same constants as this class.- Since:
- 2.0
- Restriction:
- This class is not intended to be instantiated by clients.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classModifier.ModifierKeywordModifier keywords (typesafe enumeration).
-
Field Summary
Fields Modifier and Type Field Description static intABSTRACT"abstract" modifier constant (bit mask).static intDEFAULT"default" modifier constant (bit mask) (added in JLS8 API).static intFINAL"final" modifier constant (bit mask).static SimplePropertyDescriptorKEYWORD_PROPERTYThe "keyword" structural property of this node type (type:Modifier.ModifierKeyword).static intNATIVE"native" modifier constant (bit mask).static intNONEModifier constant (bit mask, value 0) indicating no modifiers.static intPRIVATE"private" modifier constant (bit mask).static intPROTECTED"protected" modifier constant (bit mask).static intPUBLIC"public" modifier constant (bit mask).static intSTATIC"static" modifier constant (bit mask).static intSTRICTFP"strictfp" modifier constant (bit mask).static intSYNCHRONIZED"synchronized" modifier constant (bit mask).static intTRANSIENT"transient" modifier constant (bit mask).static intVOLATILE"volatile" modifier constant (bit mask).-
Fields inherited from class org.eclipse.jdt.core.dom.ASTNode
ANNOTATION_TYPE_DECLARATION, ANNOTATION_TYPE_MEMBER_DECLARATION, ANONYMOUS_CLASS_DECLARATION, ARRAY_ACCESS, ARRAY_CREATION, ARRAY_INITIALIZER, ARRAY_TYPE, ASSERT_STATEMENT, ASSIGNMENT, BLOCK, BLOCK_COMMENT, BOOLEAN_LITERAL, BREAK_STATEMENT, CAST_EXPRESSION, CATCH_CLAUSE, CHARACTER_LITERAL, CLASS_INSTANCE_CREATION, COMPILATION_UNIT, CONDITIONAL_EXPRESSION, CONSTRUCTOR_INVOCATION, CONTINUE_STATEMENT, CREATION_REFERENCE, DIMENSION, DO_STATEMENT, EMPTY_STATEMENT, ENHANCED_FOR_STATEMENT, ENUM_CONSTANT_DECLARATION, ENUM_DECLARATION, EXPORTS_DIRECTIVE, EXPRESSION_METHOD_REFERENCE, EXPRESSION_STATEMENT, FIELD_ACCESS, FIELD_DECLARATION, FOR_STATEMENT, IF_STATEMENT, IMPORT_DECLARATION, INFIX_EXPRESSION, INITIALIZER, INSTANCEOF_EXPRESSION, INTERSECTION_TYPE, JAVADOC, LABELED_STATEMENT, LAMBDA_EXPRESSION, LINE_COMMENT, MALFORMED, MARKER_ANNOTATION, MEMBER_REF, MEMBER_VALUE_PAIR, METHOD_DECLARATION, METHOD_INVOCATION, METHOD_REF, METHOD_REF_PARAMETER, MODIFIER, MODULE_DECLARATION, MODULE_MODIFIER, NAME_QUALIFIED_TYPE, NORMAL_ANNOTATION, NULL_LITERAL, NUMBER_LITERAL, OPENS_DIRECTIVE, ORIGINAL, PACKAGE_DECLARATION, PARAMETERIZED_TYPE, PARENTHESIZED_EXPRESSION, POSTFIX_EXPRESSION, PREFIX_EXPRESSION, PRIMITIVE_TYPE, PROTECT, PROVIDES_DIRECTIVE, QUALIFIED_NAME, QUALIFIED_TYPE, RECORD_DECLARATION, RECOVERED, REQUIRES_DIRECTIVE, RETURN_STATEMENT, SIMPLE_NAME, SIMPLE_TYPE, SINGLE_MEMBER_ANNOTATION, SINGLE_VARIABLE_DECLARATION, STRING_LITERAL, SUPER_CONSTRUCTOR_INVOCATION, SUPER_FIELD_ACCESS, SUPER_METHOD_INVOCATION, SUPER_METHOD_REFERENCE, SWITCH_CASE, SWITCH_EXPRESSION, SWITCH_STATEMENT, SYNCHRONIZED_STATEMENT, TAG_ELEMENT, TEXT_BLOCK, TEXT_ELEMENT, THIS_EXPRESSION, THROW_STATEMENT, TRY_STATEMENT, TYPE_DECLARATION, TYPE_DECLARATION_STATEMENT, TYPE_LITERAL, TYPE_METHOD_REFERENCE, TYPE_PARAMETER, UNION_TYPE, USES_DIRECTIVE, VARIABLE_DECLARATION_EXPRESSION, VARIABLE_DECLARATION_FRAGMENT, VARIABLE_DECLARATION_STATEMENT, WHILE_STATEMENT, WILDCARD_TYPE, YIELD_STATEMENT
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Modifier.ModifierKeywordgetKeyword()Returns the modifier keyword of this modifier node.booleanisAbstract()Answer true if the receiver is the abstract modifier, false otherwise.static booleanisAbstract(int flags)Returns whether the given flags includes the "abstract" modifier.booleanisAnnotation()Returns whether this extended modifier is an annotation.booleanisDefault()Answer true if the receiver is the default modifier, false otherwise.static booleanisDefault(int flags)Returns whether the given flags includes the "default" modifier.booleanisFinal()Answer true if the receiver is the final modifier, false otherwise.static booleanisFinal(int flags)Returns whether the given flags includes the "final" modifier.booleanisModifier()Returns whether this extended modifier is a standard modifier.booleanisNative()Answer true if the receiver is the native modifier, false otherwise.static booleanisNative(int flags)Returns whether the given flags includes the "native" modifier.booleanisPrivate()Answer true if the receiver is the private modifier, false otherwise.static booleanisPrivate(int flags)Returns whether the given flags includes the "private" modifier.booleanisProtected()Answer true if the receiver is the protected modifier, false otherwise.static booleanisProtected(int flags)Returns whether the given flags includes the "protected" modifier.booleanisPublic()Answer true if the receiver is the public modifier, false otherwise.static booleanisPublic(int flags)Returns whether the given flags includes the "public" modifier.booleanisStatic()Answer true if the receiver is the static modifier, false otherwise.static booleanisStatic(int flags)Returns whether the given flags includes the "static" modifier.booleanisStrictfp()Answer true if the receiver is the strictfp modifier, false otherwise.static booleanisStrictfp(int flags)Returns whether the given flags includes the "strictfp" modifier.booleanisSynchronized()Answer true if the receiver is the synchronized modifier, false otherwise.static booleanisSynchronized(int flags)Returns whether the given flags includes the "synchronized" modifier.booleanisTransient()Answer true if the receiver is the transient modifier, false otherwise.static booleanisTransient(int flags)Returns whether the given flags includes the "transient" modifier.booleanisVolatile()Answer true if the receiver is the volatile modifier, false otherwise.static booleanisVolatile(int flags)Returns whether the given flags includes the "volatile" modifier.static ListpropertyDescriptors(int apiLevel)Returns a list of structural property descriptors for this node type.voidsetKeyword(Modifier.ModifierKeyword modifierKeyord)Sets the modifier keyword of this modifier node.-
Methods inherited from class org.eclipse.jdt.core.dom.ASTNode
accept, copySubtree, copySubtrees, delete, equals, getAST, getFlags, getLength, getLocationInParent, getNodeType, getParent, getProperty, getRoot, getStartPosition, getStructuralProperty, hashCode, nodeClassForType, properties, setFlags, setProperty, setSourceRange, setStructuralProperty, structuralPropertiesForType, subtreeBytes, subtreeMatch, toString
-
-
-
-
Field Detail
-
ABSTRACT
public static final int ABSTRACT
"abstract" modifier constant (bit mask). Applicable to types and methods.- Since:
- 2.0
- See Also:
- Constant Field Values
-
FINAL
public static final int FINAL
"final" modifier constant (bit mask). Applicable to types, methods, fields, and variables.- Since:
- 2.0
- See Also:
- Constant Field Values
-
KEYWORD_PROPERTY
public static final SimplePropertyDescriptor KEYWORD_PROPERTY
The "keyword" structural property of this node type (type:Modifier.ModifierKeyword).- Since:
- 3.0
-
NATIVE
public static final int NATIVE
"native" modifier constant (bit mask). Applicable only to methods.- Since:
- 2.0
- See Also:
- Constant Field Values
-
NONE
public static final int NONE
Modifier constant (bit mask, value 0) indicating no modifiers.- Since:
- 2.0
- See Also:
- Constant Field Values
-
PRIVATE
public static final int PRIVATE
"private" modifier constant (bit mask). Applicable to types, methods, constructors, and fields.- Since:
- 2.0
- See Also:
- Constant Field Values
-
PROTECTED
public static final int PROTECTED
"protected" modifier constant (bit mask). Applicable to types, methods, constructors, and fields.- Since:
- 2.0
- See Also:
- Constant Field Values
-
PUBLIC
public static final int PUBLIC
"public" modifier constant (bit mask). Applicable to types, methods, constructors, and fields.- Since:
- 2.0
- See Also:
- Constant Field Values
-
STATIC
public static final int STATIC
"static" modifier constant (bit mask). Applicable to types, methods, fields, and initializers.- Since:
- 2.0
- See Also:
- Constant Field Values
-
STRICTFP
public static final int STRICTFP
"strictfp" modifier constant (bit mask). Applicable to types and methods.- Since:
- 2.0
- See Also:
- Constant Field Values
-
SYNCHRONIZED
public static final int SYNCHRONIZED
"synchronized" modifier constant (bit mask). Applicable only to methods.- Since:
- 2.0
- See Also:
- Constant Field Values
-
TRANSIENT
public static final int TRANSIENT
"transient" modifier constant (bit mask). Applicable only to fields.- Since:
- 2.0
- See Also:
- Constant Field Values
-
VOLATILE
public static final int VOLATILE
"volatile" modifier constant (bit mask). Applicable only to fields.- Since:
- 2.0
- See Also:
- Constant Field Values
-
DEFAULT
public static final int DEFAULT
"default" modifier constant (bit mask) (added in JLS8 API). Applicable only to methods in interfaces (but not for annotation methods with a default value).Note that the value of this flag is internal and is not specified in the Java Virtual Machine Specification.
- Since:
- 3.10
- See Also:
- Constant Field Values
-
-
Method Detail
-
isAbstract
public static boolean isAbstract(int flags)
Returns whether the given flags includes the "abstract" modifier. Applicable to types and methods.- Parameters:
flags- the modifier flags- Returns:
trueif theABSTRACTbit is set, andfalseotherwise- Since:
- 2.0
-
isFinal
public static boolean isFinal(int flags)
Returns whether the given flags includes the "final" modifier. Applicable to types, methods, fields, and variables.- Parameters:
flags- the modifier flags- Returns:
trueif theFINALbit is set, andfalseotherwise- Since:
- 2.0
-
isNative
public static boolean isNative(int flags)
Returns whether the given flags includes the "native" modifier. Applicable only to methods.- Parameters:
flags- the modifier flags- Returns:
trueif theNATIVEbit is set, andfalseotherwise- Since:
- 2.0
-
isPrivate
public static boolean isPrivate(int flags)
Returns whether the given flags includes the "private" modifier. Applicable to types, methods, constructors, and fields.- Parameters:
flags- the modifier flags- Returns:
trueif thePRIVATEbit is set, andfalseotherwise- Since:
- 2.0
-
isProtected
public static boolean isProtected(int flags)
Returns whether the given flags includes the "protected" modifier. Applicable to types, methods, constructors, and fields.- Parameters:
flags- the modifier flags- Returns:
trueif thePROTECTEDbit is set, andfalseotherwise- Since:
- 2.0
-
isPublic
public static boolean isPublic(int flags)
Returns whether the given flags includes the "public" modifier. Applicable to types, methods, constructors, and fields.- Parameters:
flags- the modifier flags- Returns:
trueif thePUBLICbit is set, andfalseotherwise- Since:
- 2.0
-
isStatic
public static boolean isStatic(int flags)
Returns whether the given flags includes the "static" modifier. Applicable to types, methods, fields, and initializers.- Parameters:
flags- the modifier flags- Returns:
trueif theSTATICbit is set, andfalseotherwise- Since:
- 2.0
-
isStrictfp
public static boolean isStrictfp(int flags)
Returns whether the given flags includes the "strictfp" modifier. Applicable to types and methods.- Parameters:
flags- the modifier flags- Returns:
trueif theSTRICTFPbit is set, andfalseotherwise- Since:
- 2.0
-
isSynchronized
public static boolean isSynchronized(int flags)
Returns whether the given flags includes the "synchronized" modifier. Applicable only to methods.- Parameters:
flags- the modifier flags- Returns:
trueif theSYNCHRONIZEDbit is set, andfalseotherwise- Since:
- 2.0
-
isTransient
public static boolean isTransient(int flags)
Returns whether the given flags includes the "transient" modifier. Applicable only to fields.- Parameters:
flags- the modifier flags- Returns:
trueif theTRANSIENTbit is set, andfalseotherwise- Since:
- 2.0
-
isVolatile
public static boolean isVolatile(int flags)
Returns whether the given flags includes the "volatile" modifier. Applicable only to fields.- Parameters:
flags- the modifier flags- Returns:
trueif theVOLATILEbit is set, andfalseotherwise- Since:
- 2.0
-
isDefault
public static boolean isDefault(int flags)
Returns whether the given flags includes the "default" modifier. Applicable only to methods in interfaces.- Parameters:
flags- the modifier flags- Returns:
trueif theDEFAULTbit is set andfalseotherwise- Since:
- 3.10
-
propertyDescriptors
public static List propertyDescriptors(int apiLevel)
Returns a list of structural property descriptors for this node type. Clients must not modify the result.- Parameters:
apiLevel- the API level; one of theAST.JLS*constants- Returns:
- a list of property descriptors (element type:
StructuralPropertyDescriptor) - Since:
- 3.0
-
getKeyword
public Modifier.ModifierKeyword getKeyword()
Returns the modifier keyword of this modifier node.- Returns:
- the modifier keyword
- Since:
- 3.0
-
isAbstract
public boolean isAbstract()
Answer true if the receiver is the abstract modifier, false otherwise.- Returns:
- true if the receiver is the abstract modifier, false otherwise
- Since:
- 3.2
-
isAnnotation
public boolean isAnnotation()
Description copied from interface:IExtendedModifierReturns whether this extended modifier is an annotation.- Specified by:
isAnnotationin interfaceIExtendedModifier- Returns:
trueif this is an annotation (instance of a subclass ofAnnotation), andfalseotherwise- See Also:
IExtendedModifier.isAnnotation()
-
isFinal
public boolean isFinal()
Answer true if the receiver is the final modifier, false otherwise.- Returns:
- true if the receiver is the final modifier, false otherwise
- Since:
- 3.2
-
isModifier
public boolean isModifier()
Description copied from interface:IExtendedModifierReturns whether this extended modifier is a standard modifier.- Specified by:
isModifierin interfaceIExtendedModifier- Returns:
trueif this is a standard modifier (instance ofModifier), andfalseotherwise- See Also:
IExtendedModifier.isModifier()
-
isNative
public boolean isNative()
Answer true if the receiver is the native modifier, false otherwise.- Returns:
- true if the receiver is the native modifier, false otherwise
- Since:
- 3.2
-
isPrivate
public boolean isPrivate()
Answer true if the receiver is the private modifier, false otherwise.- Returns:
- true if the receiver is the private modifier, false otherwise
- Since:
- 3.2
-
isProtected
public boolean isProtected()
Answer true if the receiver is the protected modifier, false otherwise.- Returns:
- true if the receiver is the protected modifier, false otherwise
- Since:
- 3.2
-
isPublic
public boolean isPublic()
Answer true if the receiver is the public modifier, false otherwise.- Returns:
- true if the receiver is the public modifier, false otherwise
- Since:
- 3.2
-
isStatic
public boolean isStatic()
Answer true if the receiver is the static modifier, false otherwise.- Returns:
- true if the receiver is the static modifier, false otherwise
- Since:
- 3.2
-
isStrictfp
public boolean isStrictfp()
Answer true if the receiver is the strictfp modifier, false otherwise.- Returns:
- true if the receiver is the strictfp modifier, false otherwise
- Since:
- 3.2
-
isSynchronized
public boolean isSynchronized()
Answer true if the receiver is the synchronized modifier, false otherwise.- Returns:
- true if the receiver is the synchronized modifier, false otherwise
- Since:
- 3.2
-
isTransient
public boolean isTransient()
Answer true if the receiver is the transient modifier, false otherwise.- Returns:
- true if the receiver is the transient modifier, false otherwise
- Since:
- 3.2
-
isVolatile
public boolean isVolatile()
Answer true if the receiver is the volatile modifier, false otherwise.- Returns:
- true if the receiver is the volatile modifier, false otherwise
- Since:
- 3.2
-
isDefault
public boolean isDefault()
Answer true if the receiver is the default modifier, false otherwise.- Returns:
- true if the receiver is the default modifier, false otherwise
- Since:
- 3.10
-
setKeyword
public void setKeyword(Modifier.ModifierKeyword modifierKeyord)
Sets the modifier keyword of this modifier node.- Parameters:
modifierKeyord- the modifier keyword- Throws:
IllegalArgumentException- if the argument isnull- Since:
- 3.0
-
-