private AugmentationIdentifier getAugmentationIdentifier(final AugmentationSchema augment) { final Set<QName> childNames = new HashSet<>(); for (final DataSchemaNode child : augment.getChildNodes()) { childNames.add(child.getQName()); } return new AugmentationIdentifier(childNames); }
public ImmutableMap<AugmentationIdentifier,Type> getAvailableAugmentationTypes(final DataNodeContainer container) { final Map<AugmentationIdentifier,Type> identifierToType = new HashMap<>(); if (container instanceof AugmentationTarget) { final Set<AugmentationSchema> augments = ((AugmentationTarget) container).getAvailableAugmentations(); for (final AugmentationSchema augment : augments) { // Augmentation must have child nodes if is to be used with Binding classes AugmentationSchema augOrig = augment; while (augOrig.getOriginalDefinition().isPresent()) { augOrig = augOrig.getOriginalDefinition().get(); } if (!augment.getChildNodes().isEmpty()) { final Type augType = typeToDefiningSchema.inverse().get(augOrig); if (augType != null) { identifierToType.put(getAugmentationIdentifier(augment),augType); } } } } return ImmutableMap.copyOf(identifierToType); }
public Entry<AugmentationIdentifier, AugmentationSchema> getResolvedAugmentationSchema(final DataNodeContainer target, final Class<? extends Augmentation<?>> aug) { final AugmentationSchema origSchema = getAugmentationDefinition(aug); Preconditions.checkArgument(origSchema != null, "Augmentation %s is not known in current schema context",aug); /* * FIXME: Validate augmentation schema lookup * * Currently this algorithm, does not verify if instantiated child nodes * are real one derived from augmentation schema. The problem with * full validation is, if user used copy builders, he may use * augmentation which was generated for different place. * * If this augmentations have same definition, we emit same identifier * with data and it is up to underlying user to validate data. * */ final Set<QName> childNames = new HashSet<>(); final Set<DataSchemaNode> realChilds = new HashSet<>(); for (final DataSchemaNode child : origSchema.getChildNodes()) { realChilds.add(target.getDataChildByName(child.getQName())); childNames.add(child.getQName()); } final AugmentationIdentifier identifier = new AugmentationIdentifier(childNames); final AugmentationSchema proxy = new EffectiveAugmentationSchema(origSchema, realChilds); return new AbstractMap.SimpleEntry<>(identifier, proxy); }
Collection<DataSchemaNode> childNodes = augmentation.getChildNodes(); if (areAllChildrenChoiceCaseNodes(childNodes)) { for (ChoiceCaseNode childCase : castChildNodesToChoiceCases(childNodes)) {
public static QName getAugmentationQName(final AugmentationSchema augmentation) { checkNotNull(augmentation, "Augmentation must not be null."); final QName identifier = getAugmentationIdentifier(augmentation); if(identifier != null) { return identifier; } URI namespace = null; Date revision = null; if(augmentation instanceof NamespaceRevisionAware) { namespace = ((NamespaceRevisionAware) augmentation).getNamespace(); revision = ((NamespaceRevisionAware) augmentation).getRevision(); } if(namespace == null || revision == null) { for(final DataSchemaNode child : augmentation.getChildNodes()) { // Derive QName from child nodes if(!child.isAugmenting()) { namespace = child.getQName().getNamespace(); revision = child.getQName().getRevision(); break; } } } checkState(namespace != null, "Augmentation namespace must not be null"); checkState(revision != null, "Augmentation revision must not be null"); // FIXME: Allways return a qname with module namespace. return QName.create(namespace,revision, "foo_augment"); }
addImplementedInterfaceFromUses(augSchema, augTypeBuilder); augSchemaNodeToMethods(module, basePackageName, augTypeBuilder, augTypeBuilder, augSchema.getChildNodes()); augmentBuilders.put(augTypeName, augTypeBuilder); if(!augSchema.getChildNodes().isEmpty()) { genCtx.get(module).addTargetToAugmentation(targetTypeRef, augTypeBuilder); genCtx.get(module).addTypeToAugmentation(augTypeBuilder, augSchema);
} else { generateTypesFromAugmentedChoiceCases(module, augmentPackageName, targetTypeBuilder.toInstance(), (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes());
(ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes());
Collection<DataSchemaNode> _childNodes = augment.getChildNodes(); boolean _isNullOrEmpty_3 = IterableExtensions.isNullOrEmpty(_childNodes); boolean _not_3 = (!_isNullOrEmpty_3); if (_not_3) { _builder.append(" "); Collection<DataSchemaNode> _childNodes_1 = augment.getChildNodes(); CharSequence _writeDataSchemaNodes = YangTemplate.writeDataSchemaNodes(_childNodes_1); _builder.append(_writeDataSchemaNodes, " ");