Merge branch 'master' of ../controller
[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 import org.opendaylight.yangtools.yang.common.Empty;
14
15 final class EmptyJSONCodec implements JSONCodec<Empty> {
16
17     static final EmptyJSONCodec INSTANCE = new EmptyJSONCodec();
18
19     private EmptyJSONCodec() {
20
21     }
22
23     @Override
24     public Class<Empty> getDataType() {
25         return Empty.class;
26     }
27
28     @Override
29     public Empty parseValue(final Object ctx, final String input) {
30         return Empty.getInstance();
31     }
32
33     @Override
34     public void writeValue(final JsonWriter ctx, final Empty value) throws IOException {
35         ctx.beginArray();
36         ctx.value((String) null);
37         ctx.endArray();
38     }
39 }