BUG 2973 - correction of output for empty yang type
[yangtools.git] / yang / yang-data-codec-gson / src / main / java / org / opendaylight / yangtools / yang / data / codec / gson / JSONEmptyCodec.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the terms of the Eclipse
5  * Public License v1.0 which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.codec.gson;
9
10 import com.google.gson.stream.JsonWriter;
11 import java.io.IOException;
12
13 final class JSONEmptyCodec implements JSONCodec<Object> {
14
15     static final JSONEmptyCodec INSTANCE = new JSONEmptyCodec();
16
17     private JSONEmptyCodec() {
18
19     }
20
21     @Override
22     public Object deserialize(final String input) {
23         return null;
24     }
25
26     @Override
27     public String serialize(final Object input) {
28         return null;
29     }
30
31     @Override
32     public boolean needQuotes() {
33         return false;
34     }
35
36     @Override
37     public void serializeToWriter(final JsonWriter writer, final Object value) throws IOException {
38         writer.beginArray();
39         writer.value((String) null);
40         writer.endArray();
41     }
42
43 }