2 * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.spi.meta;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Optional;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.concepts.Delegator;
15 import org.opendaylight.yangtools.yang.common.Empty;
16 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
20 * Abstract base class for {@link DeclaredStatement} implementations which decorate a statement with a
21 * {@link DeclarationReference}.
23 * @param <A> Argument type ({@link Empty} if statement does not have argument.)
24 * @param <D> Class representing declared version of this statement.
26 public abstract class AbstractRefStatement<A, D extends DeclaredStatement<A>>
27 extends ForwardingDeclaredStatement<A, D> implements Delegator<D> {
28 private final @NonNull DeclarationReference ref;
29 private final @NonNull D delegate;
31 protected AbstractRefStatement(final D delegate, final DeclarationReference ref) {
32 this.delegate = requireNonNull(delegate);
33 this.ref = requireNonNull(ref);
37 public final Optional<DeclarationReference> declarationReference() {
38 return Optional.of(ref);
42 public final D getDelegate() {
47 protected final D delegate() {