8ed23b050d5d27a3157e196e86eaa6058e1635a4
[yangtools.git] / yang / yang-data-codec-gson / src / main / java / org / opendaylight / yangtools / yang / data / codec / gson / EmptyJSONCodec.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
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
9 package org.opendaylight.yangtools.yang.data.codec.gson;
10
11 import com.google.gson.stream.JsonWriter;
12 import java.io.IOException;
13
14 final class EmptyJSONCodec implements JSONCodec<Void> {
15
16     static final EmptyJSONCodec INSTANCE = new EmptyJSONCodec();
17
18     private EmptyJSONCodec() {
19
20     }
21
22     @Override
23     public Void deserializeString(final String input) {
24         return null;
25     }
26
27     @Override
28     public void serializeToWriter(final JsonWriter writer, final Void value) throws IOException {
29         writer.beginArray();
30         writer.value((String) null);
31         writer.endArray();
32     }
33
34     @Override
35     public Class<Void> getDataClass() {
36         return Void.class;
37     }
38 }