package com.github.arteam.simplejsonrpc.core.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ValueNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;


/**
 * Date: 07.06.14
 * Time: 12:24
 * <p>Representation of a JSON-RPC request</p>
 */
public class Request {

    @Nullable
    private final String jsonrpc;

    @Nullable
    private final String method;

    @NotNull
    private final JsonNode params;

    @NotNull
    private final ValueNode id;

    public Request(@JsonProperty("jsonrpc") @Nullable String jsonrpc,
                   @JsonProperty("method") @Nullable String method,
                   @JsonProperty("params") @NotNull JsonNode params,
                   @JsonProperty("id") @NotNull ValueNode id) {
        this.jsonrpc = jsonrpc;
        this.method = method;
        this.id = id;
        this.params = params;
    }

    @Nullable
    public String getJsonrpc() {
        return jsonrpc;
    }

    @Nullable
    public String getMethod() {
        return method;
    }

    @NotNull
    public ValueNode getId() {
        return id;
    }

    @NotNull
    public JsonNode getParams() {
        return params;
    }

    @Override
    public String toString() {
        return "Request{jsonrpc=" + jsonrpc + ", method=" + method + ", id=" + id + ", params=" + params + "}";
    }
}

@@ -145,24 +145,77 @@
 d.JsonNode;%0A
+import com.fasterxml.jackson.databind.node.NullNode;%0A
 import com.f
@@ -252,24 +252,24 @@
 .ValueNode;%0A
-
 import org.j
@@ -599,38 +599,39 @@
  params;%0A%0A    @N
-otN
 ull
+able
 %0A    private fin
@@ -896,22 +896,23 @@
 %22id%22) @N
-otN
 ull
+able
  ValueNo
@@ -1235,24 +1235,24 @@
 e getId() %7B%0A
-
         retu
@@ -1256,16 +1256,54 @@
 eturn id
+ != null ? id : NullNode.getInstance()
 ;%0A    %7D%0A

Check that request id can be null