package com.fasterxml.jackson.databind.deser; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.deser.impl.ReadableObjectId; import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Method; public class SettableAnyProperty implements Serializable { private static final long serialVersionUID = 1; protected final BeanProperty _property; protected final transient Method _setter; protected final JavaType _type; protected JsonDeserializer<Object> _valueDeserializer; protected final TypeDeserializer _valueTypeDeserializer; @Deprecated public SettableAnyProperty(BeanProperty beanProperty, AnnotatedMethod annotatedMethod, JavaType javaType, JsonDeserializer<Object> jsonDeserializer) { this(beanProperty, annotatedMethod, javaType, jsonDeserializer, (TypeDeserializer) null); } public SettableAnyProperty(BeanProperty beanProperty, AnnotatedMethod annotatedMethod, JavaType javaType, JsonDeserializer<Object> jsonDeserializer, TypeDeserializer typeDeserializer) { this(beanProperty, annotatedMethod.getAnnotated(), javaType, jsonDeserializer, typeDeserializer); } @Deprecated public SettableAnyProperty(BeanProperty beanProperty, Method method, JavaType javaType, JsonDeserializer<Object> jsonDeserializer) { this(beanProperty, method, javaType, jsonDeserializer, (TypeDeserializer) null); } public SettableAnyProperty(BeanProperty beanProperty, Method method, JavaType javaType, JsonDeserializer<Object> jsonDeserializer, TypeDeserializer typeDeserializer) { this._property = beanProperty; this._type = javaType; this._setter = method; this._valueDeserializer = jsonDeserializer; this._valueTypeDeserializer = typeDeserializer; } public SettableAnyProperty withValueDeserializer(JsonDeserializer<Object> jsonDeserializer) { return new SettableAnyProperty(this._property, this._setter, this._type, jsonDeserializer, this._valueTypeDeserializer); } public BeanProperty getProperty() { return this._property; } public boolean hasValueDeserializer() { return this._valueDeserializer != null; } public JavaType getType() { return this._type; } public final void deserializeAndSet(JsonParser jsonParser, DeserializationContext deserializationContext, Object obj, String str) throws IOException { try { set(obj, str, deserialize(jsonParser, deserializationContext)); } catch (UnresolvedForwardReference e) { if (this._valueDeserializer.getObjectIdReader() != null) { e.getRoid().appendReferring(new AnySetterReferring(this, e, this._type.getRawClass(), obj, str)); return; } throw JsonMappingException.from(jsonParser, "Unresolved forward reference but no identity info.", e); } } public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) { return null; } TypeDeserializer typeDeserializer = this._valueTypeDeserializer; if (typeDeserializer != null) { return this._valueDeserializer.deserializeWithType(jsonParser, deserializationContext, typeDeserializer); } return this._valueDeserializer.deserialize(jsonParser, deserializationContext); } public void set(Object obj, String str, Object obj2) throws IOException { try { this._setter.invoke(obj, str, obj2); } catch (Exception e) { _throwAsIOE(e, str, obj2); } } /* access modifiers changed from: protected */ public void _throwAsIOE(Exception exc, String str, Object obj) throws IOException { String str2; if (exc instanceof IllegalArgumentException) { if (obj == null) { str2 = "[NULL]"; } else { str2 = obj.getClass().getName(); } StringBuilder sb = new StringBuilder("Problem deserializing \"any\" property '"); sb.append(str); sb.append("' of class " + getClassName() + " (expected type: "); sb.append(this._type); sb.append("; actual type: "); sb.append(str2); sb.append(")"); String message = exc.getMessage(); if (message != null) { sb.append(", problem: "); sb.append(message); } else { sb.append(" (no error message provided)"); } throw new JsonMappingException(sb.toString(), null, exc); } else if (!(exc instanceof IOException)) { boolean z = exc instanceof RuntimeException; Exception exc2 = exc; if (!z) { while (exc2.getCause() != null) { exc2 = exc2.getCause(); } throw new JsonMappingException(exc2.getMessage(), null, exc2); } throw ((RuntimeException) exc); } else { throw ((IOException) exc); } } private String getClassName() { return this._setter.getDeclaringClass().getName(); } public String toString() { return "[any property on class " + getClassName() + "]"; } /* access modifiers changed from: private */ public static class AnySetterReferring extends ReadableObjectId.Referring { private final SettableAnyProperty _parent; private final Object _pojo; private final String _propName; public AnySetterReferring(SettableAnyProperty settableAnyProperty, UnresolvedForwardReference unresolvedForwardReference, Class<?> cls, Object obj, String str) { super(unresolvedForwardReference, cls); this._parent = settableAnyProperty; this._pojo = obj; this._propName = str; } @Override // com.fasterxml.jackson.databind.deser.impl.ReadableObjectId.Referring public void handleResolvedForwardReference(Object obj, Object obj2) throws IOException { if (hasId(obj)) { this._parent.set(this._pojo, this._propName, obj2); return; } throw new IllegalArgumentException("Trying to resolve a forward reference with id [" + obj.toString() + "] that wasn't previously registered."); } } }