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 java.util.concurrent.ExecutorService;
13 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
14 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
15 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
17 public class NetconfDeviceBuilder {
19 private boolean reconnectOnSchemasChange;
20 private NetconfDevice.SchemaResourcesDTO schemaResourcesDTO;
21 private RemoteDeviceId id;
22 private RemoteDeviceHandler<NetconfSessionPreferences> salFacade;
23 private ExecutorService globalProcessingExecutor;
25 public NetconfDeviceBuilder() {
28 public NetconfDeviceBuilder setReconnectOnSchemasChange(boolean reconnectOnSchemasChange) {
29 this.reconnectOnSchemasChange = reconnectOnSchemasChange;
33 public NetconfDeviceBuilder setId(RemoteDeviceId id) {
38 public NetconfDeviceBuilder setSchemaResourcesDTO(NetconfDevice.SchemaResourcesDTO schemaResourcesDTO) {
39 this.schemaResourcesDTO = schemaResourcesDTO;
43 public NetconfDeviceBuilder setSalFacade(RemoteDeviceHandler<NetconfSessionPreferences> salFacade) {
44 this.salFacade = salFacade;
48 public NetconfDeviceBuilder setGlobalProcessingExecutor(ExecutorService globalProcessingExecutor) {
49 this.globalProcessingExecutor = globalProcessingExecutor;
53 public NetconfDevice build() {
55 return new NetconfDevice(schemaResourcesDTO, id, salFacade, globalProcessingExecutor, reconnectOnSchemasChange);
58 private void validation() {
59 Preconditions.checkNotNull(id, "RemoteDeviceId is not initialized");
60 Preconditions.checkNotNull(salFacade, "RemoteDeviceHandler is not initialized");
61 Preconditions.checkNotNull(globalProcessingExecutor, "ExecutorService is not initialized");
62 Preconditions.checkNotNull(schemaResourcesDTO, "SchemaResourceDTO is not initialized");