コード例 #1
0
 protected JsonSerializer<Object> getSer(BeanProperty prop) throws JsonMappingException {
   JsonSerializer<Object> ser = null;
   // 26-Jul-2013, tatu: This is ugly, should NOT require cast...
   if (prop instanceof BeanPropertyWriter) {
     ser = ((BeanPropertyWriter) prop).getSerializer();
   }
   if (ser == null) {
     ser = getProvider().findValueSerializer(prop.getType(), prop);
   }
   return ser;
 }
コード例 #2
0
 protected JsonSchema propertySchema(BeanProperty prop) throws JsonMappingException {
   if (prop == null) {
     throw new IllegalArgumentException("Null property");
   }
   SchemaFactoryWrapper visitor = wrapperFactory.getWrapper(getProvider());
   JsonSerializer<Object> ser = getSer(prop);
   if (ser != null) {
     JavaType type = prop.getType();
     if (type == null) {
       throw new IllegalStateException("Missing type for property '" + prop.getName() + "'");
     }
     ser.acceptJsonFormatVisitor(visitor, type);
   }
   return visitor.finalSchema();
 }
  @Override
  public Object findInjectableValue(
      Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) {
    // if a container, get content type

    JavaType type = forProperty.getType();
    if (type.isCollectionLikeType() | type.isArrayType()) {
      type = type.getContentType();
    }
    // checking annotation catches properties with interface types
    if (ObjBase.class.isAssignableFrom(type.getRawClass())
        || forProperty.getMember().getAnnotated().isAnnotationPresent(Reference.class)) {
      try {
        return super.findInjectableValue(valueId, ctxt, forProperty, beanInstance);
      } catch (IllegalArgumentException e) {
        Object value = getValue(valueId, type);
        return value;
      }

    } else {
      return super.findInjectableValue(valueId, ctxt, forProperty, beanInstance);
    }
  }