Package com.github.javaparser.ast.body
Class TypeDeclaration<T extends TypeDeclaration<?>>
- java.lang.Object
-
- com.github.javaparser.ast.Node
-
- com.github.javaparser.ast.body.BodyDeclaration<T>
-
- com.github.javaparser.ast.body.TypeDeclaration<T>
-
- All Implemented Interfaces:
NodeWithAccessModifiers<T>
,NodeWithPrivateModifier<T>
,NodeWithProtectedModifier<T>
,NodeWithPublicModifier<T>
,NodeWithStaticModifier<T>
,NodeWithStrictfpModifier<T>
,NodeWithAnnotations<T>
,NodeWithJavadoc<T>
,NodeWithMembers<T>
,NodeWithModifiers<T>
,NodeWithRange<Node>
,NodeWithSimpleName<T>
,NodeWithTokenRange<Node>
,Observable
,Visitable
,HasParentNode<Node>
,Cloneable
- Direct Known Subclasses:
AnnotationDeclaration
,ClassOrInterfaceDeclaration
,EnumDeclaration
public abstract class TypeDeclaration<T extends TypeDeclaration<?>> extends BodyDeclaration<T> implements NodeWithSimpleName<T>, NodeWithJavadoc<T>, NodeWithMembers<T>, NodeWithAccessModifiers<T>, NodeWithStaticModifier<T>, NodeWithStrictfpModifier<T>
A base class for all types of type declarations.- Author:
- Julio Vilmar Gesser
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.javaparser.ast.Node
Node.ObserverRegistrationMode, Node.Parsedness
-
-
Field Summary
-
Fields inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration
-
-
Constructor Summary
Constructors Constructor Description TypeDeclaration()
TypeDeclaration(TokenRange tokenRange, EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)
This constructor is used by the parser and is considered private.TypeDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)
TypeDeclaration(EnumSet<Modifier> modifiers, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
addMember(BodyDeclaration<?> decl)
Adds the given declaration to the specified type.TypeDeclaration<?>
clone()
List<CallableDeclaration<?>>
getCallablesWithSignature(CallableDeclaration.Signature signature)
NodeList<BodyDeclaration<?>>
getMembers()
TypeDeclarationMetaModel
getMetaModel()
EnumSet<Modifier>
getModifiers()
Return the modifiers of this type declaration.SimpleName
getName()
List<NodeList<?>>
getNodeLists()
The list of NodeLists owned by this node.boolean
isNestedType()
boolean
isTopLevelType()
boolean
remove(Node node)
boolean
replace(Node node, Node replacementNode)
T
setMembers(NodeList<BodyDeclaration<?>> members)
T
setModifiers(EnumSet<Modifier> modifiers)
T
setName(SimpleName name)
-
Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
getAnnotations, setAnnotations
-
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, customInitialization, equals, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getTokenRange, hasComment, hashCode, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, toString, toString, tryAddImportToParentCompilationUnit, unregister
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.HasParentNode
getAncestorOfType
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithAnnotations
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, getAnnotation, getAnnotationByClass, getAnnotationByName, isAnnotationPresent, isAnnotationPresent, setAnnotation, tryAddImportToParentCompilationUnit
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithJavadoc
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithMembers
addField, addField, addField, addInitializer, addMethod, addPrivateField, addPrivateField, addProtectedField, addProtectedField, addPublicField, addPublicField, addStaticInitializer, getFieldByName, getFields, getMember, getMethods, getMethodsByName, getMethodsByParameterTypes, getMethodsByParameterTypes, getMethodsBySignature, setMember, tryAddImportToParentCompilationUnit
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, removeModifier, setModifier
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPrivateModifier
isPrivate, setPrivate
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithProtectedModifier
isProtected, setProtected
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPublicModifier
isPublic, setPublic
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, getBegin, getEnd, isPositionedAfter, isPositionedBefore
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithSimpleName
getNameAsString, setName
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStaticModifier
isStatic, setStatic
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStrictfpModifier
isStrictfp, setStrictfp
-
-
-
-
Constructor Detail
-
TypeDeclaration
public TypeDeclaration()
-
TypeDeclaration
public TypeDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)
-
TypeDeclaration
@Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator") public TypeDeclaration(TokenRange tokenRange, EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)
This constructor is used by the parser and is considered private.
-
-
Method Detail
-
addMember
public T addMember(BodyDeclaration<?> decl)
Adds the given declaration to the specified type.- Specified by:
addMember
in interfaceNodeWithMembers<T extends TypeDeclaration<?>>
- Parameters:
decl
- member declaration
-
getMembers
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public NodeList<BodyDeclaration<?>> getMembers()
- Specified by:
getMembers
in interfaceNodeWithMembers<T extends TypeDeclaration<?>>
-
getModifiers
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public EnumSet<Modifier> getModifiers()
Return the modifiers of this type declaration.- Specified by:
getModifiers
in interfaceNodeWithModifiers<T extends TypeDeclaration<?>>
- Returns:
- modifiers
- See Also:
Modifier
-
setMembers
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public T setMembers(NodeList<BodyDeclaration<?>> members)
- Specified by:
setMembers
in interfaceNodeWithMembers<T extends TypeDeclaration<?>>
-
setModifiers
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public T setModifiers(EnumSet<Modifier> modifiers)
- Specified by:
setModifiers
in interfaceNodeWithModifiers<T extends TypeDeclaration<?>>
-
setName
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public T setName(SimpleName name)
- Specified by:
setName
in interfaceNodeWithSimpleName<T extends TypeDeclaration<?>>
-
getName
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public SimpleName getName()
- Specified by:
getName
in interfaceNodeWithSimpleName<T extends TypeDeclaration<?>>
-
getNodeLists
public List<NodeList<?>> getNodeLists()
Description copied from class:Node
The list of NodeLists owned by this node.- Overrides:
getNodeLists
in classBodyDeclaration<T extends TypeDeclaration<?>>
-
remove
@Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator") public boolean remove(Node node)
- Overrides:
remove
in classBodyDeclaration<T extends TypeDeclaration<?>>
-
isTopLevelType
public boolean isTopLevelType()
- Returns:
- is this type's parent a CompilationUnit?
-
getCallablesWithSignature
public List<CallableDeclaration<?>> getCallablesWithSignature(CallableDeclaration.Signature signature)
- Returns:
- methods or constructors whose signatures match the passed signature.
-
isNestedType
public boolean isNestedType()
- Returns:
- is this type's parent a TypeDeclaration? NOTE: many people are confused over terminology. Refer to https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html .
-
clone
@Generated("com.github.javaparser.generator.core.node.CloneGenerator") public TypeDeclaration<?> clone()
- Overrides:
clone
in classBodyDeclaration<T extends TypeDeclaration<?>>
-
getMetaModel
@Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator") public TypeDeclarationMetaModel getMetaModel()
- Overrides:
getMetaModel
in classBodyDeclaration<T extends TypeDeclaration<?>>
- Returns:
- get JavaParser specific node introspection information.
-
replace
@Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator") public boolean replace(Node node, Node replacementNode)
- Overrides:
replace
in classBodyDeclaration<T extends TypeDeclaration<?>>
-
-