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 java.lang.reflect.Method;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.concepts.Codec;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
16 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 * Abstract base class for atomic nodes. These are nodes which are not decomposed in the Binding Specification, such
20 * as LeafNodes and LeafSetNodes.
22 abstract class ValueNodeCodecContext extends NodeCodecContext implements NodeContextSupplier {
23 abstract static class WithCodec extends ValueNodeCodecContext {
24 private final @NonNull Codec<Object, Object> valueCodec;
26 WithCodec(final DataSchemaNode schema, final Codec<Object, Object> codec, final Method getter,
27 final Object defaultObject) {
28 super(schema, getter, defaultObject);
29 this.valueCodec = requireNonNull(codec);
33 final Codec<Object, Object> getValueCodec() {
38 private final @NonNull NodeIdentifier yangIdentifier;
39 private final @NonNull Method getter;
40 private final @NonNull DataSchemaNode schema;
41 private final Object defaultObject;
43 ValueNodeCodecContext(final DataSchemaNode schema, final Method getter, final Object defaultObject) {
44 this.yangIdentifier = NodeIdentifier.create(schema.getQName());
45 this.getter = requireNonNull(getter);
46 this.schema = requireNonNull(schema);
47 this.defaultObject = defaultObject;
51 protected final NodeIdentifier getDomPathArgument() {
52 return yangIdentifier;
56 public final NodeCodecContext get() {
60 final Method getGetter() {
64 abstract Codec<Object, Object> getValueCodec();
67 public final DataSchemaNode getSchema() {
72 final Object defaultObject() {