Top Description Fields Constructors Methods
com.github.javaparser.ast.body

public abstract Class TypeDeclaration<T extends TypeDeclaration<?>>

extends BodyDeclaration<T extends TypeDeclaration<?>>
implements NodeWithSimpleName<T extends TypeDeclaration<?>>, NodeWithJavadoc<T extends TypeDeclaration<?>>, NodeWithMembers<T extends TypeDeclaration<?>>, NodeWithAccessModifiers<T extends TypeDeclaration<?>>, NodeWithStaticModifier<T extends TypeDeclaration<?>>, NodeWithStrictfpModifier<T extends TypeDeclaration<?>>
Class Inheritance
All Implemented Interfaces
com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStrictfpModifier, com.github.javaparser.ast.nodeTypes.NodeWithModifiers, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStaticModifier, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAccessModifiers, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithProtectedModifier, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPrivateModifier, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPublicModifier, com.github.javaparser.ast.nodeTypes.NodeWithMembers, com.github.javaparser.ast.nodeTypes.NodeWithSimpleName, com.github.javaparser.ast.nodeTypes.NodeWithJavadoc
Known Direct Subclasses
com.github.javaparser.ast.body.AnnotationDeclaration, com.github.javaparser.ast.body.ClassOrInterfaceDeclaration, com.github.javaparser.ast.body.EnumDeclaration
Imports
com.github.javaparser.TokenRange, com.github.javaparser.ast.*, .Node, com.github.javaparser.ast.expr.AnnotationExpr, .SimpleName, com.github.javaparser.ast.nodeTypes.NodeWithJavadoc, .NodeWithMembers, .NodeWithSimpleName, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAccessModifiers, .NodeWithStaticModifier, .NodeWithStrictfpModifier, com.github.javaparser.ast.observer.ObservableProperty, com.github.javaparser.ast.visitor.CloneVisitor, com.github.javaparser.metamodel.JavaParserMetaModel, .TypeDeclarationMetaModel, com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration, java.util.List, .Optional, java.util.function.Consumer

A base class for all types of type declarations.
Author
Julio Vilmar Gesser

Field Summary

Modifier and TypeField and Description
private NodeList<BodyDeclaration<?>>
private NodeList<Modifier>
private SimpleName

Constructor Summary

AccessConstructor and Description
public
public
public
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 Summary

Modifier and TypeMethod and Description
public T
addMember(BodyDeclaration<?>
member declaration
decl
)

Overrides default com.github.javaparser.ast.nodeTypes.NodeWithMembers.addMember.

Adds the given declaration to the specified type.
public TypeDeclaration<T extends TypeDeclaration<?>>
public TypeDeclaration<?>
clone()

Overrides com.github.javaparser.ast.body.BodyDeclaration.clone.

Creates and returns a copy of this object.
public List<CallableDeclaration<?>>

Returns:

methods or constructors whose signatures match the passed signature.
getCallablesWithSignature
(CallableDeclaration.Signature signature)

public Optional<String>
getFullyQualifiedName()

Returns the fully qualified name of this type, derived only from information available in this compilation unit.

public NodeList<BodyDeclaration<?>>
public TypeDeclarationMetaModel
public NodeList<Modifier>

Returns:

modifiers
getModifiers
()

Implements com.github.javaparser.ast.nodeTypes.NodeWithModifiers.getModifiers.

Return the modifiers of this type declaration.
public SimpleName
public void
public boolean

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 .
isNestedType
()

public boolean

Returns:

is this type's parent a CompilationUnit?
isTopLevelType
()

public boolean
public boolean
public boolean
public abstract ResolvedReferenceTypeDeclaration
public T
public T
public T
public Optional<TypeDeclaration<T extends TypeDeclaration<?>>>
Inherited from com.github.javaparser.ast.body.BodyDeclaration:
asAnnotationDeclarationasAnnotationMemberDeclarationasCallableDeclarationasClassOrInterfaceDeclarationasConstructorDeclarationasEnumConstantDeclarationasEnumDeclarationasFieldDeclarationasInitializerDeclarationasMethodDeclarationgetAnnotationsifAnnotationDeclarationifAnnotationMemberDeclarationifCallableDeclarationifClassOrInterfaceDeclarationifConstructorDeclarationifEnumConstantDeclarationifEnumDeclarationifFieldDeclarationifInitializerDeclarationifMethodDeclarationisAnnotationDeclarationisAnnotationMemberDeclarationisCallableDeclarationisClassOrInterfaceDeclarationisConstructorDeclarationisEnumConstantDeclarationisEnumDeclarationisFieldDeclarationisInitializerDeclarationisMethodDeclarationsetAnnotationstoAnnotationDeclarationtoAnnotationMemberDeclarationtoCallableDeclarationtoClassOrInterfaceDeclarationtoConstructorDeclarationtoEnumConstantDeclarationtoEnumDeclarationtoFieldDeclarationtoInitializerDeclarationtoMethodDeclaration

Field Detail

membersback to summary
private NodeList<BodyDeclaration<?>> members
modifiersback to summary
private NodeList<Modifier> modifiers
nameback to summary
private SimpleName name

Constructor Detail

TypeDeclarationback to summary
public TypeDeclaration()
TypeDeclarationback to summary
public TypeDeclaration(NodeList<Modifier> modifiers, String name)
TypeDeclarationback to summary
public TypeDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)
Annotations
@AllFieldsConstructor
TypeDeclarationback to summary
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.

Annotations
@Generated:com.github.javaparser.generator.core.node.MainConstructorGenerator

Method Detail

addMemberback to summary
public T addMember(BodyDeclaration<?> decl)

Overrides default com.github.javaparser.ast.nodeTypes.NodeWithMembers.addMember.

Adds the given declaration to the specified type.

Parameters
decl:BodyDeclaration<?>

member declaration

asTypeDeclarationback to summary
public TypeDeclaration<T extends TypeDeclaration<?>> asTypeDeclaration()

Overrides com.github.javaparser.ast.body.BodyDeclaration.asTypeDeclaration.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
cloneback to summary
public TypeDeclaration<?> clone()

Overrides com.github.javaparser.ast.body.BodyDeclaration.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:TypeDeclaration<?>

a clone of this instance.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.CloneGenerator
getCallablesWithSignatureback to summary
public List<CallableDeclaration<?>> getCallablesWithSignature(CallableDeclaration.Signature signature)
Returns:List<CallableDeclaration<?>>

methods or constructors whose signatures match the passed signature.

getFullyQualifiedNameback to summary
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 not contained in a compilation unit, it will return Optional.empty().

See Also
com.github.javaparser.ast.stmt.LocalClassDeclarationStmt
getMembersback to summary
public NodeList<BodyDeclaration<?>> getMembers()

Implements com.github.javaparser.ast.nodeTypes.NodeWithMembers.getMembers.

Returns:NodeList<BodyDeclaration<?>>

Doc from com.github.javaparser.ast.nodeTypes.NodeWithMembers.getMembers.

all members inside the braces of this node, like fields, methods, nested types, etc.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
getMetaModelback to summary
public TypeDeclarationMetaModel getMetaModel()

Overrides com.github.javaparser.ast.body.BodyDeclaration.getMetaModel.

Returns:TypeDeclarationMetaModel

Doc from com.github.javaparser.ast.Node.getMetaModel.

get JavaParser specific node introspection information.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.GetMetaModelGenerator
getModifiersback to summary
public NodeList<Modifier> getModifiers()

Implements com.github.javaparser.ast.nodeTypes.NodeWithModifiers.getModifiers.

Return the modifiers of this type declaration.

Returns:NodeList<Modifier>

modifiers

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
See Also
Modifier
getNameback to summary
public SimpleName getName()

Implements com.github.javaparser.ast.nodeTypes.NodeWithSimpleName.getName.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
ifTypeDeclarationback to summary
public void ifTypeDeclaration(Consumer<TypeDeclaration<T extends TypeDeclaration<?>>> action)

Overrides com.github.javaparser.ast.body.BodyDeclaration.ifTypeDeclaration.

Annotations
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
isNestedTypeback to summary
public boolean isNestedType()
Returns:boolean

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 .

isTopLevelTypeback to summary
public boolean isTopLevelType()
Returns:boolean

is this type's parent a CompilationUnit?

isTypeDeclarationback to summary
public boolean isTypeDeclaration()

Overrides com.github.javaparser.ast.body.BodyDeclaration.isTypeDeclaration.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
removeback to summary
public boolean remove(Node node)

Overrides com.github.javaparser.ast.body.BodyDeclaration.remove.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.RemoveMethodGenerator
replaceback to summary
public boolean replace(Node node, Node replacementNode)

Overrides com.github.javaparser.ast.body.BodyDeclaration.replace.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.ReplaceMethodGenerator
resolveback to summary
public abstract ResolvedReferenceTypeDeclaration resolve()
setMembersback to summary
public T setMembers(final NodeList<BodyDeclaration<?>> members)

Implements com.github.javaparser.ast.nodeTypes.NodeWithMembers.setMembers.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
@SuppressWarnings:unchecked
setModifiersback to summary
public T setModifiers(final NodeList<Modifier> modifiers)

Implements com.github.javaparser.ast.nodeTypes.NodeWithModifiers.setModifiers.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
@SuppressWarnings:unchecked
setNameback to summary
public T setName(final SimpleName name)

Implements com.github.javaparser.ast.nodeTypes.NodeWithSimpleName.setName.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
@SuppressWarnings:unchecked
toTypeDeclarationback to summary
public Optional<TypeDeclaration<T extends TypeDeclaration<?>>> toTypeDeclaration()

Overrides com.github.javaparser.ast.body.BodyDeclaration.toTypeDeclaration.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator