Hide CodecContext methods
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / CodecContext.java
1 /*
2  * Copyright (c) 2014 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.mdsal.binding.dom.codec.impl;
9
10 import org.eclipse.jdt.annotation.Nullable;
11 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
14
15 /**
16  * Location specific context for schema nodes, which contains codec specific information to properly serialize
17  * and deserialize from Java YANG Binding data to NormalizedNode data.
18  *
19  * <p>
20  * Two core subtypes of codec context are available:
21  * <ul>
22  *   <li>{@link ValueNodeCodecContext} for nodes, which do not contain any nested YANG modeled substructures</li>
23  *   <li>{@link DataContainerCodecContext} for nodes, which contain nested YANG modeled substructures. These context
24  *       nodes contain contexts for their individual children nodes</li>
25  * </ul>
26  */
27 abstract sealed class CodecContext implements BindingCodecTreeNode
28         permits DataContainerCodecContext, ValueNodeCodecContext {
29     /**
30      * Returns {@link NodeIdentifier} of current node, if applicable.
31      *
32      * @return NodeIdentifier of node, or {@code null} if not applicable
33      */
34     abstract @Nullable NodeIdentifier getDomPathArgument();
35
36     /**
37      * Return the default value object. Implementations of this method are explicitly allowed to throw unchecked
38      * exceptions, which are propagated as-is upwards the stack.
39      *
40      * @return The default value object, or null if the default value is not defined.
41      */
42     @Nullable Object defaultObject() {
43         return null;
44     }
45
46     abstract Object deserializeObject(NormalizedNode normalizedNode);
47 }