Expose property name when checking key components
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / main / java / org / opendaylight / mdsal / binding / java / api / generator / JavaFileTemplate.java
index cec30795866d613d06c439294d4d44a609d42d0e..ec891f26250447d2dce4056f7a72587fcbb2a5b6 100644 (file)
@@ -241,6 +241,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.