Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.deser.std;
 
For com.fasterxml.jackson.core.JsonLocation, we should be able to just implement com.fasterxml.jackson.databind.deser.ValueInstantiator (not that explicit one would be very hard but...)
    public final static JsonLocationInstantiator instance = new JsonLocationInstantiator();
    
    @Override
    public String getValueTypeDesc() {
        return JsonLocation.class.getName();
    }
    
    @Override
    public boolean canCreateFromObjectWith() { return true; }
    
    @Override
        JavaType intType = config.constructType(.);
        JavaType longType = config.constructType(.);
        return  new CreatorProperty[] {
                creatorProp("sourceRef"config.constructType(Object.class), 0),
                creatorProp("byteOffset"longType, 1),
                creatorProp("charOffset"longType, 2),
                creatorProp("lineNr"intType, 3),
                creatorProp("columnNr"intType, 4)
        };
    }
    private static CreatorProperty creatorProp(String nameJavaType typeint index) {
        return new CreatorProperty(new PropertyName(name), typenull,
                nullnullnullindexnull.);
    }
    
    @Override
    public Object createFromObjectWith(DeserializationContext ctxtObject[] args) {
        return new JsonLocation(args[0], _long(args[1]), _long(args[2]),
                _int(args[3]), _int(args[4]));
    }
    private final static long _long(Object o) {
        return (o == null) ? 0L : ((Numbero).longValue();
    }
    private final static int _int(Object o) {
        return (o == null) ? 0 : ((Numbero).intValue();
    }
New to GrepCode? Check out our FAQ X