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