Class MessageTypeAdapter

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected Message createMessage​(java.lang.String jsonrpc, Either<java.lang.String,​java.lang.Number> id, java.lang.String method, java.lang.Object params, java.lang.Object responseResult, ResponseError responseError)  
      protected java.lang.Object fromJson​(com.google.gson.JsonElement element, java.lang.reflect.Type type)  
      protected java.lang.Object fromJson​(com.google.gson.stream.JsonReader in, java.lang.reflect.Type type)  
      protected java.lang.reflect.Type[] getParameterTypes​(java.lang.String method)  
      protected void handleParameter​(com.google.gson.stream.JsonWriter out, java.lang.Object params, java.lang.String method)  
      protected boolean isNull​(java.lang.Object value)  
      protected boolean isNullOrVoidType​(java.lang.reflect.Type type)  
      protected java.lang.Object parseParams​(com.google.gson.stream.JsonReader in, java.lang.String method)
      Convert the json input into the parameters object corresponding to the call made by method.
      protected java.lang.Object parseParams​(java.lang.Object params, java.lang.String method)
      Convert the JsonElement into the parameters object corresponding to the call made by method.
      protected java.lang.Object parseResult​(com.google.gson.stream.JsonReader in, java.lang.String id)
      Convert the json input into the result object corresponding to the call made by id.
      protected java.lang.Object parseResult​(java.lang.Object result, java.lang.String id)
      Convert the JsonElement into the result object corresponding to the call made by id.
      Message read​(com.google.gson.stream.JsonReader in)  
      void write​(com.google.gson.stream.JsonWriter out, Message message)  
      protected void writeId​(com.google.gson.stream.JsonWriter out, Either<java.lang.String,​java.lang.Number> id)  
      protected void writeNullValue​(com.google.gson.stream.JsonWriter out)
      Use this method to write a null value even if the JSON writer is set to not serialize null.
      • Methods inherited from class com.google.gson.TypeAdapter

        fromJson, fromJson, fromJsonTree, nullSafe, toJson, toJson, toJsonTree
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MessageTypeAdapter

        public MessageTypeAdapter​(MessageJsonHandler handler,
                                  com.google.gson.Gson gson)
    • Method Detail

      • read

        public Message read​(com.google.gson.stream.JsonReader in)
                     throws java.io.IOException,
                            com.google.gson.JsonIOException,
                            com.google.gson.JsonSyntaxException
        Specified by:
        read in class com.google.gson.TypeAdapter<Message>
        Throws:
        java.io.IOException
        com.google.gson.JsonIOException
        com.google.gson.JsonSyntaxException
      • parseResult

        protected java.lang.Object parseResult​(com.google.gson.stream.JsonReader in,
                                               java.lang.String id)
                                        throws com.google.gson.JsonIOException,
                                               com.google.gson.JsonSyntaxException
        Convert the json input into the result object corresponding to the call made by id. If the id is not known until after parsing, call parseResult(Object, String) on the return value of this call for a second chance conversion.
        Parameters:
        in - json input to read from
        id - id of request message this is in response to
        Returns:
        correctly typed object if the correct expected type can be determined, or a JsonElement representing the result
        Throws:
        com.google.gson.JsonIOException
        com.google.gson.JsonSyntaxException
      • parseResult

        protected java.lang.Object parseResult​(java.lang.Object result,
                                               java.lang.String id)
                                        throws com.google.gson.JsonSyntaxException
        Convert the JsonElement into the result object corresponding to the call made by id. If the result is already converted, does nothing.
        Parameters:
        result - json element to read from
        id - id of request message this is in response to
        Returns:
        correctly typed object if the correct expected type can be determined, or result unmodified if no conversion can be done.
        Throws:
        com.google.gson.JsonSyntaxException
      • parseParams

        protected java.lang.Object parseParams​(com.google.gson.stream.JsonReader in,
                                               java.lang.String method)
                                        throws java.io.IOException,
                                               com.google.gson.JsonIOException
        Convert the json input into the parameters object corresponding to the call made by method. If the method is not known until after parsing, call parseParams(Object, String) on the return value of this call for a second chance conversion.
        Parameters:
        in - json input to read from
        method - method name of request
        Returns:
        correctly typed object if the correct expected type can be determined, or a JsonElement representing the parameters
        Throws:
        java.io.IOException
        com.google.gson.JsonIOException
      • parseParams

        protected java.lang.Object parseParams​(java.lang.Object params,
                                               java.lang.String method)
        Convert the JsonElement into the parameters object corresponding to the call made by method. If the result is already converted, does nothing.
        Parameters:
        params - json element to read from
        method - method name of request
        Returns:
        correctly typed object if the correct expected type can be determined, or params unmodified if no conversion can be done.
      • fromJson

        protected java.lang.Object fromJson​(com.google.gson.stream.JsonReader in,
                                            java.lang.reflect.Type type)
                                     throws com.google.gson.JsonIOException
        Throws:
        com.google.gson.JsonIOException
      • fromJson

        protected java.lang.Object fromJson​(com.google.gson.JsonElement element,
                                            java.lang.reflect.Type type)
      • isNull

        protected boolean isNull​(java.lang.Object value)
      • isNullOrVoidType

        protected boolean isNullOrVoidType​(java.lang.reflect.Type type)
      • getParameterTypes

        protected java.lang.reflect.Type[] getParameterTypes​(java.lang.String method)
      • createMessage

        protected Message createMessage​(java.lang.String jsonrpc,
                                        Either<java.lang.String,​java.lang.Number> id,
                                        java.lang.String method,
                                        java.lang.Object params,
                                        java.lang.Object responseResult,
                                        ResponseError responseError)
                                 throws com.google.gson.JsonParseException
        Throws:
        com.google.gson.JsonParseException
      • write

        public void write​(com.google.gson.stream.JsonWriter out,
                          Message message)
                   throws java.io.IOException
        Specified by:
        write in class com.google.gson.TypeAdapter<Message>
        Throws:
        java.io.IOException
      • handleParameter

        protected void handleParameter​(com.google.gson.stream.JsonWriter out,
                                       java.lang.Object params,
                                       java.lang.String method)
      • writeId

        protected void writeId​(com.google.gson.stream.JsonWriter out,
                               Either<java.lang.String,​java.lang.Number> id)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeNullValue

        protected void writeNullValue​(com.google.gson.stream.JsonWriter out)
                               throws java.io.IOException
        Use this method to write a null value even if the JSON writer is set to not serialize null.
        Throws:
        java.io.IOException