/** * 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; }
public ImmutableMap<AugmentationIdentifier,Type> getAvailableAugmentationTypes(final DataNodeContainer container) { final Map<AugmentationIdentifier,Type> identifierToType = new HashMap<>(); if (container instanceof AugmentationTarget) { for (final AugmentationSchemaNode augment : ((AugmentationTarget) container).getAvailableAugmentations()) { if (!isLocalAugment((AugmentationTarget) container, augment)) { // 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 Type augType = this.targetToAugmentation.get(augOrig.getTargetPath()); if (augType != null) { identifierToType.put(getAugmentationIdentifier(augment), augType); } } } } } return ImmutableMap.copyOf(identifierToType); }
@Override public List<UnknownSchemaNode> getUnknownSchemaNodes() { return delegate.getUnknownSchemaNodes(); }
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(); }
private void usesAugmentationToGenTypes(final ModuleContext context, final AugmentationSchemaNode augSchema, final UsesNode usesNode, final DataNodeContainer usesNodeParent) { checkArgument(augSchema != null, "Augmentation Schema cannot be NULL."); checkState(augSchema.getTargetPath() != null, "Augmentation Schema does not contain Target Path (Target Path is NULL)."); final SchemaPath targetPath = augSchema.getTargetPath(); final SchemaNode targetSchemaNode = findOriginalTargetFromGrouping(targetPath, usesNode); if (targetSchemaNode == null) { (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes(), usesNodeParent);
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); }
Map<String, GeneratedTypeBuilder> augmentBuilders = genTypeBuilders.computeIfAbsent(augmentPackageName, k -> new HashMap<>()); final String augIdentifier = getAugmentIdentifier(augSchema.getUnknownSchemaNodes()); annotateDeprecatedIfNecessary(augSchema.getStatus(), augTypeBuilder); addImplementedInterfaceFromUses(augSchema, augTypeBuilder); augSchemaNodeToMethods(context, augTypeBuilder, augSchema.getChildNodes()); augmentBuilders.put(augTypeName, augTypeBuilder); if (!augSchema.getChildNodes().isEmpty()) { context.addTypeToAugmentation(augTypeBuilder, augSchema);
@Override public SchemaPath getTargetPath() { return delegate.getTargetPath(); }
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; }
@Override public Optional<AugmentationSchemaNode> getOriginalDefinition() { return delegate.getOriginalDefinition(); }
@Override public Set<NotificationDefinition> getNotifications() { return delegate.getNotifications(); } }
@Override public Set<ActionDefinition> getActions() { return delegate.getActions(); }
checkState(augSchema.getTargetPath() != null, "Augmentation Schema does not contain Target Path (Target Path is NULL)."); final SchemaPath targetPath = augSchema.getTargetPath(); SchemaNode targetSchemaNode = null; (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes(), null);
@Override public SchemaPath getTargetPath() { return delegate.getTargetPath(); }
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; }
@Override public Optional<AugmentationSchemaNode> getOriginalDefinition() { return delegate.getOriginalDefinition(); }
@Override public Set<NotificationDefinition> getNotifications() { return delegate.getNotifications(); } }
@Override public Set<ActionDefinition> getActions() { return delegate.getActions(); }
/** * 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())); }
/** * Creates package name from <code>parentAugmentPackageName</code> (package * name for direct parent augmentation) and <code>augmentationSchema</code> . * * <p> * Resulting package name is concatenation of <code>parentAugmentPackageName</code> * and the local name of <code>schemaPath</code>. * * <p> * Based on type of node, there is also possible suffix added in order * to prevent package name conflicts. * * @param parentAugmentPackageName * string with package name of direct parent augmentation, MUST be normalized, * otherwise this method may return an invalid string. * @param augmentationSchema * augmentation schema which is direct son of parent augmentation. * @return string with valid JAVA package name * @throws NullPointerException if any of the arguments are null */ public static String packageNameForAugmentedGeneratedType(final String parentAugmentPackageName, final AugmentationSchemaNode augmentationSchema) { final QName last = augmentationSchema.getTargetPath().getLastComponent(); return generateNormalizedPackageName(parentAugmentPackageName, last); }