Document Delegator and AbstractDelegator 50/73950/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Jul 2018 18:10:34 +0000 (20:10 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Jul 2018 18:10:34 +0000 (20:10 +0200)
Document Delegator.getDelegate() and add an abstract base class
for implementations.

Change-Id: I36426d1862b786fc5413baed7d6ded1fd3f5d4e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractDelegator.java [new file with mode: 0644]
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/Delegator.java

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 (file)
index 0000000..c847fca
--- /dev/null
@@ -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 <T> Type of delegate
+ */
+@Beta
+@NonNullByDefault
+public abstract class AbstractDelegator<T> implements Delegator<T> {
+    private final T delegate;
+
+    protected AbstractDelegator(final T delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    @Override
+    public final T getDelegate() {
+        return delegate;
+    }
+}
index 80373fba278607979c67c4c3d232147b3f43881a..74509dc76440a754b1fb7b638f12af1161538aee 100644 (file)
@@ -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 <T> Type of delegate
  */
 public interface Delegator<T> {
-
+    /**
+     * Return underlying delegate.
+     *
+     * @return underlying delegate.
+     */
     T getDelegate();
-
 }