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 public enum EditStrategyType {
19 // additional per element
22 private static final Set<EditStrategyType> defaultStrats = EnumSet.of(merge, replace, none);
24 private static EditStrategyType defaultStrat = merge;
26 public static EditStrategyType defaultStrategy() {
30 public static void setDefaultStrategy(EditStrategyType strat) {
31 Preconditions.checkArgument(strat.canBeDefault(), "Default edit strategy can be only of value " + defaultStrats
32 + ", but was " + strat);
36 public static void resetDefaultStrategy() {
37 setDefaultStrategy(EditStrategyType.merge);
40 public boolean isEnforcing() {
51 throw new IllegalStateException("Default edit strategy can be only of value " + defaultStrats + " but was "
56 private static final EnumSet<EditStrategyType> defaults;
59 defaults = EnumSet.of(merge, replace, none);
62 private boolean canBeDefault() {
63 return defaults.contains(this);
66 public EditConfigStrategy getFittingStrategy() {
69 return new MergeEditConfigStrategy();
71 return new ReplaceEditConfigStrategy();
73 return new DeleteEditConfigStrategy();
75 return new RemoveEditConfigStrategy();
77 return new NoneEditConfigStrategy();
79 throw new UnsupportedOperationException("Unimplemented edit config strategy" + this);