Fix code smells in AlwaysFailOperation 84/71884/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 9 May 2018 09:07:31 +0000 (11:07 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 9 May 2018 09:07:31 +0000 (11:07 +0200)
Concentrate IllegalStateException into a utility method.

Change-Id: I45fe9e20cc6c6facfdc4f468cd27d5a2f05719f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AlwaysFailOperation.java

index 8463c836e8ac2b079604de2744d0448a774861c9..9c662e5779a082518ba6c3ea04e89261e4bb3f16 100644 (file)
@@ -28,39 +28,43 @@ final class AlwaysFailOperation extends ModificationApplyOperation {
     }
 
     @Override
-    Optional<TreeNode> apply(final ModifiedNode modification,
-            final Optional<TreeNode> storeMeta, final Version version) {
-        throw new IllegalStateException("Schema Context is not available.");
+    Optional<TreeNode> apply(final ModifiedNode modification, final Optional<TreeNode> storeMeta,
+            final Version version) {
+        throw ise();
     }
 
     @Override
     void checkApplicable(final YangInstanceIdentifier path, final NodeModification modification,
             final Optional<TreeNode> storeMetadata, final Version version) {
-        throw new IllegalStateException("Schema Context is not available.");
+        throw ise();
     }
 
     @Override
     public Optional<ModificationApplyOperation> getChild(final PathArgument child) {
-        throw new IllegalStateException("Schema Context is not available.");
+        throw ise();
     }
 
     @Override
     void verifyStructure(final NormalizedNode<?, ?> modification, final boolean verifyChildren) {
-        throw new IllegalStateException("Schema Context is not available.");
+        throw ise();
     }
 
     @Override
     ChildTrackingPolicy getChildPolicy() {
-        throw new IllegalStateException("Schema Context is not available.");
+        throw ise();
     }
 
     @Override
     void mergeIntoModifiedNode(final ModifiedNode node, final NormalizedNode<?, ?> value, final Version version) {
-        throw new IllegalStateException("Schema Context is not available.");
+        throw ise();
     }
 
     @Override
     void recursivelyVerifyStructure(final NormalizedNode<?, ?> value) {
-        throw new IllegalStateException("Schema Context is not available.");
+        throw ise();
     }
-}
\ No newline at end of file
+
+    private static IllegalStateException ise() {
+        return new IllegalStateException("Schema Context is not available.");
+    }
+}