class InstanceOfExpr extends Expression implements NodeWithType<InstanceOfExpr, ReferenceType>, NodeWithExpression<InstanceOfExpr> {

    private Expression expression;

    @OptionalProperty
    private PatternExpr pattern;

    private ReferenceType type;

    public InstanceOfExpr() {
        this(null, new NameExpr(), new ClassOrInterfaceType(), null);
    }

    public InstanceOfExpr(final Expression expression, final ReferenceType type) {
        this(null, expression, type, null);
    }

    @AllFieldsConstructor
    public InstanceOfExpr(final Expression expression, final ReferenceType type, final PatternExpr pattern) {
        this(null, expression, type, pattern);
    }

    /**
     * This constructor is used by the parser and is considered private.
     */
    @Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator")
    public InstanceOfExpr(TokenRange tokenRange, Expression expression, ReferenceType type, PatternExpr pattern) {
        super(tokenRange);
        setExpression(expression);
        setType(type);
        setPattern(pattern);
        customInitialization();
    }

    /**
     * Helper method which, if this is an expression with a pattern, returns the identifier/name.
     * <br>
     * <br>For example:
     * <br>{@code obj instanceof String stringName}
     * <br>
     * <br>In this example, {@code getName()} returns {@code stringName}
     */
    public Optional<SimpleName> getName() {
        if (pattern == null) {
            return Optional.empty();
        }
        return Optional.of(pattern.getName());
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.AcceptGenerator")
    public <R, A> R accept(final GenericVisitor<R, A> v, final A arg) {
        return v.visit(this, arg);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.AcceptGenerator")
    public <A> void accept(final VoidVisitor<A> v, final A arg) {
        v.visit(this, arg);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public InstanceOfExpr asInstanceOfExpr() {
        return this;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.CloneGenerator")
    public InstanceOfExpr clone() {
        return (InstanceOfExpr) accept(new CloneVisitor(), null);
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public Expression getExpression() {
        return expression;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator")
    public InstanceOfExprMetaModel getMetaModel() {
        return JavaParserMetaModel.instanceOfExprMetaModel;
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public Optional<PatternExpr> getPattern() {
        return Optional.ofNullable(pattern);
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public ReferenceType getType() {
        return type;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public void ifInstanceOfExpr(Consumer<InstanceOfExpr> action) {
        action.accept(this);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public boolean isInstanceOfExpr() {
        return true;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
    public boolean remove(Node node) {
        if (node == null) {
            return false;
        }
        if (pattern != null) {
            if (node == pattern) {
                removePattern();
                return true;
            }
        }
        return super.remove(node);
    }

    @Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
    public InstanceOfExpr removePattern() {
        return setPattern((PatternExpr) null);
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator")
    public boolean replace(Node node, Node replacementNode) {
        if (node == null) {
            return false;
        }
        if (node == expression) {
            setExpression((Expression) replacementNode);
            return true;
        }
        if (pattern != null) {
            if (node == pattern) {
                setPattern((PatternExpr) replacementNode);
                return true;
            }
        }
        if (node == type) {
            setType((ReferenceType) replacementNode);
            return true;
        }
        return super.replace(node, replacementNode);
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public InstanceOfExpr setExpression(final Expression expression) {
        assertNotNull(expression);
        if (expression == this.expression) {
            return this;
        }
        notifyPropertyChange(ObservableProperty.EXPRESSION, this.expression, expression);
        if (this.expression != null)
            this.expression.setParentNode(null);
        this.expression = expression;
        setAsParentNodeOf(expression);
        return this;
    }

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public InstanceOfExpr setPattern(final PatternExpr pattern) {<FILL_FUNCTION_BODY>}

    @Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
    public InstanceOfExpr setType(final ReferenceType type) {
        assertNotNull(type);
        if (type == this.type) {
            return this;
        }
        notifyPropertyChange(ObservableProperty.TYPE, this.type, type);
        if (this.type != null)
            this.type.setParentNode(null);
        this.type = type;
        setAsParentNodeOf(type);
        return this;
    }

    @Override
    @Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
    public Optional<InstanceOfExpr> toInstanceOfExpr() {
        return Optional.of(this);
    }
}

        if (pattern == this.pattern) {
            return this;
        }
        notifyPropertyChange(ObservableProperty.PATTERN, this.pattern, pattern);
        if (this.pattern != null)
            this.pattern.setParentNode(null);
        this.pattern = pattern;
        setAsParentNodeOf(pattern);
        return this;
    
<methods>public void <init>() ,public void <init>(com.github.javaparser.TokenRange) ,public final boolean appearsInAssignmentContext() ,public final boolean appearsInInvocationContext() ,public com.github.javaparser.ast.expr.AnnotationExpr asAnnotationExpr() ,public com.github.javaparser.ast.expr.ArrayAccessExpr asArrayAccessExpr() ,public com.github.javaparser.ast.expr.ArrayCreationExpr asArrayCreationExpr() ,public com.github.javaparser.ast.expr.ArrayInitializerExpr asArrayInitializerExpr() ,public com.github.javaparser.ast.expr.AssignExpr asAssignExpr() ,public com.github.javaparser.ast.expr.BinaryExpr asBinaryExpr() ,public com.github.javaparser.ast.expr.BooleanLiteralExpr asBooleanLiteralExpr() ,public com.github.javaparser.ast.expr.CastExpr asCastExpr() ,public com.github.javaparser.ast.expr.CharLiteralExpr asCharLiteralExpr() ,public com.github.javaparser.ast.expr.ClassExpr asClassExpr() ,public com.github.javaparser.ast.expr.ConditionalExpr asConditionalExpr() ,public com.github.javaparser.ast.expr.DoubleLiteralExpr asDoubleLiteralExpr() ,public com.github.javaparser.ast.expr.EnclosedExpr asEnclosedExpr() ,public com.github.javaparser.ast.expr.FieldAccessExpr asFieldAccessExpr() ,public com.github.javaparser.ast.expr.InstanceOfExpr asInstanceOfExpr() ,public com.github.javaparser.ast.expr.IntegerLiteralExpr asIntegerLiteralExpr() ,public com.github.javaparser.ast.expr.LambdaExpr asLambdaExpr() ,public com.github.javaparser.ast.expr.LiteralExpr asLiteralExpr() ,public com.github.javaparser.ast.expr.LiteralStringValueExpr asLiteralStringValueExpr() ,public com.github.javaparser.ast.expr.LongLiteralExpr asLongLiteralExpr() ,public com.github.javaparser.ast.expr.MarkerAnnotationExpr asMarkerAnnotationExpr() ,public com.github.javaparser.ast.expr.MethodCallExpr asMethodCallExpr() ,public com.github.javaparser.ast.expr.MethodReferenceExpr asMethodReferenceExpr() ,public com.github.javaparser.ast.expr.NameExpr asNameExpr() ,public com.github.javaparser.ast.expr.NormalAnnotationExpr asNormalAnnotationExpr() ,public com.github.javaparser.ast.expr.NullLiteralExpr asNullLiteralExpr() ,public com.github.javaparser.ast.expr.ObjectCreationExpr asObjectCreationExpr() ,public com.github.javaparser.ast.expr.PatternExpr asPatternExpr() ,public com.github.javaparser.ast.expr.SingleMemberAnnotationExpr asSingleMemberAnnotationExpr() ,public com.github.javaparser.ast.expr.StringLiteralExpr asStringLiteralExpr() ,public com.github.javaparser.ast.expr.SuperExpr asSuperExpr() ,public com.github.javaparser.ast.expr.SwitchExpr asSwitchExpr() ,public com.github.javaparser.ast.expr.TextBlockLiteralExpr asTextBlockLiteralExpr() ,public com.github.javaparser.ast.expr.ThisExpr asThisExpr() ,public com.github.javaparser.ast.expr.TypeExpr asTypeExpr() ,public com.github.javaparser.ast.expr.UnaryExpr asUnaryExpr() ,public com.github.javaparser.ast.expr.VariableDeclarationExpr asVariableDeclarationExpr() ,public com.github.javaparser.resolution.types.ResolvedType calculateResolvedType() ,public com.github.javaparser.ast.expr.Expression clone() ,public final boolean elidesTypeArguments() ,public com.github.javaparser.metamodel.ExpressionMetaModel getMetaModel() ,public void ifAnnotationExpr(Consumer<com.github.javaparser.ast.expr.AnnotationExpr>) ,public void ifArrayAccessExpr(Consumer<com.github.javaparser.ast.expr.ArrayAccessExpr>) ,public void ifArrayCreationExpr(Consumer<com.github.javaparser.ast.expr.ArrayCreationExpr>) ,public void ifArrayInitializerExpr(Consumer<com.github.javaparser.ast.expr.ArrayInitializerExpr>) ,public void ifAssignExpr(Consumer<com.github.javaparser.ast.expr.AssignExpr>) ,public void ifBinaryExpr(Consumer<com.github.javaparser.ast.expr.BinaryExpr>) ,public void ifBooleanLiteralExpr(Consumer<com.github.javaparser.ast.expr.BooleanLiteralExpr>) ,public void ifCastExpr(Consumer<com.github.javaparser.ast.expr.CastExpr>) ,public void ifCharLiteralExpr(Consumer<com.github.javaparser.ast.expr.CharLiteralExpr>) ,public void ifClassExpr(Consumer<com.github.javaparser.ast.expr.ClassExpr>) ,public void ifConditionalExpr(Consumer<com.github.javaparser.ast.expr.ConditionalExpr>) ,public void ifDoubleLiteralExpr(Consumer<com.github.javaparser.ast.expr.DoubleLiteralExpr>) ,public void ifEnclosedExpr(Consumer<com.github.javaparser.ast.expr.EnclosedExpr>) ,public void ifFieldAccessExpr(Consumer<com.github.javaparser.ast.expr.FieldAccessExpr>) ,public void ifInstanceOfExpr(Consumer<com.github.javaparser.ast.expr.InstanceOfExpr>) ,public void ifIntegerLiteralExpr(Consumer<com.github.javaparser.ast.expr.IntegerLiteralExpr>) ,public void ifLambdaExpr(Consumer<com.github.javaparser.ast.expr.LambdaExpr>) ,public void ifLiteralExpr(Consumer<com.github.javaparser.ast.expr.LiteralExpr>) ,public void ifLiteralStringValueExpr(Consumer<com.github.javaparser.ast.expr.LiteralStringValueExpr>) ,public void ifLongLiteralExpr(Consumer<com.github.javaparser.ast.expr.LongLiteralExpr>) ,public void ifMarkerAnnotationExpr(Consumer<com.github.javaparser.ast.expr.MarkerAnnotationExpr>) ,public void ifMethodCallExpr(Consumer<com.github.javaparser.ast.expr.MethodCallExpr>) ,public void ifMethodReferenceExpr(Consumer<com.github.javaparser.ast.expr.MethodReferenceExpr>) ,public void ifNameExpr(Consumer<com.github.javaparser.ast.expr.NameExpr>) ,public void ifNormalAnnotationExpr(Consumer<com.github.javaparser.ast.expr.NormalAnnotationExpr>) ,public void ifNullLiteralExpr(Consumer<com.github.javaparser.ast.expr.NullLiteralExpr>) ,public void ifObjectCreationExpr(Consumer<com.github.javaparser.ast.expr.ObjectCreationExpr>) ,public void ifPatternExpr(Consumer<com.github.javaparser.ast.expr.PatternExpr>) ,public void ifSingleMemberAnnotationExpr(Consumer<com.github.javaparser.ast.expr.SingleMemberAnnotationExpr>) ,public void ifStringLiteralExpr(Consumer<com.github.javaparser.ast.expr.StringLiteralExpr>) ,public void ifSuperExpr(Consumer<com.github.javaparser.ast.expr.SuperExpr>) ,public void ifSwitchExpr(Consumer<com.github.javaparser.ast.expr.SwitchExpr>) ,public void ifTextBlockLiteralExpr(Consumer<com.github.javaparser.ast.expr.TextBlockLiteralExpr>) ,public void ifThisExpr(Consumer<com.github.javaparser.ast.expr.ThisExpr>) ,public void ifTypeExpr(Consumer<com.github.javaparser.ast.expr.TypeExpr>) ,public void ifUnaryExpr(Consumer<com.github.javaparser.ast.expr.UnaryExpr>) ,public void ifVariableDeclarationExpr(Consumer<com.github.javaparser.ast.expr.VariableDeclarationExpr>) ,public boolean isAnnotationExpr() ,public boolean isArrayAccessExpr() ,public boolean isArrayCreationExpr() ,public boolean isArrayInitializerExpr() ,public boolean isAssignExpr() ,public boolean isBinaryExpr() ,public boolean isBooleanLiteralExpr() ,public boolean isCastExpr() ,public boolean isCharLiteralExpr() ,public boolean isClassExpr() ,public boolean isConditionalExpr() ,public boolean isDoubleLiteralExpr() ,public boolean isEnclosedExpr() ,public boolean isFieldAccessExpr() ,public boolean isInstanceOfExpr() ,public boolean isIntegerLiteralExpr() ,public boolean isLambdaExpr() ,public boolean isLiteralExpr() ,public boolean isLiteralStringValueExpr() ,public boolean isLongLiteralExpr() ,public boolean isMarkerAnnotationExpr() ,public boolean isMethodCallExpr() ,public boolean isMethodReferenceExpr() ,public boolean isNameExpr() ,public boolean isNormalAnnotationExpr() ,public boolean isNullLiteralExpr() ,public boolean isObjectCreationExpr() ,public boolean isPatternExpr() ,public boolean isPolyExpression() ,public boolean isQualified() ,public boolean isSingleMemberAnnotationExpr() ,public boolean isStandaloneExpression() ,public boolean isStringLiteralExpr() ,public boolean isSuperExpr() ,public boolean isSwitchExpr() ,public boolean isTextBlockLiteralExpr() ,public boolean isThisExpr() ,public boolean isTypeExpr() ,public boolean isUnaryExpr() ,public boolean isVariableDeclarationExpr() ,public Optional<com.github.javaparser.ast.expr.AnnotationExpr> toAnnotationExpr() ,public Optional<com.github.javaparser.ast.expr.ArrayAccessExpr> toArrayAccessExpr() ,public Optional<com.github.javaparser.ast.expr.ArrayCreationExpr> toArrayCreationExpr() ,public Optional<com.github.javaparser.ast.expr.ArrayInitializerExpr> toArrayInitializerExpr() ,public Optional<com.github.javaparser.ast.expr.AssignExpr> toAssignExpr() ,public Optional<com.github.javaparser.ast.expr.BinaryExpr> toBinaryExpr() ,public Optional<com.github.javaparser.ast.expr.BooleanLiteralExpr> toBooleanLiteralExpr() ,public Optional<com.github.javaparser.ast.expr.CastExpr> toCastExpr() ,public Optional<com.github.javaparser.ast.expr.CharLiteralExpr> toCharLiteralExpr() ,public Optional<com.github.javaparser.ast.expr.ClassExpr> toClassExpr() ,public Optional<com.github.javaparser.ast.expr.ConditionalExpr> toConditionalExpr() ,public Optional<com.github.javaparser.ast.expr.DoubleLiteralExpr> toDoubleLiteralExpr() ,public Optional<com.github.javaparser.ast.expr.EnclosedExpr> toEnclosedExpr() ,public Optional<com.github.javaparser.ast.expr.FieldAccessExpr> toFieldAccessExpr() ,public Optional<com.github.javaparser.ast.expr.InstanceOfExpr> toInstanceOfExpr() ,public Optional<com.github.javaparser.ast.expr.IntegerLiteralExpr> toIntegerLiteralExpr() ,public Optional<com.github.javaparser.ast.expr.LambdaExpr> toLambdaExpr() ,public Optional<com.github.javaparser.ast.expr.LiteralExpr> toLiteralExpr() ,public Optional<com.github.javaparser.ast.expr.LiteralStringValueExpr> toLiteralStringValueExpr() ,public Optional<com.github.javaparser.ast.expr.LongLiteralExpr> toLongLiteralExpr() ,public Optional<com.github.javaparser.ast.expr.MarkerAnnotationExpr> toMarkerAnnotationExpr() ,public Optional<com.github.javaparser.ast.expr.MethodCallExpr> toMethodCallExpr() ,public Optional<com.github.javaparser.ast.expr.MethodReferenceExpr> toMethodReferenceExpr() ,public Optional<com.github.javaparser.ast.expr.NameExpr> toNameExpr() ,public Optional<com.github.javaparser.ast.expr.NormalAnnotationExpr> toNormalAnnotationExpr() ,public Optional<com.github.javaparser.ast.expr.NullLiteralExpr> toNullLiteralExpr() ,public Optional<com.github.javaparser.ast.expr.ObjectCreationExpr> toObjectCreationExpr() ,public Optional<com.github.javaparser.ast.expr.PatternExpr> toPatternExpr() ,public Optional<com.github.javaparser.ast.expr.SingleMemberAnnotationExpr> toSingleMemberAnnotationExpr() ,public Optional<com.github.javaparser.ast.expr.StringLiteralExpr> toStringLiteralExpr() ,public Optional<com.github.javaparser.ast.expr.SuperExpr> toSuperExpr() ,public Optional<com.github.javaparser.ast.expr.SwitchExpr> toSwitchExpr() ,public Optional<com.github.javaparser.ast.expr.TextBlockLiteralExpr> toTextBlockLiteralExpr() ,public Optional<com.github.javaparser.ast.expr.ThisExpr> toThisExpr() ,public Optional<com.github.javaparser.ast.expr.TypeExpr> toTypeExpr() ,public Optional<com.github.javaparser.ast.expr.UnaryExpr> toUnaryExpr() ,public Optional<com.github.javaparser.ast.expr.VariableDeclarationExpr> toVariableDeclarationExpr() <variables>public static final Function<com.github.javaparser.ast.expr.Expression,com.github.javaparser.ast.expr.Expression> EXCLUDE_ENCLOSED_EXPR,public static final Predicate<com.github.javaparser.ast.Node> IS_NOT_ENCLOSED_EXPR