2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.data.codec.gson;
10 import com.google.gson.stream.JsonWriter;
11 import java.io.IOException;
13 interface JSONCodec<T> {
15 * Deserialize (parse) a String representation into its native format.
17 * @param value String representation
18 * @return Value in native format
19 * @throws IllegalArgumentException if the value does not parse or pass type validation
21 T deserializeString(String value);
24 * Serialize specified value with specified JsonWriter.
26 * @param writer JsonWriter
27 * @param value Value in native format
28 * @throws IOException if the write fails
30 void serializeToWriter(JsonWriter writer, T value) throws IOException;
33 * Return the internal representation class.
35 * @return Data representation class.
37 Class<T> getDataClass();