/** * Checks if <code>dataNode</code> is <code>LeafListSchemaNode</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 leaflist and if it is of enum type * @return boolean value * <ul> * <li>true - if <code>dataNode</code> is leaflist of type * enumeration</li> * <li>false - other cases</li> * </ul> */ private static boolean leafListContainsEnumDefinition(final SchemaNode dataNode) { if (dataNode instanceof LeafListSchemaNode) { final LeafListSchemaNode leafList = (LeafListSchemaNode) dataNode; return leafList.getType() instanceof EnumTypeDefinition; } return false; }
/** * Checks if <code>dataNode</code> is <code>LeafListSchemaNode</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 leaflist and if * it is of enum type * @return boolean value * <ul> * <li>true - if <code>dataNode</code> is leaflist of type * enumeration</li> * <li>false - other cases</li> * </ul> */ private static boolean leafListContainsEnumDefinition(final SchemaNode dataNode) { if (dataNode instanceof LeafListSchemaNode) { final LeafListSchemaNode leafList = (LeafListSchemaNode) dataNode; if (leafList.getType() instanceof EnumTypeDefinition) { return true; } } return false; }
/** * Return a {@link LeafsetEntryInterner} for a particular schema. Interner instances must be used only for leafset * entries for that particular schema, otherwise they may produce unexpected results. * * @param schema Schema of the parent leaf set * @return An interner instance, or null if the leafset's type should not be interned. */ public static @Nullable LeafsetEntryInterner forSchema(final @Nullable LeafListSchemaNode schema) { if (schema != null) { final TypeDefinition<?> type = schema.getType(); if (type instanceof BooleanTypeDefinition || type instanceof EnumTypeDefinition || type instanceof IdentityrefTypeDefinition) { return INSTANCE; } } return null; } }
/** * Return a {@link LeafsetEntryInterner} for a particular schema. Interner instances must be used only for leafset * entries for that particular schema, otherwise they may produce unexpected results. * * @param schema Schema of the parent leaf set * @return An interner instance, or null if the leafset's type should not be interned. */ public static @Nullable LeafsetEntryInterner forSchema(final @Nullable LeafListSchemaNode schema) { if (schema != null) { final TypeDefinition<?> type = schema.getType(); if (type instanceof BooleanTypeDefinition || type instanceof EnumTypeDefinition || type instanceof IdentityrefTypeDefinition) { return INSTANCE; } } return null; } }
public Type getType(final LeafListSchemaNode leaf) { Type javaType; try { javaType = typeProvider.javaTypeForSchemaDefinitionType( leaf.getType(), leaf); if (javaType == null) { throw new IllegalArgumentException( "Unknown type received for " + leaf.toString()); } } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Error while resolving type of " + leaf, e); } return javaType; }
private Object getValue(String value){ if(schemaNode != null){ if(schemaNode instanceof LeafListSchemaNode){ return TypeDefinitionAwareCodec .from(LeafListSchemaNode.class.cast(schemaNode).getType()).deserialize(value); } } return value; }
private JSONObject processLeafListNode(final LeafListSchemaNode listNode) throws JSONException { JSONObject props = new JSONObject(); props.put(TYPE_KEY, ARRAY_TYPE); JSONObject itemsVal = new JSONObject(); processTypeDef(listNode.getType(), itemsVal); props.put(ITEMS_KEY, itemsVal); ConstraintDefinition constraints = listNode.getConstraints(); processConstraints(constraints, props); return props; }
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(); }
/** * Extracts the base type of leaf schema node until it reach concrete type of TypeDefinition. * * @param node * a node representing LeafListSchemaNode * @return concrete type definition of node value */ private static TypeDefinition<?> typeDefinition(final LeafListSchemaNode node) { TypeDefinition<?> baseType = node.getType(); while (baseType.getBaseType() != null) { baseType = baseType.getBaseType(); } return baseType; }
/** * Extracts the base type of leaf schema node until it reach concrete type of TypeDefinition. * * @param node * a node representing LeafListSchemaNode * @return concrete type definition of node value */ private static TypeDefinition<?> typeDefinition(final LeafListSchemaNode node) { TypeDefinition<?> baseType = node.getType(); while (baseType.getBaseType() != null) { baseType = baseType.getBaseType(); } return baseType; }
/** * 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; returnType = javaTypeForSchemaDefinitionType(leaf.getType(), leaf); } else if (dataNode instanceof LeafListSchemaNode) { final LeafListSchemaNode leafList = (LeafListSchemaNode) dataNode; returnType = javaTypeForSchemaDefinitionType(leafList.getType(), leafList); } } return returnType; }
/** * 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; }
private void emitLeafList(final LeafListSchemaNode child) { super.writer.startLeafListNode(child.getQName()); child.getWhenCondition().ifPresent(this::emitWhen); // FIXME: BUG-2444: *(ifFeatureNode ) emitTypeNode(child.getPath(), child.getType()); child.getType().getUnits().ifPresent(this::emitUnitsNode); // FIXME: BUG-2444: unitsNode /Optional child.getMustConstraints().forEach(this::emitMust); emitConfigNode(child.isConfiguration()); emitDefaultNodes(child.getDefaults()); child.getElementCountConstraint().ifPresent(this::emitCountConstraint); emitOrderedBy(child.isUserOrdered()); emitDocumentedNode(child); emitUnknownStatementNodes(child.getUnknownSchemaNodes()); super.writer.endNode(); }
type = ((LeafSchemaNode) schemaNode).getType(); } else { type = ((LeafListSchemaNode) schemaNode).getType();
public static CharSequence writeLeafListSchemaNode(final LeafListSchemaNode leafListSchemaNode) { StringConcatenation _builder = new StringConcatenation(); _builder.append("leaf-list "); QName _qName = leafListSchemaNode.getQName(); String _localName = _qName.getLocalName(); _builder.append(_localName, ""); _builder.append(" {"); _builder.newLineIfNotEmpty(); _builder.append(" "); _builder.append("type "); TypeDefinition<? extends TypeDefinition<?>> _type = leafListSchemaNode.getType(); QName _qName_1 = _type.getQName(); String _localName_1 = _qName_1.getLocalName(); _builder.append(_localName_1, " "); _builder.append(";"); _builder.newLineIfNotEmpty(); _builder.append("}"); _builder.newLine(); return _builder; }
final TypeDefinition<?> typeDef = node.getType(); final Module parentModule = findParentModule(schemaContext, node);
final TypeDefinition<?> typeDef = node.getType(); final Module parentModule = findParentModule(schemaContext, node);