Top Description Methods
com.github.javaparser.ast.nodeTypes

public Interface NodeWithType<N extends Node, T extends Type>

Known Direct Implementers
com.github.javaparser.ast.body.AnnotationMemberDeclaration, com.github.javaparser.ast.body.MethodDeclaration, com.github.javaparser.ast.body.Parameter, com.github.javaparser.ast.body.ReceiverParameter, com.github.javaparser.ast.body.VariableDeclarator, com.github.javaparser.ast.expr.CastExpr, com.github.javaparser.ast.expr.ClassExpr, com.github.javaparser.ast.expr.InstanceOfExpr, com.github.javaparser.ast.expr.ObjectCreationExpr, com.github.javaparser.ast.expr.TypeExpr
Imports
com.github.javaparser.ast.CompilationUnit, .Node, com.github.javaparser.ast.type.Type

A node with a type.

The main reason for this interface is to permit users to manipulate homogeneously all nodes with getType/setType methods

Since
2.3.1

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the type
getType
()

Gets the type

public default String
public N

Returns:

this
setType
(T
the type
type
)

Sets the type

public default N

Returns:

this
setType
(Class<?>
the type
typeClass
)

Sets this type to this class and try to import it to the CompilationUnit if needed

public default N
setType(final String typeString)

public void

Method Detail

getTypeback to summary
public T getType()

Gets the type

Returns:T

the type

getTypeAsStringback to summary
public default String getTypeAsString()
setTypeback to summary
public N setType(T type)

Sets the type

Parameters
type:T

the type

Returns:N

this

setTypeback to summary
public default N setType(Class<?> typeClass)

Sets this type to this class and try to import it to the CompilationUnit if needed

Parameters
typeClass:Class<?>

the type

Returns:N

this

Annotations
@SuppressWarnings:unchecked
setTypeback to summary
public default N setType(final String typeString)
Annotations
@SuppressWarnings:unchecked
tryAddImportToParentCompilationUnitback to summary
public void tryAddImportToParentCompilationUnit(Class<?> clazz)