Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.deser;
  
  
  
This concrete sub-class implements property that is passed via Creator (constructor or static factory method). It is not a full-featured implementation in that its set method should never be called -- instead, value must separately passed.

Note on injectable values: unlike with other mutators, where deserializer and injecting are separate, here we deal the two as related things. This is necessary to add proper priority, as well as to simplify coordination.

 
 public class CreatorProperty
     extends SettableBeanProperty
 {
     private static final long serialVersionUID = 1L;

    
Placeholder that represents constructor parameter, when it is created from actual constructor. May be null when a synthetic instance is created.
 
     protected final AnnotatedParameter _annotated;

    
Id of value to inject, if value injection should be used for this parameter (in addition to, or instead of, regular deserialization).
 
     protected final Object _injectableValueId;

    

Since:
2.1
 
     protected final int _creatorIndex;
    
    

Parameters:
name Name of the logical property
type Type of the property, used to find deserializer
typeDeser Type deserializer to use for handling polymorphic type information, if one is needed
contextAnnotations Contextual annotations (usually by class that declares creator [constructor, factory method] that includes this property)
param Representation of property, constructor or factory method parameter; used for accessing annotations of the property
index Index of this property within creator invocatino
 
     public CreatorProperty(String nameJavaType typeTypeDeserializer typeDeser,
             Annotations contextAnnotationsAnnotatedParameter param,
             int indexObject injectableValueId)
     {
         super(nametypetypeDesercontextAnnotations);
          = param;
          = index;
          = injectableValueId;
     }
 
     protected CreatorProperty(CreatorProperty srcString newName) {
         super(srcnewName);
          = src._annotated;
          = src._creatorIndex;
          = src._injectableValueId;
     }
     
     protected CreatorProperty(CreatorProperty srcJsonDeserializer<?> deser) {
         super(srcdeser);
          = src._annotated;
          = src._creatorIndex;
          = src._injectableValueId;
     }
 
     @Override
     public CreatorProperty withName(String newName) {
         return new CreatorProperty(thisnewName);
     }
     
     @Override
         return new CreatorProperty(thisdeser);
     }

    
Method that can be called to locate value to be injected for this property, if it is configured for this.
    public Object findInjectableValue(DeserializationContext contextObject beanInstance)
    {
        if ( == null) {
            throw new IllegalStateException("Property '"+getName()
                    +"' (type "+getClass().getName()+") has no injectable value id configured");
        }
        return context.findInjectableValue(thisbeanInstance);
    }
    
    
Method to find value to inject, and inject it to this property.
    public void inject(DeserializationContext contextObject beanInstance)
        throws IOException
    {
        set(beanInstancefindInjectableValue(contextbeanInstance));
    }
    
    /*
    /**********************************************************
    /* BeanProperty impl
    /**********************************************************
     */
    
    @Override
    public <A extends Annotation> A getAnnotation(Class<A> acls) {
        if ( == null) {
            return null;
        }
        return .getAnnotation(acls);
    }
    @Override public AnnotatedMember getMember() {  return ; }
    @Override public int getCreatorIndex() {
        return ;
    }
    
    /*
    /**********************************************************
    /* Overridden methods
    /**********************************************************
     */
    @Override
    public void deserializeAndSet(JsonParser jpDeserializationContext ctxt,
                                  Object instance)
        throws IOExceptionJsonProcessingException
    {
        set(instancedeserialize(jpctxt));
    }
    @Override
    		DeserializationContext ctxtObject instance)
        throws IOExceptionJsonProcessingException
    {
        return setAndReturn(instancedeserialize(jpctxt));
    }
    
    @Override
    public void set(Object instanceObject valuethrows IOException
    {
        /* Hmmmh. Should we return quietly (NOP), or error?
         * Perhaps better to throw an exception, since it's generally an error.
         */
        throw new IllegalStateException("Method should never be called on a "+getClass().getName());
    }
    @Override
    public Object setAndReturn(Object instanceObject valuethrows IOException
    {
        return instance;
    }
    
    @Override
    public Object getInjectableValueId() {
        return ;
    }
    @Override
    public String toString() { return "[creator property, name '"+getName()+"'; inject id '"++"']"; }
New to GrepCode? Check out our FAQ X