Fix odlparent-3.0.0 checkstyle issues
[mdsal.git] / binding2 / mdsal-binding2-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / javav2 / dom / adapter / spi / builder / BindingDOMAdapterBuilder.java
1 /*
2  * Copyright (c) 2017 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.javav2.dom.adapter.spi.builder;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import com.google.common.collect.ClassToInstanceMap;
13 import org.opendaylight.mdsal.binding.javav2.api.BindingService;
14 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.BindingToNormalizedNodeCodec;
15 import org.opendaylight.mdsal.dom.api.DOMService;
16
17 /**
18  * Binding DOM adapter builder instance.
19  *
20  * @param <T>
21  *            - Binding Service type
22  */
23 @Beta
24 public abstract class BindingDOMAdapterBuilder<T extends BindingService> extends AdapterBuilder<T, DOMService> {
25
26     private BindingToNormalizedNodeCodec codec;
27
28     protected abstract T createInstance(BindingToNormalizedNodeCodec myCodec, ClassToInstanceMap<DOMService> delegates);
29
30     @Override
31     protected final T createInstance(final ClassToInstanceMap<DOMService> delegates) {
32         Preconditions.checkState(codec != null);
33         return createInstance(codec, delegates);
34     }
35
36     /**
37      * Set codec for builder.
38      *
39      * @param codec
40      *            - binding normalized node codec
41      */
42     public void setCodec(final BindingToNormalizedNodeCodec codec) {
43         this.codec = codec;
44     }
45
46     /**
47      * Factory for creating of new builder.
48      *
49      * @param <T>
50      *            - Binding Service type
51      */
52     public interface Factory<T extends BindingService> {
53
54         /**
55          * Prepare new builder for service.
56          *
57          * @return adapter builder
58          */
59         BindingDOMAdapterBuilder<T> newBuilder();
60     }
61 }