Fix runtime builder string duplication 96/83696/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 16 Aug 2019 11:36:16 +0000 (13:36 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 16 Aug 2019 13:55:46 +0000 (13:55 +0000)
This is a minor code smell, concentrate exception allocation to
get rid of it.

Change-Id: I3343b5dd844e4796cd781ef478412dd40e980152
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/model/util/generated/type/builder/RuntimeEnumerationBuilder.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/model/util/generated/type/builder/RuntimeGeneratedTOBuilder.java
binding/mdsal-binding-generator-util/src/main/java/org/opendaylight/mdsal/binding/model/util/generated/type/builder/RuntimeGeneratedTypeBuilder.java

index 0e89df11b22c10c2aeb614ad4e572dec54fcdc0f..8348aa6957a920d11b2aaa84b7d1f4b9a6d3d278 100644 (file)
@@ -60,17 +60,17 @@ public final class RuntimeEnumerationBuilder extends AbstractEnumerationBuilder
 
         @Override
         public Optional<String> getDescription() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public Optional<String> getReference() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public Status getStatus() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
     }
 
@@ -81,32 +81,36 @@ public final class RuntimeEnumerationBuilder extends AbstractEnumerationBuilder
 
         @Override
         public TypeComment getComment() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public String getDescription() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public String getReference() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public Iterable<QName> getSchemaPath() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public String getModuleName() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public Optional<YangSourceDefinition> getYangSourceDefinition() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
     }
+
+    static UnsupportedOperationException unsupported() {
+        return new UnsupportedOperationException("Not available at runtime");
+    }
 }
index 8701014b7c901ef013103892bfeb44c98cba9c97..82792c847a2ed2dd4292c878396472c03cd684a0 100644 (file)
@@ -67,32 +67,36 @@ public final class RuntimeGeneratedTOBuilder extends AbstractGeneratedTOBuilder
 
         @Override
         public Restrictions getRestrictions() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public GeneratedProperty getSUID() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public String getDescription() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public String getReference() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public Iterable<QName> getSchemaPath() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public String getModuleName() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
+        }
+
+        private static UnsupportedOperationException unsupported() {
+            return new UnsupportedOperationException("Not available at runtime");
         }
     }
 }
index 8787d29527543c3da9b9abc0519aa87b11b0a5d5..fe89dbf022934c112adfdb5244ca1efaff0d7a8f 100644 (file)
@@ -94,22 +94,26 @@ public final class RuntimeGeneratedTypeBuilder extends AbstractGeneratedTypeBuil
 
         @Override
         public String getDescription() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public String getReference() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public Iterable<QName> getSchemaPath() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
         }
 
         @Override
         public String getModuleName() {
-            throw new UnsupportedOperationException("Not available at runtime");
+            throw unsupported();
+        }
+
+        private static UnsupportedOperationException unsupported() {
+            return new UnsupportedOperationException("Not available at runtime");
         }
     }
 }