2 * Copyright (c) 2016 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
9 package org.opendaylight.yangtools.yang.data.codec.xml;
11 import com.google.common.base.Preconditions;
12 import javax.xml.namespace.NamespaceContext;
13 import org.opendaylight.yangtools.yang.data.impl.codec.DataStringCodec;
14 import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
17 * Abstract base implementation of {@link XmlCodec}, which wraps a {@link TypeDefinitionAwareCodec}.
19 * @param <T> Deserialized object type
21 abstract class AbstractXmlCodec<T> implements XmlCodec<T> {
23 private final DataStringCodec<T> codec;
25 protected AbstractXmlCodec(final DataStringCodec<T> codec) {
26 this.codec = Preconditions.checkNotNull(codec);
30 public final Class<T> getDataClass() {
31 return codec.getInputClass();
35 public final T deserializeFromString(final NamespaceContext namespaceContext, final String value) {
36 return codec.deserialize(value);
39 final String serialize(final T input) {
40 return codec.serialize(input);