Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.util;
  
Simple immutable com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition implementation that can be wrapped around a com.fasterxml.jackson.databind.introspect.AnnotatedMember that is a simple accessor (getter) or mutator (setter, constructor parameter) (or both, for fields).
 
     extends BeanPropertyDefinition
 {
 	protected final AnnotationIntrospector _introspector;

    
Member that defines logical property. Assumption is that it should be a 'simple' accessor; meaning a zero-argument getter, single-argument setter or constructor parameter.
 
     protected final AnnotatedMember _member;
 
     protected final String _name;
     
     /*
     /**********************************************************
     /* Construction
     /**********************************************************
      */

    
 
     @Deprecated
     public SimpleBeanPropertyDefinition(AnnotatedMember member) {
         this(membermember.getName(), null);
     }

    
 
     @Deprecated
     public SimpleBeanPropertyDefinition(AnnotatedMember memberString name) {
         this(membernamenull);
     }
     
     private SimpleBeanPropertyDefinition(AnnotatedMember memberString name,
     		AnnotationIntrospector intr) {
          = intr;
          = member;
          = name;
     }

    

Since:
2.2
 
     public static SimpleBeanPropertyDefinition construct(MapperConfig<?> config,
     		AnnotatedMember member) {
         return new SimpleBeanPropertyDefinition(membermember.getName(),
                 (config == null) ? null : config.getAnnotationIntrospector());
     }
    
    

Since:
2.2
 
     public static SimpleBeanPropertyDefinition construct(MapperConfig<?> config,
     		AnnotatedMember memberString name) {
         return new SimpleBeanPropertyDefinition(membername,
                 (config == null) ? null : config.getAnnotationIntrospector());
     }
     
     /*
     /**********************************************************
     /* Fluent factories
     /**********************************************************
      */
 
     @Deprecated // since 2.3
     @Override
     public SimpleBeanPropertyDefinition withName(String newName) {
         return withSimpleName(newName);
     }
 
     @Override
     public SimpleBeanPropertyDefinition withSimpleName(String newName) {
         if (.equals(newName)) {
             return this;
         }
         return new SimpleBeanPropertyDefinition(newName);
     }
 
     @Override
     public SimpleBeanPropertyDefinition withName(PropertyName newName) {
         return withSimpleName(newName.getSimpleName());
     }
    
    /*
    /**********************************************************
    /* Basic property information, name, type
    /**********************************************************
     */
    @Override
    public String getName() { return ; }
    @Override
    public PropertyName getFullName() { return new PropertyName(); }
    
    @Override
    public String getInternalName() { return getName(); }
    @Override
    public PropertyName getWrapperName() {
        return ( == null) ? null : .findWrapperName();
    }
    
    // hmmh. what should we claim here?
    @Override
    public boolean isExplicitlyIncluded() { return false; }

    
We will indicate that property is optional, since there is nothing to indicate whether it might be required.
    @Override
    public PropertyMetadata getMetadata() {
        return .;
    }
    
    /*
    /**********************************************************
    /* Access to accessors (fields, methods etc)
    /**********************************************************
     */
    @Override
    public boolean hasGetter() {
        return (getGetter() != null);
    }
    @Override
    public boolean hasSetter() {
        return (getSetter() != null);
    }
    @Override
    public boolean hasField() {
        return ( instanceof AnnotatedField);
    }
    @Override
    public boolean hasConstructorParameter() {
        return ( instanceof AnnotatedParameter);
    }
    
    @Override
    public AnnotatedMethod getGetter() {
        if (( instanceof AnnotatedMethod)
                && ((AnnotatedMethod).getParameterCount() == 0) {
            return (AnnotatedMethod;
        }
        return null;
    }
        
    @Override
    public AnnotatedMethod getSetter() {
        if (( instanceof AnnotatedMethod)
                && ((AnnotatedMethod).getParameterCount() == 1) {
            return (AnnotatedMethod;
        }
        return null;
    }
    @Override
    public AnnotatedField getField() {
        return ( instanceof AnnotatedField) ?
                (AnnotatedField : null;
    }
    @Override
        return ( instanceof AnnotatedParameter) ?
                (AnnotatedParameter : null;
    }

    
Method used to find accessor (getter, field to access) to use for accessing value of the property. Null if no such member exists.
    @Override
    public AnnotatedMember getAccessor() {
        AnnotatedMember acc = getGetter();
        if (acc == null) {
            acc = getField();
        }
        return acc;
    }

    
Method used to find mutator (constructor parameter, setter, field) to use for changing value of the property. Null if no such member exists.
    @Override
    public AnnotatedMember getMutator() {
        AnnotatedMember acc = getConstructorParameter();
        if (acc == null) {
            acc = getSetter();
            if (acc == null) {
                acc = getField();
            }
        }
        return acc;
    }
    @Override
        AnnotatedMember acc = getSetter();
        if (acc == null) {
            acc = getField();
        }
        return acc;
    }
    @Override
    public AnnotatedMember getPrimaryMember() {
        return ;
    }
New to GrepCode? Check out our FAQ X