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