import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import java.util.List;
+import java.util.Optional;
import java.util.StringTokenizer;
+import java.util.function.Function;
import java.util.regex.Pattern;
import org.opendaylight.mdsal.binding.javav2.generator.util.Types;
import org.opendaylight.mdsal.binding.javav2.model.api.AccessModifier;
/**
* Returns formatted Javadoc, based on type
- * @param typeName
+ * @param typeName given type name
* @return formatted Javadoc, based on type
*/
public static String formatDataForJavaDocBuilder(final String typeName) {
/**
* Returns formatted Javadoc with possible additional comment, based on type
- * @param type
- * @param additionalComment
+ * @param type given type
+ * @param additionalComment additional comment to format
* @return formatted Javadoc with possible additional comment, based on type
*/
public static String formatDataForJavaDoc(final GeneratedType type, final String additionalComment) {
/**
* Returns properties names in formatted string
- * @param properties
+ * @param properties list of given properties
* @return properties names in formatted string
*/
//FIXME: this needs further clarification in future patch
/**
* Returns formatted type description
- * @param type
+ * @param type given type
* @return formatted type description
*/
public static String formatDataForJavaDoc(final GeneratedType type) {
/**
* Returns parameter name, based on given Type
- * @param returnType
- * @param paramName
+ * @param returnType given type
+ * @param paramName parameter name
* @return parameter name, based on given Type
*/
public static String paramValue(final Type returnType, final String paramName) {
/**
* Returns related Javadoc
- * @param methodSignature
+ * @param methodSignature method signature
* @return related Javadoc
*/
public static String getJavaDocForInterface(final MethodSignature methodSignature) {
/**
* Returns collection of properties as formatted String
- * @param properties
+ * @param properties list of given properties
* @return generated properties as formatted String
*/
public static String propsAsArgs(final Iterable<GeneratedProperty> properties) {
/**
* Returns properties as formatted String
- * @param properties
- * @param booleanName
+ * @param properties list of given properties
+ * @param booleanName Java Boolean type name
* @return Properties as formatted String
*/
public static String propsAsList(final Iterable<GeneratedProperty> properties, final String booleanName) {
/**
* Extracts available restrictions from given type
- * @param currentType
+ * @param currentType given type
* @return restrictions from given type
*/
public static Restrictions getRestrictions(final Type currentType) {
* method(type fieldname)
*
* @param property type from getter
+ * @return underscored string form
*/
public static String fieldName(final GeneratedProperty property) {
final String name = Preconditions.checkNotNull(property.getName());
}
/**
- * Template method which generates sequence of the names of the class attributes
+ * Template method which generates sequence of the names of the class attributes.
*
* @param parameters group of generated property instances which are transformed to the sequence of parameter names
* @return string with the list of the parameter names
}
/**
- * Helper method for building getter
+ * Helper method for building getter.
*
* @param field property name
- * @return getter for propery
+ * @return getter for property
*/
public static String getterMethodName(final GeneratedProperty field) {
final Type type = Preconditions.checkNotNull(field.getReturnType());
}
/**
- * Returns built setter method body
- * @param field
- * @param typeName
- * @param returnTypeName
+ * Returns built setter method body from input parameters.
+ * @param field generated property
+ * @param typeName type name
+ * @param returnTypeName return type name
* @return built setter method body
*/
public static String setterMethod(final GeneratedProperty field, final String typeName, final String returnTypeName) {
}
/**
- * Cuts prefix from getter name
+ * Cuts prefix from getter name.
*
* @param getter getter name
* @return getter name without prefix
}
/**
- * Returns list of properties as formatted String
- * @param properties
+ * Returns list of properties as formatted String.
+ * @param properties input list of generated properties
* @return formatted property list as String
*/
public static String getPropertyList(final List<GeneratedProperty> properties) {
}
/**
- * Returns source path as String
- * @param module
+ * Returns source path as String.
+ * @param module module
+ * @param moduleFilePathResolver function module to module file path
* @return formatted String source path
*/
- public static String getSourcePath(final Module module) {
- return "/".concat(module.getModuleSourcePath().replace(java.io.File.separatorChar, '/'));
+ public static String getSourcePath(final Module module, final Function<Module, Optional<String>> moduleFilePathResolver) {
+ final java.util.Optional<String> moduleFilePath = moduleFilePathResolver.apply(module);
+ Preconditions.checkArgument(moduleFilePath.isPresent(),"Module file path for %s is not present", module);
+
+ return moduleFilePath.get();
}
/**
- * util method for unionTemplateBuilderTemplate
+ * Util method for unionTemplateBuilderTemplate.
+ * @param modifier enum representing Java access modifier
* @return needed access modifier
*/
public static String getAccessModifier(final AccessModifier modifier) {
* and is available at http://www.eclipse.org/legal/epl-v10.html
*@
+@import java.util.function.Function;
+@import java.util.Optional
@import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifier.CLASS
@import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer.normalizeSpecificIdentifier
@import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer.normalizeFullPackageName
@import org.opendaylight.yangtools.yang.model.api.Module
@import org.opendaylight.yangtools.yang.model.api.SchemaContext
-@(module: Module, ctx: SchemaContext, importedNames: Map[String, String])
+@(module: Module, ctx: SchemaContext, importedNames: Map[String, String],
+moduleFilePathResolver: Function[Module, Optional[String]])
@if(module != null && ctx != null) {
public final class @{MODULE_INFO_CLASS_NAME} implements @{importedNames.get("yangModuleInfo")} {
private final @{importedNames.get("string")} namespace = "@{module.getNamespace.toString}";
private final @{importedNames.get("string")} semanticVersion = "@{module.getSemanticVersion}";
private final @{importedNames.get("string")} revision = "@{module.getQNameModule.getFormattedRevision}";
- private final @{importedNames.get("string")} resourcePath = "@{getSourcePath(module)}";
+ private final @{importedNames.get("string")} resourcePath = "@{getSourcePath(module, moduleFilePathResolver)}";
private final @{importedNames.get("set")}<YangModuleInfo> importedModules;
public static @{importedNames.get("yangModuleInfo")} getInstance() {
private final @{importedNames.get("string")} semanticVersion = "@{submodule.getSemanticVersion}";
private final @{importedNames.get("string")} namespace = "@{submodule.getNamespace.toString}";
private final @{importedNames.get("string")} revision = "@{submodule.getQNameModule.getFormattedRevision}";
- private final @{importedNames.get("string")} resourcePath = "@{getSourcePath(submodule)}";
+ private final @{importedNames.get("string")} resourcePath = "@{getSourcePath(submodule, moduleFilePathResolver)}";
private final @{importedNames.get("set")}<YangModuleInfo> importedModules;
public static @{importedNames.get("yangModuleInfo")} getInstance() {