org.checkerframework.dataflow.cfg.node.ClassDeclarationNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
The Checker Framework enhances Java's type system to
make it more powerful and useful. This lets software developers
detect and prevent errors in their Java programs.
The Checker Framework includes compiler plug-ins ("checkers")
that find bugs or verify their absence. It also permits you to
write your own compiler plug-ins.
package org.checkerframework.dataflow.cfg.node;
import com.sun.source.tree.ClassTree;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.javacutil.TreeUtils;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
/**
* A node representing a class declaration that occurs within a method, for example, an anonymous
* class declaration. In contrast to a top-level class declaration, such a declaration has an
* initialization store that contains captured variables.
*/
public class ClassDeclarationNode extends Node {
protected final ClassTree tree;
public ClassDeclarationNode(ClassTree tree) {
super(TreeUtils.typeOf(tree));
this.tree = tree;
}
@Override
public ClassTree getTree() {
return tree;
}
@Override
public R accept(NodeVisitor visitor, P p) {
return visitor.visitClassDeclaration(this, p);
}
@Override
public String toString() {
return tree.toString();
}
@Override
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ClassDeclarationNode that = (ClassDeclarationNode) o;
return Objects.equals(tree, that.tree);
}
@Override
public int hashCode() {
return Objects.hash(tree);
}
@Override
@SideEffectFree
public Collection getOperands() {
return Collections.emptyList();
}
}