All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
/**
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */

package net.sourceforge.pmd.lang.java.ast;

import java.util.List;

import net.sourceforge.pmd.lang.ast.Node;


/**
 * Represents class and interface declarations.
 * This is a {@linkplain Node#isFindBoundary() find boundary} for tree traversal methods.
 *
 * 
 *
 * ClassOrInterfaceDeclaration ::= {@link ASTModifierList ModifierList}
 *                                 ( "class" | "interface" )
 *                                 <IDENTIFIER>
 *                                 {@link ASTTypeParameters TypeParameters}?
 *                                 {@link ASTExtendsList ExtendsList}?
 *                                 {@link ASTImplementsList ImplementsList}?
 *                                 {@link ASTClassOrInterfaceBody ClassOrInterfaceBody}
 *
 * 
*/ public final class ASTClassOrInterfaceDeclaration extends AbstractAnyTypeDeclaration { private boolean isInterface; ASTClassOrInterfaceDeclaration(int id) { super(id); } @Override protected R acceptVisitor(JavaVisitor visitor, P data) { return visitor.visit(this, data); } @Override public boolean isPackagePrivate() { return super.isPackagePrivate() && !isLocal(); } @Override public boolean isInterface() { return this.isInterface; } @Override public boolean isRegularClass() { return !isInterface; } @Override public boolean isRegularInterface() { return isInterface; } void setInterface() { this.isInterface = true; } /** * Returns the superclass type node if this node is a class * declaration and explicitly declares an {@code extends} * clause. Superinterfaces of an interface are not considered. * *

Returns {@code null} otherwise. */ public ASTClassOrInterfaceType getSuperClassTypeNode() { if (isInterface()) { return null; } ASTExtendsList extendsList = getFirstChildOfType(ASTExtendsList.class); return extendsList == null ? null : extendsList.iterator().next(); } public List getPermittedSubclasses() { return ASTList.orEmpty(children(ASTPermitsList.class).first()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy