github.com/keysonZZZ/kmg@v0.0.0-20151121023212-05317bfd7d39/kmgRpc/kmgRpcJava/java/src/com/google/gson/JsonDeserializationContext.java (about)

     1  /*
     2   * Copyright (C) 2008 Google Inc.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   * http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package com.google.gson;
    18  
    19  import java.lang.reflect.Type;
    20  
    21  /**
    22   * Context for deserialization that is passed to a custom deserializer during invocation of its
    23   * {@link JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext)}
    24   * method.
    25   *
    26   * @author Inderjeet Singh
    27   * @author Joel Leitch
    28   */
    29  public interface JsonDeserializationContext {
    30  
    31    /**
    32     * Invokes default deserialization on the specified object. It should never be invoked on
    33     * the element received as a parameter of the
    34     * {@link JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext)} method. Doing
    35     * so will result in an infinite loop since Gson will in-turn call the custom deserializer again.
    36     *
    37     * @param json the parse tree.
    38     * @param typeOfT type of the expected return value.
    39     * @param <T> The type of the deserialized object.
    40     * @return An object of type typeOfT.
    41     * @throws JsonParseException if the parse tree does not contain expected data.
    42     */
    43    public <T> T deserialize(JsonElement json, Type typeOfT) throws JsonParseException;
    44  }