2 * Copyright (c) 2013 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.controller.netconf.confignetconfconnector.operations.editconfig;
11 import java.util.EnumSet;
14 import com.google.common.base.Preconditions;
16 //FIXME: make thread safe
17 public enum EditStrategyType {
20 // additional per element
23 private static final Set<EditStrategyType> defaultStrats = EnumSet.of(merge, replace, none);
25 private static EditStrategyType defaultStrat = merge;
27 public static EditStrategyType defaultStrategy() {
31 public static void setDefaultStrategy(EditStrategyType strat) {
32 Preconditions.checkArgument(strat.canBeDefault(), "Default edit strategy can be only of value " + defaultStrats
33 + ", but was " + strat);
37 public static void resetDefaultStrategy() {
38 setDefaultStrategy(EditStrategyType.merge);
41 public boolean isEnforcing() {
52 throw new IllegalStateException("Default edit strategy can be only of value " + defaultStrats + " but was "
57 private static final EnumSet<EditStrategyType> defaults;
60 defaults = EnumSet.of(merge, replace, none);
63 private boolean canBeDefault() {
64 return defaults.contains(this);
67 public EditConfigStrategy getFittingStrategy() {
70 return new MergeEditConfigStrategy();
72 return new ReplaceEditConfigStrategy();
74 return new DeleteEditConfigStrategy();
76 return new RemoveEditConfigStrategy();
78 return new NoneEditConfigStrategy();
80 throw new UnsupportedOperationException("Unimplemented edit config strategy" + this);