X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager-facade-xml%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Ffacade%2Fxml%2Fstrategy%2FEditStrategyType.java;h=bf11f2a13770b3403f56563e64080ab49ff79980;hp=9954592b0a624268f446cfe20ae7e12174533b5d;hb=d266f4384d4850af9049d7cddd2bbac8f75ba61e;hpb=b197d75e803beac663033287d769dce62c108490 diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/EditStrategyType.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/EditStrategyType.java index 9954592b0a..bf11f2a137 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/EditStrategyType.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/EditStrategyType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2015, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -19,7 +19,7 @@ public enum EditStrategyType { // additional per element delete, remove, recreate; - private static final Set defaultStrats = EnumSet.of(merge, replace, none); + private static final Set DEFAULT_STRATS = EnumSet.of(merge, replace, none); public static EditStrategyType getDefaultStrategy() { return merge; @@ -27,50 +27,50 @@ public enum EditStrategyType { public boolean isEnforcing() { switch (this) { - case merge: - case none: - case remove: - case delete: - case recreate: - return false; - case replace: - return true; + case merge: + case none: + case remove: + case delete: + case recreate: + return false; + case replace: + return true; - default: - throw new IllegalStateException("Default edit strategy can be only of value " + defaultStrats + " but was " - + this); + default: + throw new IllegalStateException( + "Default edit strategy can be only of value " + DEFAULT_STRATS + " but was " + this); } } + public static void compareParsedStrategyToDefaultEnforcing(EditStrategyType parsedStrategy, - EditStrategyType defaultStrategy) throws OperationNotPermittedException { + EditStrategyType defaultStrategy) throws OperationNotPermittedException { if (defaultStrategy.isEnforcing()) { - if (parsedStrategy != defaultStrategy){ - throw new OperationNotPermittedException(String.format("With " - + defaultStrategy - + " as default-operation operations on module elements are not permitted since the default option is restrictive"), - DocumentedException.ErrorType.APPLICATION, - DocumentedException.ErrorTag.OPERATION_FAILED, + if (parsedStrategy != defaultStrategy) { + throw new OperationNotPermittedException(String.format("With " + defaultStrategy + + " as default-operation operations on module elements are not permitted" + + "since the default option is restrictive"), + DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); } } - } + public EditConfigStrategy getFittingStrategy() { switch (this) { - case merge: - return new MergeEditConfigStrategy(); - case replace: - return new ReplaceEditConfigStrategy(); - case delete: - return new DeleteEditConfigStrategy(); - case remove: - return new RemoveEditConfigStrategy(); - case recreate: - return new ReCreateEditConfigStrategy(); - case none: - return new NoneEditConfigStrategy(); - default: - throw new UnsupportedOperationException("Unimplemented edit config strategy" + this); + case merge: + return new MergeEditConfigStrategy(); + case replace: + return new ReplaceEditConfigStrategy(); + case delete: + return new DeleteEditConfigStrategy(); + case remove: + return new RemoveEditConfigStrategy(); + case recreate: + return new ReCreateEditConfigStrategy(); + case none: + return new NoneEditConfigStrategy(); + default: + throw new UnsupportedOperationException("Unimplemented edit config strategy" + this); } } }