/** * For input node, find if it contains config:java-name-prefix extension. If * not found, convert local name of node converted to cammel case. */ public static String findJavaNamePrefix(final SchemaNode schemaNode) { return convertToJavaName(schemaNode, true); }
AbstractAttribute(DataSchemaNode attrNode) { this.attributeYangName = getLocalName(attrNode); this.node = attrNode; this.upperCaseCammelCase = TypeProviderWrapper.findJavaNamePrefix(node); this.lowerCaseCammelCase = TypeProviderWrapper.findJavaParameter(node); }
private void addArtificialPropertyToUnionCompositeType(final TypeDefinition<?> baseTypeDefinition, final String[] itemNames, final OpenType<?>[] itemTypes) { String artificialPropertyName = typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition); itemNames[0] = artificialPropertyName; OpenType<?> artificialPropertyType = getArrayOpenTypeForSimpleType(TYPE_OF_ARTIFICIAL_UNION_PROPERTY.getName(), SimpleTypeResolver.getSimpleType(TYPE_OF_ARTIFICIAL_UNION_PROPERTY.getName())); itemTypes[0] = artificialPropertyType; }
TypeProviderWrapper typeProviderWrapper = new TypeProviderWrapper( new TypeProviderImpl(resolveSchemaContext));
public JavaAttribute(final LeafSchemaNode leaf, final TypeProviderWrapper typeProviderWrapper) { super(leaf); this.type = typeProviderWrapper.getType(leaf); this.typeDefinition = CompatUtils.compatLeafType(leaf); this.typeProviderWrapper = typeProviderWrapper; this.nullableDefault = leaf.getDefault(); this.nullableDefaultWrappedForCode = leaf.getDefault() == null ? null : typeProviderWrapper.getDefault(leaf); this.nullableDescription = leaf.getDescription(); }
for (TypeDefinition<?> innerTypeDefinition : types) { Type innerType = typeProviderWrapper.getType(innerTypeDefinition, innerTypeDefinition); Type innerTypeBaseType = typeProviderWrapper.getType(baseInnerTypeDefinition, baseInnerTypeDefinition); itemNames[i] = typeProviderWrapper.getJMXParamForUnionInnerType(innerTypeDefinition); itemTypes[i++] = innerCompositeType;
public Type getType(final LeafSchemaNode leaf) { TypeDefinition<?> type = CompatUtils.compatLeafType(leaf); return getType(leaf, type); }
.findJavaNamePrefix(listSchemaNode);
.findJavaParameter(rpcDefinition); AttributeIfc returnType; if (rpcDefinition.getOutput() == null
String packageName = packageTranslator.getPackageName(module); .create(module, qNamesToSIEs, context, new TypeProviderWrapper(new TypeProviderImpl(context)), packageName);
public JavaAttribute(final LeafListSchemaNode leaf, final TypeProviderWrapper typeProviderWrapper) { super(leaf); this.type = typeProviderWrapper.getType(leaf); this.typeDefinition = leaf.getType(); this.typeProviderWrapper = typeProviderWrapper; this.nullableDefault = nullableDefaultWrappedForCode = null; this.nullableDescription = leaf.getDescription(); }
schemaContext); String javaNamePrefix = TypeProviderWrapper.findJavaNamePrefix(moduleIdentity);
Module module = moduleEntry.getValue(); String packageName = packageTranslator.getPackageName(module); TypeProviderWrapper typeProviderWrapper = new TypeProviderWrapper( new TypeProviderImpl(resolveSchemaContext)); String yangAsString = reReadInputStream(moduleEntry);
public static String findJavaParameter(final SchemaNode schemaNode) { return convertToJavaName(schemaNode, false); }
private OpenType<?> getEnumType(final TypeDefinition<?> baseType) { final String fullyQualifiedName = typeProviderWrapper.getType(node, getTypeDefinition()).getFullyQualifiedName(); final String[] items = {"instance"}; String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription(); try { return new CompositeType(fullyQualifiedName, description, items, items, new OpenType[]{SimpleType.STRING}); } catch (OpenDataException e) { throw new RuntimeException("Unable to create enum type" + fullyQualifiedName + " as open type", e); } }
private OpenType<?> getCompositeType(final Type baseType, final TypeDefinition<?> baseTypeDefinition) { SimpleType<?> innerItemType = SimpleTypeResolver.getSimpleType(baseType); String innerItemName = typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition); String[] itemNames = new String[]{innerItemName}; String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription(); OpenType<?>[] itemTypes = new OpenType[]{innerItemType}; try { return new CompositeType(getUpperCaseCammelCase(), description, itemNames, itemNames, itemTypes); } catch (OpenDataException e) { throw new RuntimeException("Unable to create " + CompositeType.class + " with inner element of type " + itemTypes, e); } }
public Map<String, AttributeIfc> getCapitalizedPropertiesToTypesMap() { Map<String, AttributeIfc> capitalizedPropertiesToTypesMap = Maps .newHashMap(); for (Entry<String, AttributeIfc> entry : yangNameToAttributeMap .entrySet()) { capitalizedPropertiesToTypesMap.put( TypeProviderWrapper.convertToJavaName(entry.getKey(), true), entry.getValue()); } return capitalizedPropertiesToTypesMap; }
@Override public OpenType<?> getOpenType() { TypeDefinition<?> baseTypeDefinition = getBaseType(typeProviderWrapper, typeDefinition); Type baseType = typeProviderWrapper.getType(baseTypeDefinition, baseTypeDefinition); if (isArray()) { return getArrayType(); } else if (isEnum()) { return getEnumType(baseTypeDefinition); } else if (isUnion()) { return getCompositeTypeForUnion(baseTypeDefinition); } else if (isDerivedType(baseType, getType())) { return getCompositeType(baseType, baseTypeDefinition); } else if (isIdentityRef()) { return getCompositeTypeForIdentity(); } return getSimpleType(getType()); }
public Map<String, AttributeIfc> getJmxPropertiesToTypesMap() { Map<String, AttributeIfc> jmxPropertiesToTypesMap = Maps.newHashMap(); for (Entry<String, AttributeIfc> entry : yangNameToAttributeMap .entrySet()) { jmxPropertiesToTypesMap.put( TypeProviderWrapper.convertToJavaName(entry.getKey(), false), entry.getValue()); } return jmxPropertiesToTypesMap; }
public static String convertToJavaName(final SchemaNode schemaNode, final boolean capitalizeFirstLetter) { for (UnknownSchemaNode unknownNode : schemaNode.getUnknownSchemaNodes()) { if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME .equals(unknownNode.getNodeType())) { String value = unknownNode.getNodeParameter(); return convertToJavaName(value, capitalizeFirstLetter); } } return convertToJavaName(schemaNode.getQName().getLocalName(), capitalizeFirstLetter); }