b94aedd1d53ff5c3c6984a62b9976d8598e40586
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / dom / adapter / AbstractBindingAdapter.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.dom.adapter;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.opendaylight.yangtools.concepts.Delegator;
14
15 @NonNullByDefault
16 abstract class AbstractBindingAdapter<T> implements Delegator<T> {
17     private final AdapterContext adapterContext;
18     private final T delegate;
19
20     AbstractBindingAdapter(final AdapterContext adapterContext, final T delegate) {
21         this.adapterContext = requireNonNull(adapterContext);
22         this.delegate = requireNonNull(delegate);
23     }
24
25     @Override
26     public final T getDelegate() {
27         return delegate;
28     }
29
30     protected final AdapterContext adapterContext() {
31         return adapterContext;
32     }
33
34     protected final CurrentAdapterSerializer currentSerializer() {
35         return adapterContext.currentSerializer();
36     }
37 }