Switch to Objects.requireNonNull
[mdsal.git] / binding2 / mdsal-binding2-dom-codec / src / main / java / org / opendaylight / mdsal / binding / javav2 / dom / codec / impl / context / base / BindingCodecContext.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.mdsal.binding.javav2.dom.codec.impl.context.base;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import com.google.common.base.Preconditions;
14 import com.google.common.collect.ImmutableMap;
15 import java.lang.reflect.Method;
16 import java.lang.reflect.ParameterizedType;
17 import java.lang.reflect.Type;
18 import java.util.AbstractMap.SimpleEntry;
19 import java.util.Collection;
20 import java.util.HashMap;
21 import java.util.LinkedList;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Map.Entry;
25 import java.util.concurrent.Callable;
26 import javax.annotation.Nonnull;
27 import javax.annotation.Nullable;
28 import javax.xml.transform.dom.DOMSource;
29 import org.opendaylight.mdsal.binding.javav2.dom.codec.api.BindingTreeCodec;
30 import org.opendaylight.mdsal.binding.javav2.dom.codec.api.BindingTreeNodeCodec;
31 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.AnyxmlCodec;
32 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
33 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.IdentifiableItemCodec;
34 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.IdentityCodec;
35 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.InstanceIdentifierCodec;
36 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.OperationInputCodec;
37 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.UnionTypeCodec;
38 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.CaseNodeCodecContext;
39 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.ChoiceNodeCodecContext;
40 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.ListNodeCodecContext;
41 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.NotificationCodecContext;
42 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.SchemaRootCodecContext;
43 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.ValueContext;
44 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base.NodeCodecContext.CodecContextFactory;
45 import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.value.ValueTypeCodec;
46 import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifier;
47 import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer;
48 import org.opendaylight.mdsal.binding.javav2.model.api.GeneratedType;
49 import org.opendaylight.mdsal.binding.javav2.runtime.context.BindingRuntimeContext;
50 import org.opendaylight.mdsal.binding.javav2.runtime.reflection.BindingReflections;
51 import org.opendaylight.mdsal.binding.javav2.spec.base.IdentifiableItem;
52 import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
53 import org.opendaylight.mdsal.binding.javav2.spec.base.Instantiable;
54 import org.opendaylight.mdsal.binding.javav2.spec.base.Notification;
55 import org.opendaylight.mdsal.binding.javav2.spec.base.TreeArgument;
56 import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
57 import org.opendaylight.mdsal.binding.javav2.spec.runtime.BindingStreamEventWriter;
58 import org.opendaylight.mdsal.binding.javav2.spec.runtime.TreeNodeSerializer;
59 import org.opendaylight.yangtools.concepts.Codec;
60 import org.opendaylight.yangtools.concepts.Identifiable;
61 import org.opendaylight.yangtools.concepts.Identifier;
62 import org.opendaylight.yangtools.concepts.Immutable;
63 import org.opendaylight.yangtools.util.ClassLoaderUtils;
64 import org.opendaylight.yangtools.yang.common.Empty;
65 import org.opendaylight.yangtools.yang.common.QName;
66 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
67 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
68 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
69 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
70 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
71 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
72 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
73 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
74 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
75 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
76 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
77 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
78 import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
79 import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
80 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
81 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
82 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
83 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
84 import org.slf4j.Logger;
85 import org.slf4j.LoggerFactory;
86 import org.w3c.dom.Document;
87
88 /**
89  * Binding codec context for holding runtime part and codecs.
90  */
91 @Beta
92 public final class BindingCodecContext implements CodecContextFactory, BindingTreeCodec, Immutable {
93
94     private static final Logger LOG = LoggerFactory.getLogger(BindingCodecContext.class);
95
96     private final Codec<YangInstanceIdentifier, InstanceIdentifier<?>> instanceIdentifierCodec;
97     private final Codec<QName, Class<?>> identityCodec;
98     private final Codec<DOMSource, Document> anyxmlCodec;
99     private final BindingNormalizedNodeCodecRegistry registry;
100     private final BindingRuntimeContext context;
101     private final SchemaRootCodecContext<?> root;
102
103     /**
104      * Prepare runtime context and codec registry.
105      *
106      * @param context
107      *            - runtime context
108      * @param registry
109      *            - binding normalized node codec registry
110      */
111     public BindingCodecContext(final BindingRuntimeContext context, final BindingNormalizedNodeCodecRegistry registry) {
112         this.context = requireNonNull(context, "Binding Runtime Context is required.");
113         this.root = SchemaRootCodecContext.create(this);
114         this.identityCodec = new IdentityCodec(context);
115         this.anyxmlCodec = new AnyxmlCodec(context);
116         this.instanceIdentifierCodec = new InstanceIdentifierCodec(this);
117         this.registry = requireNonNull(registry);
118     }
119
120     @Override
121     public BindingRuntimeContext getRuntimeContext() {
122         return context;
123     }
124
125     /**
126      * Get instance identifier codec.
127      *
128      * @return instance identifier codec
129      */
130     public Codec<YangInstanceIdentifier, InstanceIdentifier<?>> getInstanceIdentifierCodec() {
131         return instanceIdentifierCodec;
132     }
133
134     /**
135      * Get identity codec.
136      *
137      * @return identity codec
138      */
139     public Codec<QName, Class<?>> getIdentityCodec() {
140         return identityCodec;
141     }
142
143     /**
144      * Get anyxml codec.
145      *
146      * @return anyxml codec
147      */
148     public Codec<DOMSource, Document> getAnyxmlCodec() {
149         return anyxmlCodec;
150     }
151
152     @SuppressWarnings({ "rawtypes", "unchecked" })
153     @Override
154     public TreeNodeSerializer getEventStreamSerializer(final Class<?> type) {
155         return registry.getSerializer((Class) type);
156     }
157
158     /**
159      * Prepare specific writer for binding path.
160      *
161      * @param path
162      *            - binding path
163      * @param domWriter
164      *            - DOM writer
165      * @return entry of DOM path and writer
166      */
167     public Entry<YangInstanceIdentifier, BindingStreamEventWriter> newWriter(final InstanceIdentifier<?> path,
168             final NormalizedNodeStreamWriter domWriter) {
169         final List<YangInstanceIdentifier.PathArgument> yangArgs = new LinkedList<>();
170         final DataContainerCodecContext<?, ?> codecContext = getCodecContextNode(path, yangArgs);
171         return new SimpleEntry<>(YangInstanceIdentifier.create(yangArgs), codecContext.createWriter(domWriter));
172     }
173
174     /**
175      * Prepare specific writer for binding path without DOM identifier.
176      *
177      * @param path
178      *            - binding path
179      * @param domWriter
180      *            - DOM writer
181      * @return stream event writer for binding path
182      */
183     public BindingStreamEventWriter newWriterWithoutIdentifier(final InstanceIdentifier<?> path,
184             final NormalizedNodeStreamWriter domWriter) {
185         return getCodecContextNode(path, null).createWriter(domWriter);
186     }
187
188     /**
189      * Prepare specific writer for operations.
190      *
191      * @param operationInputOrOutput
192      *            - binding data
193      * @param domWriter
194      *            - DOM writer
195      * @return stream event writer for operation
196      */
197     public BindingStreamEventWriter newOperationWriter(final Class<? extends Instantiable<?>> operationInputOrOutput,
198             final NormalizedNodeStreamWriter domWriter) {
199         return root.getOperation(operationInputOrOutput).createWriter(domWriter);
200     }
201
202     @SuppressWarnings("rawtypes")
203     public BindingStreamEventWriter newNotificationWriter(final Class<? extends Notification> notification,
204             final NormalizedNodeStreamWriter domWriter) {
205         return root.getNotification(notification).createWriter(domWriter);
206     }
207
208     /**
209      * Prepare context from Binding and DOM path.
210      *
211      * @param binding
212      *            - binding path
213      * @param builder
214      *            - DOM path
215      *
216      * @return context for path
217      */
218     public DataContainerCodecContext<?, ?> getCodecContextNode(final InstanceIdentifier<?> binding,
219             final List<YangInstanceIdentifier.PathArgument> builder) {
220         DataContainerCodecContext<?, ?> currentNode = root;
221         for (final TreeArgument<?> bindingArg : binding.getPathArguments()) {
222             currentNode = currentNode.bindingPathArgumentChild(bindingArg, builder);
223             Preconditions.checkArgument(currentNode != null, "Supplied Instance Identifier %s is not valid.", binding);
224         }
225         return currentNode;
226     }
227
228     /**
229      * Multi-purpose utility function. Traverse the codec tree, looking for the appropriate codec for the
230      * specified {@link YangInstanceIdentifier}. As a side-effect, gather all traversed binding
231      * {@link TreeArgument} into the supplied collection.
232      *
233      * @param dom
234      *            {@link YangInstanceIdentifier} which is to be translated
235      * @param bindingArguments
236      *            Collection for traversed path arguments
237      * @return Codec for target node, or @null if the node does not have a binding representation (choice,
238      *         case, leaf).
239      *
240      */
241     @Nullable
242     public NodeCodecContext<?> getCodecContextNode(final @Nonnull YangInstanceIdentifier dom,
243             final @Nullable Collection<TreeArgument<?>> bindingArguments) {
244         NodeCodecContext<?> currentNode = root;
245         ListNodeCodecContext<?> currentList = null;
246
247         for (final YangInstanceIdentifier.PathArgument domArg : dom.getPathArguments()) {
248             Preconditions.checkArgument(currentNode instanceof DataContainerCodecContext<?, ?>,
249                     "Unexpected child of non-container node %s", currentNode);
250             final DataContainerCodecContext<?, ?> previous = (DataContainerCodecContext<?, ?>) currentNode;
251             final NodeCodecContext<?> nextNode = previous.yangPathArgumentChild(domArg);
252
253             /*
254              * List representation in YANG Instance Identifier consists of two arguments: first is list as a
255              * whole, second is list as an item so if it is /list it means list as whole, if it is /list/list
256              * - it is wildcarded and if it is /list/list[key] it is concrete item, all this variations are
257              * expressed in Binding Aware Instance Identifier as Item or IdentifiableItem
258              */
259             if (currentList != null) {
260                 Preconditions.checkArgument(currentList == nextNode,
261                         "List should be referenced two times in YANG Instance Identifier %s", dom);
262
263                 // We entered list, so now we have all information to emit
264                 // list path using second list argument.
265                 if (bindingArguments != null) {
266                     bindingArguments.add(currentList.getBindingPathArgument(domArg));
267                 }
268                 currentList = null;
269                 currentNode = nextNode;
270             } else if (nextNode instanceof ListNodeCodecContext) {
271                 // We enter list, we do not update current Node yet,
272                 // since we need to verify
273                 currentList = (ListNodeCodecContext<?>) nextNode;
274             } else if (nextNode instanceof ChoiceNodeCodecContext) {
275                 // We do not add path argument for choice, since
276                 // it is not supported by binding instance identifier.
277                 currentNode = nextNode;
278             } else if (nextNode instanceof DataContainerCodecContext<?, ?>) {
279                 if (bindingArguments != null) {
280                     bindingArguments.add(((DataContainerCodecContext<?, ?>) nextNode).getBindingPathArgument(domArg));
281                 }
282                 currentNode = nextNode;
283             } else if (nextNode instanceof LeafNodeCodecContext) {
284                 LOG.debug("Instance identifier referencing a leaf is not representable (%s)", dom);
285                 return null;
286             }
287         }
288
289         // Algorithm ended in list as whole representation
290         // we sill need to emit identifier for list
291         if (currentNode instanceof ChoiceNodeCodecContext) {
292             LOG.debug("Instance identifier targeting a choice is not representable (%s)", dom);
293             return null;
294         }
295         if (currentNode instanceof CaseNodeCodecContext) {
296             LOG.debug("Instance identifier targeting a case is not representable (%s)", dom);
297             return null;
298         }
299
300         if (currentList != null) {
301             if (bindingArguments != null) {
302                 bindingArguments.add(currentList.getBindingPathArgument(null));
303             }
304             return currentList;
305         }
306         return currentNode;
307     }
308
309     /**
310      * Get notification codec according to notification schema path.
311      *
312      * @param notification
313      *            - schema path of notification
314      * @return notification codec context
315      */
316     public NotificationCodecContext<?> getNotificationContext(final SchemaPath notification) {
317         return root.getNotification(notification);
318     }
319
320     /**
321      * Get operation input codec.
322      *
323      * @param path
324      *            - path of input data of operation
325      * @return operation input codec
326      */
327     public OperationInputCodec<?> getOperationInputCodec(final SchemaPath path) {
328         return root.getOperation(path);
329     }
330
331     @Override
332     public ImmutableMap<String, LeafNodeCodecContext<?>> getLeafNodes(final Class<?> parentClass,
333             final DataNodeContainer childSchema) {
334         final Map<String, DataSchemaNode> getterToLeafSchema = new HashMap<>();
335         for (final DataSchemaNode leaf : childSchema.getChildNodes()) {
336             if (leaf instanceof TypedDataSchemaNode) {
337                 getterToLeafSchema.put(getGetterName(leaf, ((TypedDataSchemaNode) leaf).getType()), leaf);
338             }
339         }
340         return getLeafNodesUsingReflection(parentClass, getterToLeafSchema);
341     }
342
343     @Override
344     public ImmutableMap<String, AnyxmlNodeCodecContext<?>> getAnyxmlNodes(final Class<?> parentClass,
345             final DataNodeContainer childSchema) {
346         final Map<String, DataSchemaNode> getterToAnyxmlSchema = new HashMap<>();
347         for (final DataSchemaNode anyxml : childSchema.getChildNodes()) {
348             if (anyxml instanceof AnyXmlSchemaNode) {
349                 getterToAnyxmlSchema.put(getGetterName(anyxml.getQName(), false), anyxml);
350             }
351         }
352         return getAnyxmlNodesUsingReflection(parentClass, getterToAnyxmlSchema);
353     }
354
355     private static String getGetterName(final SchemaNode node, final TypeDefinition<?> typeDef) {
356         final String suffix = JavaIdentifierNormalizer.normalizeSpecificIdentifier(node.getQName().getLocalName(),
357             JavaIdentifier.CLASS);
358
359         if (typeDef instanceof BooleanTypeDefinition
360                 && (typeDef.getPath().equals(node.getPath()) || typeDef.getBaseType() == null)) {
361             return "is" + suffix;
362         }
363
364         return "get" + suffix;
365     }
366
367     private static String getGetterName(final QName qname, final boolean booleanOrEmpty) {
368         final String suffix =
369                 JavaIdentifierNormalizer.normalizeSpecificIdentifier(qname.getLocalName(), JavaIdentifier.CLASS);
370         if (booleanOrEmpty) {
371             return "is" + suffix;
372         }
373         return "get" + suffix;
374     }
375
376     private ImmutableMap<String, LeafNodeCodecContext<?>> getLeafNodesUsingReflection(final Class<?> parentClass,
377             final Map<String, DataSchemaNode> getterToLeafSchema) {
378         final Map<String, LeafNodeCodecContext<?>> leaves = new HashMap<>();
379         for (final Method method : parentClass.getMethods()) {
380             if (method.getParameterTypes().length == 0) {
381                 final DataSchemaNode schema = getterToLeafSchema.get(method.getName());
382                 final Class<?> valueType;
383                 if (schema instanceof LeafSchemaNode) {
384                     valueType = method.getReturnType();
385                 } else if (schema instanceof LeafListSchemaNode) {
386                     final Type genericType = ClassLoaderUtils.getFirstGenericParameter(method.getGenericReturnType());
387
388                     if (genericType instanceof Class<?>) {
389                         valueType = (Class<?>) genericType;
390                     } else if (genericType instanceof ParameterizedType) {
391                         valueType = (Class<?>) ((ParameterizedType) genericType).getRawType();
392                     } else {
393                         throw new IllegalStateException("Unexpected return type " + genericType);
394                     }
395                 } else {
396                     continue; // We do not have schema for leaf, so we will ignore it (eg. getClass,
397                               // getImplementedInterface).
398                 }
399                 final Codec<Object, Object> codec = getCodec(valueType, schema);
400                 final LeafNodeCodecContext<?> leafNode =
401                         new LeafNodeCodecContext<>(schema, codec, method, context.getSchemaContext());
402                 leaves.put(schema.getQName().getLocalName(), leafNode);
403             }
404         }
405         return ImmutableMap.copyOf(leaves);
406     }
407
408     private ImmutableMap<String, AnyxmlNodeCodecContext<?>> getAnyxmlNodesUsingReflection(final Class<?> parentClass,
409             final Map<String, DataSchemaNode> getterToAnyxmlSchema) {
410         final Map<String, AnyxmlNodeCodecContext<?>> anyxmls = new HashMap<>();
411         for (final Method method : parentClass.getMethods()) {
412             if (method.getParameterTypes().length == 0) {
413                 final DataSchemaNode schema = getterToAnyxmlSchema.get(method.getName());
414                 if (schema instanceof AnyXmlSchemaNode) {
415                     final Class<?> valueType = method.getReturnType();
416                     final Codec<Object, Object> codec = (Codec) getAnyxmlCodec();
417                     final AnyxmlNodeCodecContext<?> anyxmlNodeCtx =
418                             new AnyxmlNodeCodecContext<>(schema, codec, method, context.getSchemaContext());
419                     anyxmls.put(schema.getQName().getLocalName(), anyxmlNodeCtx);
420                 }
421             }
422         }
423         return ImmutableMap.copyOf(anyxmls);
424     }
425
426     private Codec<Object, Object> getCodec(final Class<?> valueType, final DataSchemaNode schema) {
427         Preconditions.checkArgument(schema instanceof TypedDataSchemaNode, "Unsupported leaf node type %s", schema);
428
429         return getCodec(valueType, ((TypedDataSchemaNode) schema).getType());
430     }
431
432     /**
433      * Get specific codec for binding class by type.
434      *
435      * @param valueType
436      *            - binding class
437      * @param instantiatedType
438      *            - type definition
439      * @return specific codec
440      */
441     public Codec<Object, Object> getCodec(final Class<?> valueType, final TypeDefinition<?> instantiatedType) {
442         if (Class.class.equals(valueType)) {
443             @SuppressWarnings({ "unchecked", "rawtypes" })
444             final Codec<Object, Object> casted = (Codec) identityCodec;
445             return casted;
446         } else if (InstanceIdentifier.class.equals(valueType)) {
447             @SuppressWarnings({ "unchecked", "rawtypes" })
448             final Codec<Object, Object> casted = (Codec) instanceIdentifierCodec;
449             return casted;
450         } else if (Empty.class.equals(valueType)) {
451             return ValueTypeCodec.EMPTY_CODEC;
452         } else if (BindingReflections.isBindingClass(valueType)) {
453             return getCodecForBindingClass(valueType, instantiatedType);
454         }
455         return ValueTypeCodec.NOOP_CODEC;
456     }
457
458     @SuppressWarnings("checkstyle:IllegalCatch")
459     private Codec<Object, Object> getCodecForBindingClass(final Class<?> valueType, final TypeDefinition<?> typeDef) {
460         if (typeDef instanceof IdentityrefTypeDefinition) {
461             return ValueTypeCodec.encapsulatedValueCodecFor(valueType, typeDef, identityCodec);
462         } else if (typeDef instanceof InstanceIdentifierTypeDefinition) {
463             return ValueTypeCodec.encapsulatedValueCodecFor(valueType, typeDef, instanceIdentifierCodec);
464         } else if (typeDef instanceof UnionTypeDefinition) {
465             final Callable<UnionTypeCodec> loader =
466                     UnionTypeCodec.loader(valueType, (UnionTypeDefinition) typeDef, this);
467             try {
468                 return loader.call();
469             } catch (final Exception e) {
470                 throw new IllegalStateException("Unable to load codec for " + valueType, e);
471             }
472         } else if (typeDef instanceof LeafrefTypeDefinition) {
473             final Entry<GeneratedType, Object> typeWithSchema = context.getTypeWithSchema(valueType);
474             final Object schema = typeWithSchema.getValue();
475             Preconditions.checkState(schema instanceof TypeDefinition<?>);
476             return getCodec(valueType, (TypeDefinition<?>) schema);
477         }
478         return ValueTypeCodec.getCodecFor(valueType, typeDef);
479     }
480
481     @Override
482     public Codec<NodeIdentifierWithPredicates, IdentifiableItem<?, ?>> getPathArgumentCodec(final Class<?> listClz,
483             final ListSchemaNode schema) {
484         final Class<? extends Identifier> identifier =
485                 ClassLoaderUtils.findFirstGenericArgument(listClz, Identifiable.class);
486         final Map<QName, ValueContext> valueCtx = new HashMap<>();
487         for (final LeafNodeCodecContext<?> leaf : getLeafNodes(identifier, schema).values()) {
488             final QName name = leaf.getDomPathArgument().getNodeType();
489             valueCtx.put(name, new ValueContext(identifier, leaf));
490         }
491         return new IdentifiableItemCodec(schema, identifier, listClz, valueCtx);
492     }
493
494     @SuppressWarnings("unchecked")
495     @Nullable
496     @Override
497     public <T extends TreeNode> BindingTreeNodeCodec<T> getSubtreeCodec(final InstanceIdentifier<T> path) {
498         return (BindingTreeNodeCodec<T>) getCodecContextNode(path, null);
499     }
500
501     @Nullable
502     @Override
503     public BindingTreeNodeCodec<?> getSubtreeCodec(final YangInstanceIdentifier path) {
504         return getCodecContextNode(path, null);
505     }
506
507     @Nullable
508     @Override
509     public BindingTreeNodeCodec<?> getSubtreeCodec(final SchemaPath path) {
510         throw new UnsupportedOperationException("Not implemented yet.");
511     }
512 }