/** * Checks if <code>dataNode</code> is <code>LeafSchemaNode</code> and if it so then checks if it is of type * <code>EnumTypeDefinition</code>. * * @param dataNode data schema node for which is checked if it is leaf and if it is of enum type * @return boolean value * <ul> * <li>true - if <code>dataNode</code> is leaf of type enumeration</li> * <li>false - other cases</li> * </ul> */ private static boolean leafContainsEnumDefinition(final SchemaNode dataNode) { if (dataNode instanceof LeafSchemaNode) { final LeafSchemaNode leaf = (LeafSchemaNode) dataNode; return CompatUtils.compatLeafType(leaf) instanceof EnumTypeDefinition; } return false; }
public Type getType(final LeafSchemaNode leaf) { TypeDefinition<?> type = CompatUtils.compatLeafType(leaf); return getType(leaf, type); }
/** * Converts <code>dataNode</code> to JAVA <code>Type</code>. * * @param dataNode contains information about YANG type * @return JAVA <code>Type</code> representation of <code>dataNode</code> */ private Type resolveTypeFromDataSchemaNode(final SchemaNode dataNode) { Type returnType = null; if (dataNode != null) { if (dataNode instanceof LeafSchemaNode) { final LeafSchemaNode leaf = (LeafSchemaNode) dataNode; final TypeDefinition<?> type = CompatUtils.compatLeafType(leaf); returnType = javaTypeForSchemaDefinitionType(type, leaf); } else if (dataNode instanceof LeafListSchemaNode) { final LeafListSchemaNode leafList = (LeafListSchemaNode) dataNode; returnType = javaTypeForSchemaDefinitionType(leafList.getType(), leafList); } } return returnType; }
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(); }
private String unionToDef(final LeafSchemaNode node) { final TypeDefinition<?> type = CompatUtils.compatLeafType(node); String parentName; String className;
private boolean resolveLeafSchemaNodeAsProperty(final GeneratedTOBuilder toBuilder, final LeafSchemaNode leaf, final boolean isReadOnly) { if (leaf != null && toBuilder != null) { Type returnType; final TypeDefinition<?> typeDef = CompatUtils.compatLeafType(leaf); if (typeDef instanceof UnionTypeDefinition) { // GeneratedType for this type definition should have be already created final ModuleContext mc = moduleContext(typeDef.getQName().getModule()); returnType = mc.getTypedefs().get(typeDef.getPath()); if (returnType == null) { // This may still be an inner type, try to find it returnType = mc.getInnerType(typeDef.getPath()); } } else if (typeDef instanceof EnumTypeDefinition && typeDef.getBaseType() == null) { // Annonymous enumeration (already generated, since it is inherited via uses). LeafSchemaNode originalLeaf = (LeafSchemaNode) SchemaNodeUtils.getRootOriginalIfPossible(leaf); QName qname = originalLeaf.getQName(); returnType = moduleContext(qname.getModule()).getInnerType(originalLeaf.getType().getPath()); } else { returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf); } return resolveLeafSchemaNodeAsProperty(toBuilder, leaf, returnType, isReadOnly); } return false; }
public String getTypeDefaultConstruction(final LeafSchemaNode node, final String defaultValue) { final TypeDefinition<?> type = CompatUtils.compatLeafType(node); final QName typeQName = type.getQName(); final TypeDefinition<?> base = baseTypeDefForExtendedType(type);
Type returnType = null; final TypeDefinition<?> typeDef = CompatUtils.compatLeafType(leaf); if (isInnerType(leaf, typeDef)) { if (typeDef instanceof EnumTypeDefinition) {