2b3e29bb7faf95abe89cf257a24835f4da7267f6
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / util / CopyUtils.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.parser.util;
9
10 import java.util.ArrayList;
11 import java.util.Collections;
12 import java.util.List;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
15 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
16 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
17 import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
18 import org.opendaylight.yangtools.yang.parser.builder.api.DataSchemaNodeBuilder;
19 import org.opendaylight.yangtools.yang.parser.builder.api.GroupingBuilder;
20 import org.opendaylight.yangtools.yang.parser.builder.api.SchemaNodeBuilder;
21 import org.opendaylight.yangtools.yang.parser.builder.api.TypeDefinitionBuilder;
22 import org.opendaylight.yangtools.yang.parser.builder.api.UsesNodeBuilder;
23 import org.opendaylight.yangtools.yang.parser.builder.impl.AnyXmlBuilder;
24 import org.opendaylight.yangtools.yang.parser.builder.impl.AugmentationSchemaBuilderImpl;
25 import org.opendaylight.yangtools.yang.parser.builder.impl.ChoiceBuilder;
26 import org.opendaylight.yangtools.yang.parser.builder.impl.ChoiceCaseBuilder;
27 import org.opendaylight.yangtools.yang.parser.builder.impl.ConstraintsBuilder;
28 import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder;
29 import org.opendaylight.yangtools.yang.parser.builder.impl.GroupingBuilderImpl;
30 import org.opendaylight.yangtools.yang.parser.builder.impl.IdentityrefTypeBuilder;
31 import org.opendaylight.yangtools.yang.parser.builder.impl.LeafListSchemaNodeBuilder;
32 import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder;
33 import org.opendaylight.yangtools.yang.parser.builder.impl.ListSchemaNodeBuilder;
34 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
35 import org.opendaylight.yangtools.yang.parser.builder.impl.TypeDefinitionBuilderImpl;
36 import org.opendaylight.yangtools.yang.parser.builder.impl.UnionTypeBuilder;
37 import org.opendaylight.yangtools.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
38 import org.opendaylight.yangtools.yang.parser.builder.impl.UsesNodeBuilderImpl;
39
40 public final class CopyUtils {
41
42     private CopyUtils() {
43     }
44
45     /**
46      * Create copy of DataSchemaNodeBuilder with new parent. If updateQName is
47      * true, qname of node will be corrected based on new parent.
48      *
49      * @param old
50      *            builder to copy
51      * @param newParent
52      *            new parent
53      * @param updateQName
54      *            flag to indicate if qname should be updated based on new
55      *            parent location
56      * @return copy of given builder
57      */
58     public static DataSchemaNodeBuilder copy(final DataSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
59         if (old instanceof AnyXmlBuilder) {
60             return copy((AnyXmlBuilder) old, newParent, updateQName);
61         } else if (old instanceof ChoiceBuilder) {
62             return copy((ChoiceBuilder) old, newParent, updateQName);
63         } else if (old instanceof ContainerSchemaNodeBuilder) {
64             return copy((ContainerSchemaNodeBuilder) old, newParent, updateQName);
65         } else if (old instanceof LeafSchemaNodeBuilder) {
66             return copy((LeafSchemaNodeBuilder) old, newParent, updateQName);
67         } else if (old instanceof LeafListSchemaNodeBuilder) {
68             return copy((LeafListSchemaNodeBuilder) old, newParent, updateQName);
69         } else if (old instanceof ListSchemaNodeBuilder) {
70             return copy((ListSchemaNodeBuilder) old, newParent, updateQName);
71         } else if (old instanceof ChoiceCaseBuilder) {
72             return copy((ChoiceCaseBuilder) old, newParent, updateQName);
73         } else {
74             throw new YangParseException(old.getModuleName(), old.getLine(),
75                     "Failed to copy node: Unknown type of DataSchemaNode: " + old);
76         }
77     }
78
79     private static AnyXmlBuilder copy(final AnyXmlBuilder old, final Builder newParent, final boolean updateQName) {
80         DataBean data = getdata(old, newParent, updateQName);
81         QName newQName = data.qname;
82         SchemaPath newSchemaPath = data.schemaPath;
83
84         AnyXmlBuilder copy = new AnyXmlBuilder(newParent.getModuleName(), newParent.getLine(), newQName, newSchemaPath);
85         copyConstraints(copy.getConstraints(), old.getConstraints());
86         copy.setParent(newParent);
87         copy.setDescription(old.getDescription());
88         copy.setReference(old.getReference());
89         copy.setStatus(old.getStatus());
90         copy.setAugmenting(old.isAugmenting());
91         copy.setAddedByUses(old.isAddedByUses());
92         copy.setConfiguration(old.isConfiguration());
93         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
94             copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
95         }
96
97         return copy;
98     }
99
100     private static ChoiceBuilder copy(final ChoiceBuilder old, final Builder newParent, final boolean updateQName) {
101         DataBean data = getdata(old, newParent, updateQName);
102         QName newQName = data.qname;
103         SchemaPath newSchemaPath = data.schemaPath;
104
105         ChoiceBuilder copy = new ChoiceBuilder(newParent.getModuleName(), newParent.getLine(), newQName, newSchemaPath);
106         copyConstraints(copy.getConstraints(), old.getConstraints());
107         copy.setParent(newParent);
108         copy.setDescription(old.getDescription());
109         copy.setReference(old.getReference());
110         copy.setStatus(old.getStatus());
111         copy.setAugmenting(old.isAugmenting());
112         copy.setAddedByUses(old.isAddedByUses());
113         copy.setConfiguration(old.isConfiguration());
114         for (ChoiceCaseBuilder childNode : old.getCases()) {
115             copy.addCase(copy(childNode, copy, updateQName));
116         }
117         for (AugmentationSchemaBuilder augment : old.getAugmentationBuilders()) {
118             copy.addAugmentation(copyAugment(augment, copy));
119         }
120         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
121             copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
122         }
123
124         return copy;
125     }
126
127     private static ChoiceCaseBuilder copy(final ChoiceCaseBuilder old, final Builder newParent, final boolean updateQName) {
128         DataBean data = getdata(old, newParent, updateQName);
129         QName newQName = data.qname;
130         SchemaPath newSchemaPath = data.schemaPath;
131
132         ChoiceCaseBuilder copy = new ChoiceCaseBuilder(newParent.getModuleName(), newParent.getLine(), newQName, newSchemaPath);
133         copyConstraints(copy.getConstraints(), old.getConstraints());
134         copy.setParent(newParent);
135         copy.setDescription(old.getDescription());
136         copy.setReference(old.getReference());
137         copy.setStatus(old.getStatus());
138         copy.setAugmenting(old.isAugmenting());
139         for (DataSchemaNodeBuilder childNode : old.getChildNodeBuilders()) {
140             copy.addChildNode(copy(childNode, copy, updateQName));
141         }
142         copy.getGroupings().addAll(old.getGroupings());
143         for (GroupingBuilder grouping : old.getGroupingBuilders()) {
144             copy.addGrouping(copy(grouping, copy, updateQName));
145         }
146         for (TypeDefinitionBuilder tdb : old.getTypeDefinitionBuilders()) {
147             copy.addTypedef(copy(tdb, copy, updateQName));
148         }
149         for (UsesNodeBuilder oldUses : old.getUsesNodeBuilders()) {
150             copy.addUsesNode(copyUses(oldUses, copy));
151         }
152         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
153             copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
154         }
155
156         return copy;
157     }
158
159     private static ContainerSchemaNodeBuilder copy(final ContainerSchemaNodeBuilder old, final Builder newParent,
160             final boolean updateQName) {
161         DataBean data = getdata(old, newParent, updateQName);
162         QName newQName = data.qname;
163         SchemaPath newSchemaPath = data.schemaPath;
164
165         ContainerSchemaNodeBuilder copy = new ContainerSchemaNodeBuilder(newParent.getModuleName(),
166                 newParent.getLine(), newQName, newSchemaPath);
167         copyConstraints(copy.getConstraints(), old.getConstraints());
168         copy.setParent(newParent);
169         copy.setDescription(old.getDescription());
170         copy.setReference(old.getReference());
171         copy.setStatus(old.getStatus());
172         copy.setPresence(old.isPresence());
173         copy.setAugmenting(old.isAugmenting());
174         copy.setAddedByUses(old.isAddedByUses());
175         copy.setConfiguration(old.isConfiguration());
176         for (DataSchemaNodeBuilder childNode : old.getChildNodeBuilders()) {
177             copy.addChildNode(copy(childNode, copy, updateQName));
178         }
179         copy.getGroupings().addAll(old.getGroupings());
180         for (GroupingBuilder grouping : old.getGroupingBuilders()) {
181             copy.addGrouping(copy(grouping, copy, updateQName));
182         }
183         for (TypeDefinitionBuilder tdb : old.getTypeDefinitionBuilders()) {
184             copy.addTypedef(copy(tdb, copy, updateQName));
185         }
186         for (UsesNodeBuilder oldUses : old.getUsesNodeBuilders()) {
187             copy.addUsesNode(copyUses(oldUses, copy));
188         }
189         for (AugmentationSchemaBuilder augment : old.getAugmentationBuilders()) {
190             copy.addAugmentation(copyAugment(augment, copy));
191         }
192         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
193             copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
194         }
195
196         return copy;
197     }
198
199     private static LeafSchemaNodeBuilder copy(final LeafSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
200         DataBean data = getdata(old, newParent, updateQName);
201         QName newQName = data.qname;
202         SchemaPath newSchemaPath = data.schemaPath;
203
204         LeafSchemaNodeBuilder copy = new LeafSchemaNodeBuilder(newParent.getModuleName(), newParent.getLine(),
205                 newQName, newSchemaPath);
206         copyConstraints(copy.getConstraints(), old.getConstraints());
207         copy.setParent(newParent);
208         copy.setDescription(old.getDescription());
209         copy.setReference(old.getReference());
210         copy.setStatus(old.getStatus());
211         copy.setAugmenting(old.isAugmenting());
212         copy.setAddedByUses(old.isAddedByUses());
213         copy.setConfiguration(old.isConfiguration());
214         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
215             copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
216         }
217
218         if (old.getType() == null) {
219             copy.setTypedef(copy(old.getTypedef(), copy, updateQName));
220         } else {
221             copy.setType(old.getType());
222         }
223
224         copy.setDefaultStr(old.getDefaultStr());
225         copy.setUnits(old.getUnits());
226
227         return copy;
228     }
229
230     public static LeafListSchemaNodeBuilder copy(final LeafListSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
231         DataBean data = getdata(old, newParent, updateQName);
232         QName newQName = data.qname;
233         SchemaPath newSchemaPath = data.schemaPath;
234
235         LeafListSchemaNodeBuilder copy = new LeafListSchemaNodeBuilder(newParent.getModuleName(), newParent.getLine(),
236                 newQName, newSchemaPath);
237         copyConstraints(copy.getConstraints(), old.getConstraints());
238         copy.setParent(newParent);
239         copy.setDescription(old.getDescription());
240         copy.setReference(old.getReference());
241         copy.setStatus(old.getStatus());
242         copy.setAugmenting(old.isAugmenting());
243         copy.setAddedByUses(old.isAddedByUses());
244         copy.setConfiguration(old.isConfiguration());
245         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
246             copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
247         }
248
249         if (old.getType() == null) {
250             copy.setTypedef(copy(old.getTypedef(), copy, updateQName));
251         } else {
252             copy.setType(old.getType());
253         }
254
255         copy.setUserOrdered(old.isUserOrdered());
256
257         return copy;
258     }
259
260     private static ListSchemaNodeBuilder copy(final ListSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
261         DataBean data = getdata(old, newParent, updateQName);
262         QName newQName = data.qname;
263         SchemaPath newSchemaPath = data.schemaPath;
264
265         ListSchemaNodeBuilder copy = new ListSchemaNodeBuilder(newParent.getModuleName(), newParent.getLine(),
266                 newQName, newSchemaPath);
267         copyConstraints(copy.getConstraints(), old.getConstraints());
268         copy.setParent(newParent);
269         copy.setDescription(old.getDescription());
270         copy.setReference(old.getReference());
271         copy.setStatus(old.getStatus());
272         copy.setAugmenting(old.isAugmenting());
273         copy.setAddedByUses(old.isAddedByUses());
274         copy.setConfiguration(old.isConfiguration());
275         for (DataSchemaNodeBuilder childNode : old.getChildNodeBuilders()) {
276             copy.addChildNode(copy(childNode, copy, updateQName));
277         }
278         copy.getGroupings().addAll(old.getGroupings());
279         for (GroupingBuilder grouping : old.getGroupingBuilders()) {
280             copy.addGrouping(copy(grouping, copy, updateQName));
281         }
282         for (TypeDefinitionBuilder tdb : old.getTypeDefinitionBuilders()) {
283             copy.addTypedef(copy(tdb, copy, updateQName));
284         }
285         for (UsesNodeBuilder oldUses : old.getUsesNodeBuilders()) {
286             copy.addUsesNode(copyUses(oldUses, copy));
287         }
288         for (AugmentationSchemaBuilder augment : old.getAugmentationBuilders()) {
289             copy.addAugmentation(copyAugment(augment, copy));
290         }
291         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
292             copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
293         }
294
295         copy.setUserOrdered(old.isUserOrdered());
296         copy.setKeys(old.getKeys());
297
298         return copy;
299     }
300
301     public static GroupingBuilder copy(final GroupingBuilder old, final Builder newParent, final boolean updateQName) {
302         DataBean data = getdata(old, newParent, updateQName);
303         QName newQName = data.qname;
304         SchemaPath newSchemaPath = data.schemaPath;
305
306         GroupingBuilderImpl copy = new GroupingBuilderImpl(newParent.getModuleName(), newParent.getLine(), newQName, newSchemaPath);
307         copy.setParent(newParent);
308         copy.setDescription(old.getDescription());
309         copy.setReference(old.getReference());
310         copy.setStatus(old.getStatus());
311         copy.setAddedByUses(old.isAddedByUses());
312         for (DataSchemaNodeBuilder childNode : old.getChildNodeBuilders()) {
313             copy.addChildNode(copy(childNode, copy, updateQName));
314         }
315         copy.getGroupings().addAll(old.getGroupings());
316         for (GroupingBuilder grouping : old.getGroupingBuilders()) {
317             copy.addGrouping(copy(grouping, copy, updateQName));
318         }
319         for (TypeDefinitionBuilder tdb : old.getTypeDefinitionBuilders()) {
320             copy.addTypedef(copy(tdb, copy, updateQName));
321         }
322         for (UsesNodeBuilder oldUses : old.getUsesNodeBuilders()) {
323             copy.addUsesNode(copyUses(oldUses, copy));
324         }
325         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
326             copy.addUnknownNodeBuilder((copy(un, copy, updateQName)));
327         }
328
329         return copy;
330     }
331
332     public static TypeDefinitionBuilder copy(final TypeDefinitionBuilder old, final Builder newParent, final boolean updateQName) {
333         DataBean data = getdata(old, newParent, updateQName);
334         QName newQName = data.qname;
335         SchemaPath newSchemaPath = data.schemaPath;
336         TypeDefinitionBuilder type;
337
338         if (old instanceof UnionTypeBuilder) {
339             UnionTypeBuilder oldUnion = (UnionTypeBuilder) old;
340             type = new UnionTypeBuilder(newParent.getModuleName(), newParent.getLine());
341             type.setParent(newParent);
342             for (TypeDefinition<?> td : oldUnion.getTypes()) {
343                 type.setType(td);
344             }
345             for (TypeDefinitionBuilder tdb : oldUnion.getTypedefs()) {
346                 type.setTypedef(copy(tdb, type, updateQName));
347             }
348         } else if (old instanceof IdentityrefTypeBuilder) {
349             type = new IdentityrefTypeBuilder(newParent.getModuleName(), newParent.getLine(),
350                     ((IdentityrefTypeBuilder) old).getBaseString(), newSchemaPath);
351             type.setParent(newParent);
352         } else {
353             type = new TypeDefinitionBuilderImpl(old.getModuleName(), newParent.getLine(), newQName, old.getPath());
354             type.setParent(newParent);
355
356             if (old.getType() == null) {
357                 type.setTypedef(copy(old.getTypedef(), type, updateQName));
358             } else {
359                 type.setType(old.getType());
360             }
361
362             for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
363                 type.addUnknownNodeBuilder((copy(un, type, updateQName)));
364             }
365
366             type.setRanges(old.getRanges());
367             type.setLengths(old.getLengths());
368             type.setPatterns(old.getPatterns());
369             type.setFractionDigits(old.getFractionDigits());
370             type.setDescription(old.getDescription());
371             type.setReference(old.getReference());
372             type.setStatus(old.getStatus());
373             type.setUnits(old.getUnits());
374             type.setDefaultValue(old.getDefaultValue());
375             type.setAddedByUses(old.isAddedByUses());
376         }
377
378         return type;
379     }
380
381     private static ConstraintsBuilder copyConstraints(final ConstraintsBuilder newConstraints, final ConstraintsBuilder old) {
382         newConstraints.getMustDefinitions().addAll(old.getMustDefinitions());
383         newConstraints.addWhenCondition(old.getWhenCondition());
384         newConstraints.setMandatory(old.isMandatory());
385         newConstraints.setMinElements(old.getMinElements());
386         newConstraints.setMaxElements(old.getMaxElements());
387         return newConstraints;
388     }
389
390     private static UsesNodeBuilder copyUses(final UsesNodeBuilder old, final Builder newParent) {
391         UsesNodeBuilder copy = new UsesNodeBuilderImpl(newParent.getModuleName(), newParent.getLine(),
392                 old.getGroupingPathAsString());
393         copy.setParent(newParent);
394         copy.setGroupingDefinition(old.getGroupingDefinition());
395         copy.setGrouping(old.getGroupingBuilder());
396         copy.setAddedByUses(old.isAddedByUses());
397         copy.getAugmentations().addAll(old.getAugmentations());
398         copy.getRefineNodes().addAll(old.getRefineNodes());
399         copy.getRefines().addAll(old.getRefines());
400         copy.setAugmenting(old.isAugmenting());
401         return copy;
402     }
403
404     private static AugmentationSchemaBuilder copyAugment(final AugmentationSchemaBuilder old, final Builder newParent) {
405         AugmentationSchemaBuilderImpl copy = new AugmentationSchemaBuilderImpl(newParent.getModuleName(),
406                 newParent.getLine(), old.getTargetPathAsString(), old.getOrder());
407         copy.setParent(newParent);
408         copy.setCopyOf(old);
409         copy.setDescription(old.getDescription());
410         copy.setReference(old.getReference());
411         copy.setStatus(old.getStatus());
412         copy.addWhenCondition(old.getWhenCondition());
413         copy.setTargetNodeSchemaPath(old.getTargetNodeSchemaPath());
414         for (DataSchemaNodeBuilder childNode : old.getChildNodeBuilders()) {
415             copy.addChildNode(copy(childNode, copy, false));
416         }
417         for (UsesNodeBuilder oldUses : old.getUsesNodeBuilders()) {
418             copy.addUsesNode(copyUses(oldUses, copy));
419         }
420         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
421             copy.addUnknownNodeBuilder((copy(un, copy, false)));
422         }
423
424         return copy;
425     }
426
427     public static UnknownSchemaNodeBuilder copy(final UnknownSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
428         DataBean data = getdata(old, newParent, updateQName);
429         QName newQName = data.qname;
430         SchemaPath newSchemaPath = data.schemaPath;
431
432         UnknownSchemaNodeBuilder c = new UnknownSchemaNodeBuilder(newParent.getModuleName(), newParent.getLine(),
433                 newQName, newSchemaPath);
434
435         c.setNodeType(old.getNodeType());
436         c.setNodeParameter(old.getNodeParameter());
437         c.setParent(newParent);
438         c.setDescription(old.getDescription());
439         c.setReference(old.getReference());
440         c.setStatus(old.getStatus());
441         c.setAddedByUses(old.isAddedByUses());
442         for (UnknownSchemaNodeBuilder un : old.getUnknownNodes()) {
443             c.addUnknownNodeBuilder((copy(un, c, updateQName)));
444         }
445         c.setExtensionBuilder(old.getExtensionBuilder());
446         c.setExtensionDefinition(old.getExtensionDefinition());
447
448         return c;
449     }
450
451     private static DataBean getdata(final SchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
452         List<QName> newPath = null;
453         QName newQName = null;
454         if (newParent instanceof ModuleBuilder) {
455             ModuleBuilder parent = (ModuleBuilder) newParent;
456             if (updateQName) {
457                 newQName = new QName(parent.getNamespace(), parent.getRevision(), parent.getPrefix(), old.getQName()
458                         .getLocalName());
459                 newPath = Collections.singletonList(newQName);
460             } else {
461                 newQName = old.getQName();
462                 newPath = Collections.singletonList(newQName);
463             }
464         } else if (newParent instanceof AugmentationSchemaBuilder) {
465             AugmentationSchemaBuilder augment = (AugmentationSchemaBuilder) newParent;
466             ModuleBuilder parent = ParserUtils.getParentModule(newParent);
467             if (updateQName) {
468                 newQName = new QName(parent.getNamespace(), parent.getRevision(), parent.getPrefix(), old.getQName()
469                         .getLocalName());
470                 newPath = new ArrayList<>(augment.getTargetNodeSchemaPath().getPath());
471                 newPath.add(newQName);
472             } else {
473                 newQName = old.getQName();
474                 newPath = new ArrayList<>(augment.getTargetNodeSchemaPath().getPath());
475                 newPath.add(newQName);
476             }
477
478         } else if (newParent instanceof SchemaNodeBuilder) {
479             SchemaNodeBuilder parent = (SchemaNodeBuilder) newParent;
480             QName parentQName = parent.getQName();
481             if (updateQName) {
482                 newQName = new QName(parentQName.getNamespace(), parentQName.getRevision(), parentQName.getPrefix(),
483                         old.getQName().getLocalName());
484                 newPath = new ArrayList<>(parent.getPath().getPath());
485                 newPath.add(newQName);
486             } else {
487                 newQName = old.getQName();
488                 newPath = new ArrayList<>(parent.getPath().getPath());
489                 newPath.add(newQName);
490             }
491         }
492
493         SchemaPath newSchemaPath = SchemaPath.create(newPath, true);
494         return new DataBean(newQName, newSchemaPath);
495     }
496
497     private static final class DataBean {
498         private final QName qname;
499         private final SchemaPath schemaPath;
500
501         private DataBean(final QName qname, final SchemaPath schemaPath) {
502             this.qname = qname;
503             this.schemaPath = schemaPath;
504         }
505     }
506
507 }