/*
- * 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,
// additional per element
delete, remove, recreate;
- private static final Set<EditStrategyType> defaultStrats = EnumSet.of(merge, replace, none);
+ private static final Set<EditStrategyType> DEFAULT_STRATS = EnumSet.of(merge, replace, none);
public static EditStrategyType getDefaultStrategy() {
return merge;
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);
}
}
}