/** * Override {@link AbstractDataNodeContainerSerializerSource#getChildNodes()} to get all children nodes * of same target augmentation schema nodes. */ @Override protected Collection<DataSchemaNode> getChildNodes() { Collection<DataSchemaNode> childNodes = new ArrayList<>(); for (AugmentationSchemaNode schema : this.augmentationSchemas) { childNodes.addAll(schema.getChildNodes()); } return childNodes; }
/** * Create AugmentationIdentifier from an AugmentationSchemaNode. * * @param schema Augmentation schema * @return AugmentationIdentifier for the schema * @throws NullPointerException if {@code schema} is null */ public static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchemaNode schema) { return new AugmentationIdentifier(schema.getChildNodes().stream().map(DataSchemaNode::getQName) .collect(Collectors.toSet())); }
private static Optional<AugmentationSchemaNode> findAugment(final AugmentationTarget schema, final Set<QName> qnames) { for (final AugmentationSchemaNode augment : schema.getAvailableAugmentations()) { final Set<QName> qNamesFromAugment = ImmutableSet.copyOf(Collections2.transform(augment.getChildNodes(), DataSchemaNode::getQName)); if (qnames.equals(qNamesFromAugment)) { return Optional.of(augment); } } return Optional.empty(); }
private static Optional<AugmentationSchemaNode> findAugment(final AugmentationTarget schema, final Set<QName> qnames) { for (final AugmentationSchemaNode augment : schema.getAvailableAugmentations()) { final Set<QName> qNamesFromAugment = ImmutableSet.copyOf(Collections2.transform(augment.getChildNodes(), DataSchemaNode::getQName)); if (qnames.equals(qNamesFromAugment)) { return Optional.of(augment); } } return Optional.empty(); }
/** * Create AugmentationIdentifier from an AugmentationSchemaNode. * * @param schema Augmentation schema * @return AugmentationIdentifier for the schema * @throws NullPointerException if {@code schema} is null */ public static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchemaNode schema) { return new AugmentationIdentifier(schema.getChildNodes().stream().map(DataSchemaNode::getQName) .collect(Collectors.toSet())); }
public static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchemaNode augmentation) { final ImmutableSet.Builder<QName> potentialChildren = ImmutableSet.builder(); for (final DataSchemaNode child : augmentation.getChildNodes()) { potentialChildren.add(child.getQName()); } return new AugmentationIdentifier(potentialChildren.build()); }
private static AugmentationIdentifier getAugmentationIdentifier(final AugmentationSchemaNode augment) { final Set<QName> childNames = new HashSet<>(); for (final DataSchemaNode child : augment.getChildNodes()) { childNames.add(child.getQName()); } return new AugmentationIdentifier(childNames); }
private static AugmentationIdentifier getAugmentationIdentifier(final AugmentationSchemaNode augment) { final Set<QName> childNames = new HashSet<>(); for (final DataSchemaNode child : augment.getChildNodes()) { childNames.add(child.getQName()); } return new AugmentationIdentifier(childNames); }
public static Set<DataSchemaNode> getRealSchemasForAugment(final DataNodeContainer targetSchema, final AugmentationSchemaNode augmentSchema) { final Set<DataSchemaNode> realChildNodes = new HashSet<>(); for (final DataSchemaNode dataSchemaNode : augmentSchema.getChildNodes()) { final DataSchemaNode realChild = targetSchema.getDataChildByName(dataSchemaNode.getQName()); realChildNodes.add(realChild); } return realChildNodes; }
public static Set<DataSchemaNode> getRealSchemasForAugment(final DataNodeContainer targetSchema, final AugmentationSchemaNode augmentSchema) { final Set<DataSchemaNode> realChildNodes = new HashSet<>(); for (final DataSchemaNode dataSchemaNode : augmentSchema.getChildNodes()) { final DataSchemaNode realChild = targetSchema.getDataChildByName(dataSchemaNode.getQName()); realChildNodes.add(realChild); } return realChildNodes; }
private static DataNodeContainer augmentationProxy(final AugmentationSchemaNode augmentation, final DataNodeContainer schema) { final Set<DataSchemaNode> children = new HashSet<>(); for (final DataSchemaNode augNode : augmentation.getChildNodes()) { children.add(schema.getDataChildByName(augNode.getQName())); } return new EffectiveAugmentationSchema(augmentation, children); }
public static boolean belongsToCaseAugment(final CaseSchemaNode caseNode, final AugmentationIdentifier childToProcess) { for (final AugmentationSchemaNode augmentationSchema : caseNode.getAvailableAugmentations()) { final Set<QName> currentAugmentChildNodes = new HashSet<>(); for (final DataSchemaNode dataSchemaNode : augmentationSchema.getChildNodes()) { currentAugmentChildNodes.add(dataSchemaNode.getQName()); } if (childToProcess.getPossibleChildNames().equals(currentAugmentChildNodes)) { return true; } } return false; }
public static boolean belongsToCaseAugment(final CaseSchemaNode caseNode, final AugmentationIdentifier childToProcess) { for (final AugmentationSchemaNode augmentationSchema : caseNode.getAvailableAugmentations()) { final Set<QName> currentAugmentChildNodes = new HashSet<>(); for (final DataSchemaNode dataSchemaNode : augmentationSchema.getChildNodes()) { currentAugmentChildNodes.add(dataSchemaNode.getQName()); } if (childToProcess.getPossibleChildNames().equals(currentAugmentChildNodes)) { return true; } } return false; }
private static boolean isLocalAugment(final AugmentationTarget container, final AugmentationSchemaNode augment) { Preconditions.checkState(container instanceof SchemaNode); final QName root = ((SchemaNode) container).getPath().getPathFromRoot().iterator().next(); // findFirst makes no sense but just pick up one child to judge whether the target node is // in the same module. final Optional<DataSchemaNode> child = augment.getChildNodes().stream().findFirst(); if (child.isPresent()) { return root.getModule().equals(child.get().getQName().getModule()); } return false; }
/** * Returns an AugmentationSchemaNode as effective in a parent node. * * @param schema Augmentation schema * @param parent Parent schema * @return Adjusted Augmentation schema * @throws NullPointerException if any of the arguments is null */ public static AugmentationSchemaNode create(final AugmentationSchemaNode schema, final DataNodeContainer parent) { Set<DataSchemaNode> children = new HashSet<>(); for (DataSchemaNode augNode : schema.getChildNodes()) { children.add(parent.getDataChildByName(augNode.getQName())); } return new EffectiveAugmentationSchema(schema, children); }
/** * Returns an AugmentationSchemaNode as effective in a parent node. * * @param schema Augmentation schema * @param parent Parent schema * @return Adjusted Augmentation schema * @throws NullPointerException if any of the arguments is null */ public static AugmentationSchemaNode create(final AugmentationSchemaNode schema, final DataNodeContainer parent) { Set<DataSchemaNode> children = new HashSet<>(); for (DataSchemaNode augNode : schema.getChildNodes()) { children.add(parent.getDataChildByName(augNode.getQName())); } return new EffectiveAugmentationSchema(schema, children); }
public ImmutableMap<AugmentationIdentifier, Type> getAvailableAugmentationTypes(final DataNodeContainer container) { final Map<AugmentationIdentifier, Type> identifierToType = new HashMap<>(); if (container instanceof AugmentationTarget) { final Set<AugmentationSchemaNode> augments = ((AugmentationTarget) container).getAvailableAugmentations(); for (final AugmentationSchemaNode augment : augments) { // Augmentation must have child nodes if is to be used with Binding classes AugmentationSchemaNode augOrig = augment; while (augOrig.getOriginalDefinition().isPresent()) { augOrig = augOrig.getOriginalDefinition().get(); } if (!augment.getChildNodes().isEmpty()) { final Optional<Type> augType = runtimeTypes.findType(augOrig); if (augType.isPresent()) { identifierToType.put(getAugmentationIdentifier(augment), augType.get()); } } } } return ImmutableMap.copyOf(identifierToType); }
public static SchemaAwareApplyOperation from(final DataNodeContainer resolvedTree, final AugmentationTarget augSchemas, final AugmentationIdentifier identifier, final DataTreeConfiguration treeConfig) { for (final AugmentationSchemaNode potential : augSchemas.getAvailableAugmentations()) { for (final DataSchemaNode child : potential.getChildNodes()) { if (identifier.getPossibleChildNames().contains(child.getQName())) { return new AugmentationModificationStrategy(potential, resolvedTree, treeConfig); } } } return null; }
public static SchemaAwareApplyOperation from(final DataNodeContainer resolvedTree, final AugmentationTarget augSchemas, final AugmentationIdentifier identifier, final DataTreeConfiguration treeConfig) { for (final AugmentationSchemaNode potential : augSchemas.getAvailableAugmentations()) { for (final DataSchemaNode child : potential.getChildNodes()) { if (identifier.getPossibleChildNames().contains(child.getQName())) { return new AugmentationModificationStrategy(potential, resolvedTree, treeConfig); } } } return null; }
private void emitAugment(final AugmentationSchemaNode augmentation) { super.writer.startAugmentNode(augmentation.getTargetPath()); // FIXME: BUG-2444: whenNode //Optional // FIXME: BUG-2444: *(ifFeatureNode ) emitDocumentedNode(augmentation); for (final UsesNode uses : augmentation.getUses()) { emitUsesNode(uses); } for (final DataSchemaNode childNode : augmentation.getChildNodes()) { if (childNode instanceof CaseSchemaNode) { emitCaseNode((CaseSchemaNode) childNode); } else { emitDataSchemaNode(childNode); } } emitUnknownStatementNodes(augmentation.getUnknownSchemaNodes()); emitNotifications(augmentation.getNotifications()); emitActions(augmentation.getActions()); super.writer.endNode(); }