| /* |
| * Copyright (c) 2006, 2021 Oracle and/or its affiliates. All rights reserved. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0, |
| * or the Eclipse Distribution License v. 1.0 which is available at |
| * http://www.eclipse.org/org/documents/edl-v10.php. |
| * |
| * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause |
| */ |
| |
| // Contributors: |
| // Oracle - initial API and implementation |
| // |
| package org.eclipse.persistence.jpa.jpql.parser; |
| |
| /** |
| * This {@link ExpressionVisitor} wraps another {@link ExpressionVisitor} and delegates all its |
| * calls to it (the delegate). |
| * |
| * @version 2.4 |
| * @since 2.3 |
| * @author Pascal Filion |
| */ |
| @SuppressWarnings("nls") |
| public abstract class ExpressionVisitorWrapper extends AnonymousExpressionVisitor { |
| |
| /** |
| * The {@link ExpressionVisitor} that will have the calls delegated from this one. |
| */ |
| private final ExpressionVisitor delegate; |
| |
| /** |
| * Creates a new <code>ExpressionVisitorWrapper</code>. |
| */ |
| @SuppressWarnings("unused") |
| private ExpressionVisitorWrapper() { |
| this(null); |
| } |
| |
| /** |
| * Creates a new <code>ExpressionVisitorWrapper</code>. |
| * |
| * @param delegate The {@link ExpressionVisitor} that will have the calls delegated from this one |
| * @exception NullPointerException The delegate {@link ExpressionVisitor} cannot be null |
| */ |
| protected ExpressionVisitorWrapper(ExpressionVisitor delegate) { |
| super(); |
| if (delegate == null) { |
| throw new NullPointerException("The delegate ExpressionVisitor cannot be null"); |
| } |
| this.delegate = delegate; |
| } |
| |
| /** |
| * Returns the delegate {@link ExpressionVisitor} that is receiving all the calls from this one. |
| * |
| * @return The delegate {@link ExpressionVisitor} |
| */ |
| protected ExpressionVisitor getDelegate() { |
| return delegate; |
| } |
| |
| @Override |
| protected void visit(Expression expression) { |
| expression.accept(delegate); |
| } |
| } |