title: Pass a field to custom deserializer class Jackson
body: <p>I have written a custom deserializer to map only the required fields using jackson. Here goes.  </p>
  
  <pre><code>public class GeneralDeserializer extends JsonDeserializer&lt;GeneralDomain&gt; {
  
      @Override
      public GeneralDomain deserialize(JsonParser jp, DeserializationContext ctxt)
              throws IOException, JsonProcessingException {
  
          final JsonNode jsonNode = jp.getCodec().readTree(jp);
          final Map&lt;String, String&gt; map = new ObjectMapper().convertValue(jsonNode, Map.class);
          final String event = "Proxy";
          return new GeneralDomain(map.get("id"), event, map.get("name"), map.get("lastLogin"));
      }
  
      @Override
      public Class&lt;GeneralDomain&gt; handledType() {
          return GeneralDomain.class;
      }
  }
  </code></pre>
  
  <p>I have a mixin class too for this to add extra annotations. </p>
  
  <pre><code>@JsonDeserialize(using = GeneralDeserializer.class)
  public class GeneralDomainMixIn{}
  </code></pre>
  
  <p>I fetch the object in this way, </p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  mapper.addMixIn(GeneralDomain.class, SimpleRevealPublicEventMixIn.class);
  String json = "{\"id\": 111, \"name\": David, \"lastLogin\": \"02-10-2016 10:32:00 AM\"}";
  GeneralDomain readValue = mapper.readValue(json, GeneralDomain.class);
  </code></pre>
  
  <p>This works great. But as you can see in the custom deserializer, I am hard coding the event field value. This will be passed on by some other instance variable in the main class. I have to pass this field to the custom deserializer. So is there a way to access this variable inside the deserializer? Or is there any other alternative way to achieve this? Please help me out. Thanks.</p>