Package org.codehaus.janino

# Class Java.AbstractTypeDeclaration

java.lang.Object
org.codehaus.janino.Java.AbstractTypeDeclaration

All Implemented Interfaces:
  `Java.Annotatable`, `Java.Locatable`, `Java.Scope`, `Java.TypeDeclaration`

Direct Known Subclasses:
  `Java.AbstractClassDeclaration`, `Java.InterfaceDeclaration`

Enclosing class:
  `Java`

public abstract static class Java.AbstractTypeDeclaration extends Object implements Java.TypeDeclaration
Abstract implementation of `Java.TypeDeclaration`.

## Field Summary

Fields
Modifier and Type
Field
Description
`int`
`anonymousClassCount`
For naming anonymous classes.
`int`
`localClassCount`
For naming local classes.

## Constructor Summary

Constructors
Constructor
Description
`AbstractTypeDeclaration(Location location, Java.Modifier[] modifiers, Java.TypeParameter[] typeParameters)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addDeclaredMethod(Java.MethodDeclarator method)`
Adds one `Java.MethodDeclarator` to this type.
`void`
`addMemberTypeDeclaration(Java.MemberTypeDeclaration mcoid)`
Adds one `Java.MemberTypeDeclaration` to this type.
`String`
`createAnonymousClassName()`
Creates a unique name for an anonymous class.
`String`
`createLocalTypeName(String localTypeName)`
Creates a unique name for a local class or interface.
`Java.Annotation[]`
`getAnnotations()`
`Java.Scope`
`getEnclosingScope()`
`Location`
`getLocation()`
`Java.MemberTypeDeclaration`
`getMemberTypeDeclaration(String name)`
Returns the member type with the given name.
`Collection<Java.MemberTypeDeclaration>`
`getMemberTypeDeclarations()`
`Java.MethodDeclarator`
`getMethodDeclaration(String name)`
Returns the first method declared with the given name.
`List<Java.MethodDeclarator>`
`getMethodDeclarations()`
`Java.Modifier[]`
`getModifiers()`
`Java.TypeParameter[]`
`getOptionalTypeParameters()`
`void`
`invalidateMethodCaches()`
Invalidates the method cache of the `resolvedType`.
`void`
`setEnclosingScope(Java.Scope enclosingScope)`
Sets the enclosing scope of this `Java.TypeDeclaration`.
`void`
`throwCompileException(String message)`
Throws a `CompileException` with the given message and this object's location.
`abstract String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.codehaus.janino.Java.TypeDeclaration

`accept, getClassName`

## Field Details

### anonymousClassCount

public int anonymousClassCount
For naming anonymous classes.

### localClassCount

public int localClassCount
For naming local classes.

## Constructor Details

### AbstractTypeDeclaration

public AbstractTypeDeclaration(Location location, Java.Modifier[] modifiers, @Nullable Java.TypeParameter[] typeParameters)

## Method Details

### setEnclosingScope

public void setEnclosingScope(Java.Scope enclosingScope)
Sets the enclosing scope of this `Java.TypeDeclaration`.

### getModifiers

public Java.Modifier[] getModifiers()

### getAnnotations

public Java.Annotation[] getAnnotations()

Specified by:
  `getAnnotations` in interface `Java.Annotatable`
Returns:
  The annotations of this `Java.TypeDeclaration`, `Java.FieldDeclaration`, `Java.MethodDeclarator` or `Java.ConstructorDeclarator`

### getOptionalTypeParameters

@Nullable public Java.TypeParameter[] getOptionalTypeParameters()

### getEnclosingScope

public Java.Scope getEnclosingScope()

Specified by:
  `getEnclosingScope` in interface `Java.Scope`
Returns:
  The scope that encloses this scope, or `null`

### invalidateMethodCaches

public void invalidateMethodCaches()
Invalidates the method cache of the `resolvedType`. This is necessary when methods are added during compilation

### addMemberTypeDeclaration

public void addMemberTypeDeclaration(Java.MemberTypeDeclaration mcoid)
Adds one `Java.MemberTypeDeclaration` to this type.

### addDeclaredMethod

public void addDeclaredMethod(Java.MethodDeclarator method)
Adds one `Java.MethodDeclarator` to this type.

### getMemberTypeDeclarations

public Collection<Java.MemberTypeDeclaration> getMemberTypeDeclarations()

Specified by:
  `getMemberTypeDeclarations` in interface `Java.TypeDeclaration`
Returns:
  The (possibly empty) set of member types declared inside this `Java.TypeDeclaration`

### getMemberTypeDeclaration

@Nullable public Java.MemberTypeDeclaration getMemberTypeDeclaration(String name)
Description copied from interface: `Java.TypeDeclaration`
Returns the member type with the given name.

Specified by:
  `getMemberTypeDeclaration` in interface `Java.TypeDeclaration`
Returns:
  `null` if a member type with that name is not declared

### getMethodDeclaration

@Nullable public Java.MethodDeclarator getMethodDeclaration(String name)
Description copied from interface: `Java.TypeDeclaration`
Returns the first method declared with the given name. (Does not honor inherited methods.)

Specified by:
  `getMethodDeclaration` in interface `Java.TypeDeclaration`
Returns:
  `null` if a method with this name is not declared

### getMethodDeclarations

public List<Java.MethodDeclarator> getMethodDeclarations()

Specified by:
  `getMethodDeclarations` in interface `Java.TypeDeclaration`
Returns:
  The list of methods declared in this `Java.TypeDeclaration`, not including methods declared in supertypes

### createLocalTypeName

public String createLocalTypeName(String localTypeName)
Description copied from interface: `Java.TypeDeclaration`
Creates a unique name for a local class or interface.

Specified by:
  `createLocalTypeName` in interface `Java.TypeDeclaration`

### createAnonymousClassName

public String createAnonymousClassName()
Description copied from interface: `Java.TypeDeclaration`
Creates a unique name for an anonymous class.

Specified by:
  `createAnonymousClassName` in interface `Java.TypeDeclaration`

### getLocation

public Location getLocation()

Specified by:
  `getLocation` in interface `Java.Locatable`
Returns:
  The location of this object

### throwCompileException

public void throwCompileException(String message) throws CompileException
Description copied from interface: `Java.Locatable`
Throws a `CompileException` with the given message and this object's location.

Specified by:
  `throwCompileException` in interface `Java.Locatable`
Parameters:
  `message` - The message to report
Throws:
  `CompileException`

### toString

public abstract String toString()

Overrides:
  `toString` in class `Object`