5abad0bd01a571d23d838e957a6dd7a978edb5c9
[yangtools.git] / yang / yang-data-codec-xml / src / main / java / org / opendaylight / yangtools / yang / data / codec / xml / NullXmlCodec.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.yangtools.yang.data.codec.xml;
9
10 import javax.xml.namespace.NamespaceContext;
11 import javax.xml.stream.XMLStreamException;
12 import javax.xml.stream.XMLStreamWriter;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 final class NullXmlCodec implements XmlCodec<Object> {
17     static final NullXmlCodec INSTANCE = new NullXmlCodec();
18     private static final Logger LOG = LoggerFactory.getLogger(NullXmlCodec.class);
19
20     private NullXmlCodec() {
21
22     }
23
24     @Override
25     public Class<Object> getDataClass() {
26         return Object.class;
27     }
28
29     @Override
30     public void serializeToWriter(final XMLStreamWriter writer, final Object value) throws XMLStreamException {
31         // NOOP since codec is unkwown.
32         LOG.warn("Call of the serializeToWriter method on null codec. No operation performed.");
33     }
34
35     @Override
36     public Object deserializeFromString(final NamespaceContext namespaceContext, final String value) {
37         LOG.warn("Call of the deserializeString method on null codec. No operation performed.");
38         return null;
39     }
40
41 }