32d10e7572fd3dd28a1a703b0592174ae79ad176
[yangtools.git] / yang / yang-data-codec-gson / src / main / java / org / opendaylight / yangtools / yang / data / codec / gson / JSONCodec.java
1 /*
2  * Copyright (c) 2014 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 com.google.gson.stream.JsonWriter;
11 import java.io.IOException;
12
13 interface JSONCodec<T> {
14     /**
15      * Deserialize (parse) a String representation into its native format.
16      *
17      * @param value String representation
18      * @return Value in native format
19      * @throws IllegalArgumentException if the value does not parse or pass type validation
20      */
21     T deserializeString(String value);
22
23     /**
24      * Serialize specified value with specified JsonWriter.
25      *
26      * @param writer JsonWriter
27      * @param value Value in native format
28      * @throws IOException if the write fails
29      */
30     void serializeToWriter(JsonWriter writer, T value) throws IOException;
31
32     /**
33      * Return the internal representation class.
34      *
35      * @return Data representation class.
36      */
37     Class<T> getDataClass();
38 }