Add JSONValue and JSONCodec.unparseValue()
[yangtools.git] / codec / yang-data-codec-gson / src / main / java / org / opendaylight / yangtools / yang / data / codec / gson / NullJSONCodec.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.gson;
9
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
12
13 final class NullJSONCodec implements JSONCodec<Object> {
14     static final NullJSONCodec INSTANCE = new NullJSONCodec();
15     private static final Logger LOG = LoggerFactory.getLogger(NullJSONCodec.class);
16
17     private NullJSONCodec() {
18
19     }
20
21     @Override
22     public Class<Object> getDataType() {
23         return Object.class;
24     }
25
26     @Override
27     public Object parseValue(final String str) {
28         LOG.warn("Call of the deserializeString method on null codec. No operation performed.");
29         return null;
30     }
31
32     @Override
33     public void writeValue(final JSONValueWriter ctx, final Object value) {
34         // NOOP since codec is unknown.
35         LOG.warn("Call of the serializeToWriter method on null codec. No operation performed.");
36     }
37
38     @Override
39     public JSONValue unparseValue(final Object value) {
40         throw new UnsupportedOperationException();
41     }
42 }