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,RecordDeclaration
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.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal
-
-
Field Summary
-
Fields inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEY
-
-
Constructor Summary
Constructors Constructor Description TypeDeclaration()TypeDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)TypeDeclaration(NodeList<Modifier> modifiers, String name)TypeDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)This constructor is used by the parser and is considered private.
-
Method Summary
-
Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
asAnnotationDeclaration, asAnnotationMemberDeclaration, asCallableDeclaration, asClassOrInterfaceDeclaration, asCompactConstructorDeclaration, asConstructorDeclaration, asEnumConstantDeclaration, asEnumDeclaration, asFieldDeclaration, asInitializerDeclaration, asMethodDeclaration, asRecordDeclaration, getAnnotations, ifAnnotationDeclaration, ifAnnotationMemberDeclaration, ifCallableDeclaration, ifClassOrInterfaceDeclaration, ifCompactConstructorDeclaration, ifConstructorDeclaration, ifEnumConstantDeclaration, ifEnumDeclaration, ifFieldDeclaration, ifInitializerDeclaration, ifMethodDeclaration, ifRecordDeclaration, isAnnotationDeclaration, isAnnotationMemberDeclaration, isCallableDeclaration, isClassOrInterfaceDeclaration, isCompactConstructorDeclaration, isConstructorDeclaration, isEnumConstantDeclaration, isEnumDeclaration, isFieldDeclaration, isInitializerDeclaration, isMethodDeclaration, isRecordDeclaration, setAnnotations, toAnnotationDeclaration, toAnnotationMemberDeclaration, toCallableDeclaration, toClassOrInterfaceDeclaration, toCompactConstructorDeclaration, toConstructorDeclaration, toEnumConstantDeclaration, toEnumDeclaration, toFieldDeclaration, toInitializerDeclaration, toMethodDeclaration, toRecordDeclaration
-
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, containsData, createDefaultPrinter, createDefaultPrinter, customInitialization, equals, findAll, findAll, findAll, findByRange, findCompilationUnit, findData, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getDataKeys, getDefaultPrinterConfiguration, getLineEndingStyle, getLineEndingStyleOrDefault, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getPrinter, getPrinter, getRange, getSymbolResolver, getTokenRange, hashCode, hasScope, isAncestorOf, isPhantom, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeData, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walk
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.HasParentNode
findAncestor, findAncestor, findAncestor, hasParentNode, isDescendantOf
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithAnnotations
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, 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, setJavadocComment
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithMembers
addConstructor, addField, addField, addField, addFieldWithInitializer, addFieldWithInitializer, addFieldWithInitializer, addInitializer, addMethod, addPrivateField, addPrivateField, addPrivateField, addProtectedField, addProtectedField, addProtectedField, addPublicField, addPublicField, addPublicField, addStaticInitializer, getConstructorByParameterTypes, getConstructorByParameterTypes, getConstructors, getDefaultConstructor, getFieldByName, getFields, getMember, getMethods, getMethodsByName, getMethodsByParameterTypes, getMethodsByParameterTypes, getMethodsBySignature, isEmpty, setMember, tryAddImportToParentCompilationUnit
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, getAccessSpecifier, hasModifier, removeModifier, setModifier, setModifiers
-
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, containsWithinRange, getBegin, getEnd, hasRange
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithSimpleName
getNameAsExpression, 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(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)
-
TypeDeclaration
public TypeDeclaration(TokenRange tokenRange, NodeList<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:
addMemberin interfaceNodeWithMembers<T extends TypeDeclaration<?>>- Parameters:
decl- member declaration
-
getMembers
public NodeList<BodyDeclaration<?>> getMembers()
- Specified by:
getMembersin interfaceNodeWithMembers<T extends TypeDeclaration<?>>- Returns:
- all members inside the braces of this node, like fields, methods, nested types, etc.
-
getModifiers
public NodeList<Modifier> getModifiers()
Return the modifiers of this type declaration.- Specified by:
getModifiersin interfaceNodeWithModifiers<T extends TypeDeclaration<?>>- Returns:
- modifiers
- See Also:
Modifier
-
setMembers
public T setMembers(NodeList<BodyDeclaration<?>> members)
- Specified by:
setMembersin interfaceNodeWithMembers<T extends TypeDeclaration<?>>
-
setModifiers
public T setModifiers(NodeList<Modifier> modifiers)
- Specified by:
setModifiersin interfaceNodeWithModifiers<T extends TypeDeclaration<?>>
-
setName
public T setName(SimpleName name)
- Specified by:
setNamein interfaceNodeWithSimpleName<T extends TypeDeclaration<?>>
-
getName
public SimpleName getName()
- Specified by:
getNamein interfaceNodeWithSimpleName<T extends TypeDeclaration<?>>
-
remove
public boolean remove(Node node)
- Overrides:
removein 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.
-
getFullyQualifiedName
public Optional<String> getFullyQualifiedName()
Returns the fully qualified name of this type, derived only from information available in this compilation unit. (So no symbol solving happens.) If the declared type is a local class declaration, it will return Optional.empty(). If the declared type is a local record declaration, it will return Optional.empty(). If the declared type is not contained in a compilation unit, it will return Optional.empty().
-
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
public TypeDeclaration<?> clone()
- Overrides:
clonein classBodyDeclaration<T extends TypeDeclaration<?>>
-
getMetaModel
public TypeDeclarationMetaModel getMetaModel()
- Overrides:
getMetaModelin classBodyDeclaration<T extends TypeDeclaration<?>>- Returns:
- get JavaParser specific node introspection information.
-
replace
public boolean replace(Node node, Node replacementNode)
- Overrides:
replacein classBodyDeclaration<T extends TypeDeclaration<?>>
-
isTypeDeclaration
public boolean isTypeDeclaration()
- Overrides:
isTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
asTypeDeclaration
public TypeDeclaration asTypeDeclaration()
- Overrides:
asTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
ifTypeDeclaration
public void ifTypeDeclaration(Consumer<TypeDeclaration> action)
- Overrides:
ifTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
toTypeDeclaration
public Optional<TypeDeclaration> toTypeDeclaration()
- Overrides:
toTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
resolve
public abstract ResolvedReferenceTypeDeclaration resolve()
-
-