Remove yang-test
[controller.git] / opendaylight / config / config-manager-facade-xml / src / main / java / org / opendaylight / controller / config / facade / xml / mapping / config / InstanceConfigElementResolved.java
1 /*
2  * Copyright (c) 2015, 2017 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
9 package org.opendaylight.controller.config.facade.xml.mapping.config;
10
11 import java.util.Map;
12 import org.opendaylight.controller.config.facade.xml.exception.OperationNotPermittedException;
13 import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
14 import org.opendaylight.controller.config.facade.xml.strategy.EditConfigStrategy;
15 import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType;
16 import org.opendaylight.controller.config.util.xml.DocumentedException;
17
18 /**
19  * Parsed xml element containing whole configuration for an instance of some
20  * module. Contains preferred edit strategy type.
21  */
22 public class InstanceConfigElementResolved {
23
24     private final EditStrategyType editStrategy;
25     private final Map<String, AttributeConfigElement> configuration;
26
27     public InstanceConfigElementResolved(final String currentStrategy,
28             final Map<String, AttributeConfigElement> configuration, final EditStrategyType defaultStrategy)
29             throws DocumentedException {
30         this.editStrategy = parseStrategy(currentStrategy, defaultStrategy);
31         this.configuration = configuration;
32     }
33
34     public InstanceConfigElementResolved(final Map<String, AttributeConfigElement> configuration,
35             final EditStrategyType defaultStrategy) {
36         editStrategy = defaultStrategy;
37         this.configuration = configuration;
38     }
39
40     static EditStrategyType parseStrategy(final String currentStrategy, final EditStrategyType defaultStrategy)
41             throws OperationNotPermittedException {
42         EditStrategyType parsedStrategy = EditStrategyType.valueOf(currentStrategy);
43         EditStrategyType.compareParsedStrategyToDefaultEnforcing(parsedStrategy, defaultStrategy);
44         return parsedStrategy;
45     }
46
47     public EditConfigStrategy getEditStrategy() {
48         return editStrategy.getFittingStrategy();
49     }
50
51     public Map<String, AttributeConfigElement> getConfiguration() {
52         return configuration;
53     }
54 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.