import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.moduleNamespaceToPackageName;
import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.packageNameForGeneratedType;
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.parseToValidParamName;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import com.google.common.io.BaseEncoding;
*/
private void resolveTypeDefsFromContext() {
final Set<Module> modules = schemaContext.getModules();
- Preconditions.checkArgument(modules != null, "Sef of Modules cannot be NULL!");
+ Preconditions.checkArgument(modules != null, "Set of Modules cannot be NULL!");
final Module[] modulesArray = new Module[modules.size()];
int i = 0;
for (Module modul : modules) {
if (dateTypeMap == null) {
dateTypeMap = new HashMap<>();
}
- final Map<String, Type> typeMap = new HashMap<>();
- dateTypeMap.put(module.getRevision(), typeMap);
+ dateTypeMap.put(module.getRevision(), Collections.<String, Type>emptyMap());
genTypeDefsContextMap.put(module.getName(), dateTypeMap);
}
}
if (returnType != null) {
final Map<Date, Map<String, Type>> modulesByDate = genTypeDefsContextMap.get(moduleName);
- final Map<String, Type> typeMap = modulesByDate.get(moduleRevision);
+ Map<String, Type> typeMap = modulesByDate.get(moduleRevision);
if (typeMap != null) {
+ if (typeMap.isEmpty()) {
+ typeMap = new HashMap<>(4);
+ modulesByDate.put(moduleRevision, typeMap);
+ }
typeMap.put(typedefName, returnType);
}
return returnType;
basePackageName, unionSubtype, newTOBuilderName, parentNode);
final GeneratedPropertyBuilder propertyBuilder;
- propertyBuilder = parentUnionGenTOBuilder.addProperty(BindingGeneratorUtil
- .parseToValidParamName(newTOBuilderName));
+ propertyBuilder = parentUnionGenTOBuilder.addProperty(BindingMapping.getPropertyName(newTOBuilderName));
propertyBuilder.setReturnType(subUnionGenTOBUilders.get(0));
parentUnionGenTOBuilder.addEqualsIdentity(propertyBuilder);
parentUnionGenTOBuilder.addToStringProperty(propertyBuilder);
final String propertyName) {
if (unionGenTransObject != null && type != null && !unionGenTransObject.containsProperty(propertyName)) {
final GeneratedPropertyBuilder propBuilder = unionGenTransObject
- .addProperty(parseToValidParamName(propertyName));
+ .addProperty(BindingMapping.getPropertyName(propertyName));
propBuilder.setReturnType(type);
unionGenTransObject.addEqualsIdentity(propBuilder);
genTOBuilder.setReference(typeDef.getReference());
genTOBuilder.setSchemaPath(typeDef.getPath().getPathFromRoot());
genTOBuilder.setModuleName(moduleName);
+ genTOBuilder.setBaseType(typeDef);
final List<Bit> bitList = bitsTypeDefinition.getBits();
GeneratedPropertyBuilder genPropertyBuilder;
for (final Bit bit : bitList) {
String name = bit.getName();
- genPropertyBuilder = genTOBuilder.addProperty(parseToValidParamName(name));
+ genPropertyBuilder = genTOBuilder.addProperty(BindingMapping.getPropertyName(name));
genPropertyBuilder.setReadOnly(true);
genPropertyBuilder.setReturnType(BaseYangTypes.BOOLEAN_TYPE);
@Override
public String getParamNameFromType(final TypeDefinition<?> type) {
- return BindingGeneratorUtil.parseToValidParamName(type.getQName().getLocalName());
+ return BindingMapping.getPropertyName(type.getQName().getLocalName());
}
}