2 * Copyright (c) 2016 Cisco Systems, Inc. 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
9 package org.opendaylight.netconf.sal.connect.netconf;
11 import com.google.common.base.Preconditions;
12 import com.google.common.util.concurrent.ListeningExecutorService;
13 import io.netty.util.concurrent.EventExecutor;
14 import org.opendaylight.netconf.sal.connect.api.DeviceActionFactory;
15 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
16 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
17 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.optional.rev190614.NetconfNodeAugmentedOptional;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
21 public class NetconfDeviceBuilder {
23 private boolean reconnectOnSchemasChange;
24 private NetconfDevice.SchemaResourcesDTO schemaResourcesDTO;
25 private RemoteDeviceId id;
26 private RemoteDeviceHandler<NetconfSessionPreferences> salFacade;
27 private ListeningExecutorService globalProcessingExecutor;
28 private DeviceActionFactory deviceActionFactory;
29 private NetconfNode node;
30 private EventExecutor eventExecutor;
31 private NetconfNodeAugmentedOptional nodeOptional;
33 public NetconfDeviceBuilder() {
36 public NetconfDeviceBuilder setReconnectOnSchemasChange(final boolean reconnectOnSchemasChange) {
37 this.reconnectOnSchemasChange = reconnectOnSchemasChange;
41 public NetconfDeviceBuilder setId(final RemoteDeviceId id) {
46 public NetconfDeviceBuilder setSchemaResourcesDTO(final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO) {
47 this.schemaResourcesDTO = schemaResourcesDTO;
51 public NetconfDeviceBuilder setSalFacade(final RemoteDeviceHandler<NetconfSessionPreferences> salFacade) {
52 this.salFacade = salFacade;
56 public NetconfDeviceBuilder setGlobalProcessingExecutor(final ListeningExecutorService globalProcessingExecutor) {
57 this.globalProcessingExecutor = globalProcessingExecutor;
61 public NetconfDeviceBuilder setDeviceActionFactory(final DeviceActionFactory deviceActionFactory) {
62 this.deviceActionFactory = deviceActionFactory;
66 public NetconfDeviceBuilder setNode(final NetconfNode node) {
71 public NetconfDeviceBuilder setEventExecutor(final EventExecutor eventExecutor) {
72 this.eventExecutor = eventExecutor;
76 public NetconfDeviceBuilder setNodeOptional(final NetconfNodeAugmentedOptional nodeOptional) {
77 this.nodeOptional = nodeOptional;
81 public NetconfDevice build() {
83 return new NetconfDevice(this.schemaResourcesDTO, this.id, this.salFacade, this.globalProcessingExecutor,
84 this.reconnectOnSchemasChange, this.deviceActionFactory, this.node, this.eventExecutor,
88 private void validation() {
89 Preconditions.checkNotNull(this.id, "RemoteDeviceId is not initialized");
90 Preconditions.checkNotNull(this.salFacade, "RemoteDeviceHandler is not initialized");
91 Preconditions.checkNotNull(this.globalProcessingExecutor, "ExecutorService is not initialized");
92 Preconditions.checkNotNull(this.schemaResourcesDTO, "SchemaResourceDTO is not initialized");