From: Robert Varga Date: Wed, 11 Jul 2018 18:10:34 +0000 (+0200) Subject: Document Delegator and AbstractDelegator X-Git-Tag: v2.0.8~14 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=0d4575e50fdfb0e700b4b0b994aa00b884f41869;p=yangtools.git Document Delegator and AbstractDelegator Document Delegator.getDelegate() and add an abstract base class for implementations. Change-Id: I36426d1862b786fc5413baed7d6ded1fd3f5d4e5 Signed-off-by: Robert Varga --- diff --git a/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractDelegator.java b/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractDelegator.java new file mode 100644 index 0000000000..c847fca84e --- /dev/null +++ b/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractDelegator.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.yangtools.concepts; + +import static java.util.Objects.requireNonNull; + +import com.google.common.annotations.Beta; +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Simple base class for classes which wish to implement {@link Delegator} interface and are not otherwise constrained + * in their class hierarchy. + * + * @param Type of delegate + */ +@Beta +@NonNullByDefault +public abstract class AbstractDelegator implements Delegator { + private final T delegate; + + protected AbstractDelegator(final T delegate) { + this.delegate = requireNonNull(delegate); + } + + @Override + public final T getDelegate() { + return delegate; + } +} diff --git a/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/Delegator.java b/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/Delegator.java index 80373fba27..74509dc764 100644 --- a/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/Delegator.java +++ b/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/Delegator.java @@ -8,14 +8,15 @@ package org.opendaylight.yangtools.concepts; /** - * Implementation of this interface delegates all it's calls - * to the delegator if not specified otherwise. - * + * Implementation of this interface delegates all it's calls to the delegate if not specified otherwise. * * @param Type of delegate */ public interface Delegator { - + /** + * Return underlying delegate. + * + * @return underlying delegate. + */ T getDelegate(); - }