Class JavaVisitorBase<P,​R>

  • All Implemented Interfaces:
    AstVisitor<P,​R>, JavaVisitor<P,​R>
    Direct Known Subclasses:
    JavaParserVisitorAdapter, LazyTypeResolver

    public class JavaVisitorBase<P,​R>
    extends AstVisitorBase<P,​R>
    implements JavaVisitor<P,​R>
    Base implementation of JavaVisitor. This adds delegation logic which the interface doesn't have.

    Contrary to the old visitor, which used Object as both parameter and return type, this visitor uses separate type parameters for those. This means you can't just return the parameter, unless your visitor has equal parameter and return type. This type signature subsumes many possible signatures. The old one is <Object, Object>, still implemented by JavaParserVisitor for backwards compatibility. If you don't want to return a value, or don't want a parameter, use Void.

    Since 7.0.0 we use default methods on the interface, which removes code duplication. However it's still recommended to extend a base class, for forward compatibility.