public static Set<AugmentationSchema> collectAllAugmentationDefinitions(final SchemaContext currentSchema, final AugmentationTarget ctxNode) { HashSet<AugmentationSchema> augmentations = new HashSet<>(); augmentations.addAll(ctxNode.getAvailableAugmentations()); if(ctxNode instanceof DataSchemaNode && ((DataSchemaNode) ctxNode).isAddedByUses()) { System.out.println(ctxNode); } // TODO Auto-generated method stub return augmentations; }
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(); }
public static Set<AugmentationSchemaNode> collectAllAugmentationDefinitions(final SchemaContext currentSchema, final AugmentationTarget ctxNode) { HashSet<AugmentationSchemaNode> augmentations = new HashSet<>(); augmentations.addAll(ctxNode.getAvailableAugmentations()); if (ctxNode instanceof DataSchemaNode && ((DataSchemaNode) ctxNode).isAddedByUses()) { LOG.info("DataSchemaNode target added by uses {}", ctxNode); } return augmentations; }
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(); }
public DataNodeContainerValidator(final DataNodeContainer schema) { this.schema = requireNonNull(schema, "Schema was null"); this.childNodes = getChildNodes(schema); if (schema instanceof AugmentationTarget) { for (AugmentationSchemaNode augmentation : ((AugmentationTarget) schema).getAvailableAugmentations()) { augments.add(DataSchemaContextNode.augmentationIdentifierFrom(augmentation)); } } }
public DataNodeContainerValidator(final DataNodeContainer schema) { this.schema = requireNonNull(schema, "Schema was null"); this.childNodes = getChildNodes(schema); if (schema instanceof AugmentationTarget) { for (AugmentationSchemaNode augmentation : ((AugmentationTarget) schema).getAvailableAugmentations()) { augments.add(DataSchemaContextNode.augmentationIdentifierFrom(augmentation)); } } }
private static AugmentationSchema findCorrespondingAugment(final DataSchemaNode parent, final DataSchemaNode child) { if (parent instanceof AugmentationTarget && !(parent instanceof ChoiceSchemaNode)) { for (final AugmentationSchema augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) { final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName()); if (childInAugmentation != null) { return augmentation; } } } return null; } }
private static boolean isFromAugment(final DataNodeContainer schema, final DataSchemaNode childSchema) { if (!(schema instanceof AugmentationTarget)) { return false; } for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) schema).getAvailableAugmentations()) { if (augmentation.getDataChildByName(childSchema.getQName()) != null) { return true; } } return false; }
private static boolean isFromAugment(final DataNodeContainer schema, final DataSchemaNode childSchema) { if (!(schema instanceof AugmentationTarget)) { return false; } for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) schema).getAvailableAugmentations()) { if (augmentation.getDataChildByName(childSchema.getQName()) != null) { return true; } } return false; }
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 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); }
/** * Tries to find in {@code parent} which is dealed as augmentation target node with QName as {@code child}. If such * node is found then it is returned, else null. * * @param parent parent node * @param child child node * @return augmentation schema */ public static AugmentationSchemaNode findCorrespondingAugment(final DataSchemaNode parent, final DataSchemaNode child) { if (!(parent instanceof AugmentationTarget) || parent instanceof ChoiceSchemaNode) { return null; } for (final AugmentationSchemaNode augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) { final DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName()); if (childInAugmentation != null) { return augmentation; } } return null; }
/** * Tries to find in {@code parent} which is dealed as augmentation target node with QName as {@code child}. If such * node is found then it is returned, else null. * * @param parent parent node * @param child child node * @return augmentation schema */ private static AugmentationSchemaNode findCorrespondingAugment(final DataSchemaNode parent, final DataSchemaNode child) { if (parent instanceof AugmentationTarget && !(parent instanceof ChoiceSchemaNode)) { for (AugmentationSchemaNode augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) { DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName()); if (childInAugmentation != null) { return augmentation; } } } return null; }
/** * Tries to find in {@code parent} which is dealed as augmentation target node with QName as {@code child}. If such * node is found then it is returned, else null. * * @param parent parent node * @param child child node * @return augmentation schema */ private static AugmentationSchemaNode findCorrespondingAugment(final DataSchemaNode parent, final DataSchemaNode child) { if (parent instanceof AugmentationTarget && !(parent instanceof ChoiceSchemaNode)) { for (AugmentationSchemaNode augmentation : ((AugmentationTarget) parent).getAvailableAugmentations()) { DataSchemaNode childInAugmentation = augmentation.getDataChildByName(child.getQName()); if (childInAugmentation != null) { return augmentation; } } } return null; }
/** * Returns a DataContextNodeOperation for provided child node * * <p> * If supplied child is added by Augmentation this operation returns a * DataContextNodeOperation for augmentation, otherwise returns a * DataContextNodeOperation for child as call for * {@link #fromDataSchemaNode(DataSchemaNode)}. */ static @Nullable DataSchemaContextNode<?> fromAugmentation(final DataNodeContainer parent, final AugmentationTarget parentAug, final DataSchemaNode child) { for (AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) { if (aug.findDataChildByName(child.getQName()).isPresent()) { return new AugmentationContextNode(aug, parent); } } return fromDataSchemaNode(child); }
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; }
/** * Returns a DataContextNodeOperation for provided child node * * <p> * If supplied child is added by Augmentation this operation returns a * DataContextNodeOperation for augmentation, otherwise returns a * DataContextNodeOperation for child as call for * {@link #fromDataSchemaNode(DataSchemaNode)}. */ static @Nullable DataSchemaContextNode<?> fromAugmentation(final DataNodeContainer parent, final AugmentationTarget parentAug, final DataSchemaNode child) { for (AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) { if (aug.findDataChildByName(child.getQName()).isPresent()) { return new AugmentationContextNode(aug, parent); } } return fromDataSchemaNode(child); }
/** * Returns a SchemaPathUtil for provided child node * <p/> * If supplied child is added by Augmentation this operation returns * a SchemaPathUtil for augmentation, * otherwise returns a SchemaPathUtil for child as * call for {@link #fromDataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode)}. */ private static InstanceIdToNodes<?> fromAugmentation(final DataNodeContainer parent, final AugmentationTarget parentAug, final DataSchemaNode child) { for (final AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) { final DataSchemaNode potential = aug.getDataChildByName(child.getQName()); if (potential != null) { return new InstanceIdToCompositeNodes.AugmentationNormalization(aug, parent); } } return fromDataSchemaNode(child); }
/** * Returns a SchemaPathUtil for provided child node * <p/> * If supplied child is added by Augmentation this operation returns * a SchemaPathUtil for augmentation, * otherwise returns a SchemaPathUtil for child as * call for {@link #fromDataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode)}. */ private static InstanceIdToNodes<?> fromAugmentation(final DataNodeContainer parent, final AugmentationTarget parentAug, final DataSchemaNode child) { for (final AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) { final DataSchemaNode potential = aug.getDataChildByName(child.getQName()); if (potential != null) { return new InstanceIdToCompositeNodes.AugmentationNormalization(aug, parent); } } return fromDataSchemaNode(child); }