Propagate notification status to generated listener methods
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / main / java / org / opendaylight / mdsal / binding / java / api / generator / JavaFileTemplate.java
index cec30795866d613d06c439294d4d44a609d42d0e..d86bbfe66e561ebafa90b5e9604e0c682f9cf762 100644 (file)
@@ -67,9 +67,13 @@ class JavaFileTemplate {
      */
     static final @NonNull JavaTypeName OVERRIDE = JavaTypeName.create(Override.class);
     /**
-     * {@code java.lang.SuppressWarnings} as a JavaTypeName.
+     * {@code java.lang.void} as a JavaTypeName.
      */
     static final @NonNull JavaTypeName SUPPRESS_WARNINGS = JavaTypeName.create(SuppressWarnings.class);
+    /**
+     * {@code java.lang.SuppressWarnings} as a JavaTypeName.
+     */
+    static final @NonNull JavaTypeName VOID = JavaTypeName.create(void.class);
 
     /**
      * {@code java.util.Arrays} as a JavaTypeName.
@@ -241,6 +245,16 @@ class JavaFileTemplate {
         return null;
     }
 
+    /**
+     * Generate a call to {@link Object#clone()} if target field represents an array. Returns an empty string otherwise.
+     *
+     * @param property Generated property
+     * @return The string used to clone the property, or an empty string
+     */
+    static final String cloneCall(final GeneratedProperty property) {
+        return property.getReturnType().getName().endsWith("[]") ? ".clone()" : "";
+    }
+
     /**
      * Returns set of method signature instances which contains all the methods of the <code>genType</code>
      * and all the methods of the implemented interfaces.