Add JSONValue and JSONCodec.unparseValue()
[yangtools.git] / codec / 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 package org.opendaylight.yangtools.yang.data.codec.gson;
9
10 import java.io.IOException;
11 import org.opendaylight.yangtools.yang.common.Empty;
12
13 final class EmptyJSONCodec implements JSONCodec<Empty> {
14     static final EmptyJSONCodec INSTANCE = new EmptyJSONCodec();
15
16     private EmptyJSONCodec() {
17         // Hidden on purpose
18     }
19
20     @Override
21     public Class<Empty> getDataType() {
22         return Empty.class;
23     }
24
25     @Override
26     public Empty parseValue(final String input) {
27         return Empty.value();
28     }
29
30     @Override
31     public JSONValue unparseValue(final Empty value) {
32         return JSONValue.EMPTY;
33     }
34
35     @Override
36     public void writeValue(final JSONValueWriter ctx, final Empty value) throws IOException {
37         ctx.writeEmpty();
38     }
39 }