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
8 package org.opendaylight.netconf.sal.connect.netconf;
10 import static java.util.Objects.requireNonNull;
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.schema.mapping.BaseNetconfSchemas;
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 salFacade;
27 private ListeningExecutorService globalProcessingExecutor;
28 private DeviceActionFactory deviceActionFactory;
29 private NetconfNode node;
30 private EventExecutor eventExecutor;
31 private NetconfNodeAugmentedOptional nodeOptional;
32 private BaseNetconfSchemas baseSchemas;
34 public NetconfDeviceBuilder() {
37 public NetconfDeviceBuilder setReconnectOnSchemasChange(final boolean reconnectOnSchemasChange) {
38 this.reconnectOnSchemasChange = reconnectOnSchemasChange;
42 public NetconfDeviceBuilder setId(final RemoteDeviceId id) {
47 public NetconfDeviceBuilder setSchemaResourcesDTO(final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO) {
48 this.schemaResourcesDTO = schemaResourcesDTO;
52 public NetconfDeviceBuilder setSalFacade(final RemoteDeviceHandler salFacade) {
53 this.salFacade = salFacade;
57 public NetconfDeviceBuilder setGlobalProcessingExecutor(final ListeningExecutorService globalProcessingExecutor) {
58 this.globalProcessingExecutor = globalProcessingExecutor;
62 public NetconfDeviceBuilder setDeviceActionFactory(final DeviceActionFactory deviceActionFactory) {
63 this.deviceActionFactory = deviceActionFactory;
67 public NetconfDeviceBuilder setNode(final NetconfNode node) {
72 public NetconfDeviceBuilder setEventExecutor(final EventExecutor eventExecutor) {
73 this.eventExecutor = eventExecutor;
77 public NetconfDeviceBuilder setNodeOptional(final NetconfNodeAugmentedOptional nodeOptional) {
78 this.nodeOptional = nodeOptional;
82 public NetconfDeviceBuilder setBaseSchemas(final BaseNetconfSchemas baseSchemas) {
83 this.baseSchemas = requireNonNull(baseSchemas);
87 public NetconfDevice build() {
89 return new NetconfDevice(schemaResourcesDTO, baseSchemas, id, salFacade,
90 globalProcessingExecutor, reconnectOnSchemasChange, deviceActionFactory, node,
91 eventExecutor, nodeOptional);
94 private void validation() {
95 requireNonNull(baseSchemas, "BaseSchemas is not initialized");
96 requireNonNull(id, "RemoteDeviceId is not initialized");
97 requireNonNull(salFacade, "RemoteDeviceHandler is not initialized");
98 requireNonNull(globalProcessingExecutor, "ExecutorService is not initialized");
99 requireNonNull(schemaResourcesDTO, "SchemaResourceDTO is not initialized");