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 org.opendaylight.netconf.sal.connect.api.DeviceActionFactory;
14 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
15 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceId;
16 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO;
17 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseNetconfSchemas;
19 public class NetconfDeviceBuilder {
20 private boolean reconnectOnSchemasChange;
21 private SchemaResourcesDTO schemaResourcesDTO;
22 private RemoteDeviceId id;
23 private RemoteDeviceHandler salFacade;
24 private ListeningExecutorService globalProcessingExecutor;
25 private DeviceActionFactory deviceActionFactory;
26 private BaseNetconfSchemas baseSchemas;
28 public NetconfDeviceBuilder() {
31 public NetconfDeviceBuilder setReconnectOnSchemasChange(final boolean reconnectOnSchemasChange) {
32 this.reconnectOnSchemasChange = reconnectOnSchemasChange;
36 public NetconfDeviceBuilder setId(final RemoteDeviceId id) {
41 public NetconfDeviceBuilder setSchemaResourcesDTO(final SchemaResourcesDTO schemaResourcesDTO) {
42 this.schemaResourcesDTO = schemaResourcesDTO;
46 public NetconfDeviceBuilder setSalFacade(final RemoteDeviceHandler salFacade) {
47 this.salFacade = salFacade;
51 public NetconfDeviceBuilder setGlobalProcessingExecutor(final ListeningExecutorService globalProcessingExecutor) {
52 this.globalProcessingExecutor = globalProcessingExecutor;
56 public NetconfDeviceBuilder setDeviceActionFactory(final DeviceActionFactory deviceActionFactory) {
57 this.deviceActionFactory = deviceActionFactory;
61 public NetconfDeviceBuilder setBaseSchemas(final BaseNetconfSchemas baseSchemas) {
62 this.baseSchemas = requireNonNull(baseSchemas);
66 public NetconfDevice build() {
68 return new NetconfDevice(schemaResourcesDTO, baseSchemas, id, salFacade,
69 globalProcessingExecutor, reconnectOnSchemasChange, deviceActionFactory);
72 private void validation() {
73 requireNonNull(baseSchemas, "BaseSchemas is not initialized");
74 requireNonNull(id, "RemoteDeviceId is not initialized");
75 requireNonNull(salFacade, "RemoteDeviceHandler is not initialized");
76 requireNonNull(globalProcessingExecutor, "ExecutorService is not initialized");
77 requireNonNull(schemaResourcesDTO, "SchemaResourceDTO is not initialized");