+/*
+ * Copyright (c) 2014 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.yangtools.sal.java.api.generator
import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty
*/
def protected CharSequence asJavadoc(String comment) {
if(comment == null) return '';
- val paragraphs = paragraphSplitter.split(comment)
+ var txt = comment
+ if (txt.contains("*/")) {
+ txt = txt.replace("*/", "*/")
+ }
+ val paragraphs = paragraphSplitter.split(txt)
return '''
/**
}
}
if (!isValidLength) {
- throw new IllegalArgumentException(String.format("Invalid length: {}, expected: {}.", «paramName», lengthConstraints));
+ throw new IllegalArgumentException(String.format("Invalid length: %s, expected: %s.", «paramName», lengthConstraints));
}
}
'''
«IF !properties.empty»
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("«type.name» [«properties.get(0).fieldName»=");
- «IF properties.get(0).returnType.name.contains("[")»
- builder.append(«Arrays.importedName».toString(«properties.get(0).fieldName»));
- «ELSE»
- builder.append(«properties.get(0).fieldName»);
- «ENDIF»
- «FOR i : 1..<properties.size»
- builder.append(", «properties.get(i).fieldName»=");
- «IF properties.get(i).returnType.name.contains("[")»
- builder.append(«Arrays.importedName».toString(«properties.get(i).fieldName»));
- «ELSE»
- builder.append(«properties.get(i).fieldName»);
- «ENDIF»
+ StringBuilder builder = new StringBuilder("«type.name» [");
+ boolean first = true;
+
+ «FOR property : properties»
+ if («property.fieldName» != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("«property.fieldName»=");
+ «IF property.returnType.name.contains("[")»
+ builder.append(«Arrays.importedName».toString(«property.fieldName»));
+ «ELSE»
+ builder.append(«property.fieldName»);
+ «ENDIF»
+ }
«ENDFOR»
- builder.append("]");
- return builder.toString();
+ return builder.append(']').toString();
}
«ENDIF»
'''