Move sal-netconf-connector to plugins/
[netconf.git] / plugins / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / listener / UserPreferences.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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.netconf.sal.connect.netconf.listener;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.eclipse.jdt.annotation.NonNull;
13
14 /**
15  * DTO with user capabilities to override or merge with device specific capabilities.
16  */
17 public record UserPreferences(
18         @NonNull NetconfSessionPreferences sessionPreferences,
19         boolean overrideModuleCapabilities,
20         boolean overrideNonModuleCapabilities) {
21
22     public UserPreferences {
23         requireNonNull(sessionPreferences);
24
25         if (overrideModuleCapabilities && sessionPreferences.moduleBasedCaps().isEmpty()) {
26             throw new IllegalStateException(
27                     "Override module based capabilities flag set true but module based capabilities list is empty.");
28         }
29         if (overrideNonModuleCapabilities && sessionPreferences.nonModuleCaps().isEmpty()) {
30             throw new IllegalStateException(
31                     "Override non-module based capabilities set true but non-module based capabilities list is empty.");
32         }
33     }
34
35 }