2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.dom.codec.impl;
10 import static java.util.Objects.requireNonNull;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
14 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
17 * Abstract base class for atomic nodes. These are nodes which are not decomposed in the Binding Specification, such
18 * as LeafNodes and LeafSetNodes.
20 abstract class ValueNodeCodecContext extends NodeCodecContext implements NodeContextSupplier {
21 abstract static class WithCodec extends ValueNodeCodecContext {
22 private final @NonNull ValueCodec<Object, Object> valueCodec;
24 WithCodec(final DataSchemaNode schema, final ValueCodec<Object, Object> codec, final String getterName,
25 final Object defaultObject) {
26 super(schema, getterName, defaultObject);
27 valueCodec = requireNonNull(codec);
31 final ValueCodec<Object, Object> getValueCodec() {
36 private final @NonNull NodeIdentifier yangIdentifier;
37 private final @NonNull String getterName;
38 private final @NonNull DataSchemaNode schema;
39 private final Object defaultObject;
41 ValueNodeCodecContext(final DataSchemaNode schema, final String getterName, final Object defaultObject) {
42 yangIdentifier = NodeIdentifier.create(schema.getQName());
43 this.getterName = requireNonNull(getterName);
44 this.schema = requireNonNull(schema);
45 this.defaultObject = defaultObject;
49 protected final NodeIdentifier getDomPathArgument() {
50 return yangIdentifier;
54 public final NodeCodecContext get() {
58 final String getGetterName() {
62 abstract ValueCodec<Object, Object> getValueCodec();
65 public final DataSchemaNode getSchema() {
70 final Object defaultObject() {