X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager-facade-xml%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Ffacade%2Fxml%2Fstrategy%2FEditStrategyType.java;h=506159279138ee02e7fcfc3027c8410b4cd5cd72;hb=refs%2Fchanges%2F54%2F57354%2F8;hp=9954592b0a624268f446cfe20ae7e12174533b5d;hpb=f336ffef3aaf674ba23133cb5c5201105e5d8637;p=controller.git 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..5061592791 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,51 @@ 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"), + if (parsedStrategy != defaultStrategy) { + throw new OperationNotPermittedException("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); } } }