blob: c6b8d495f452c9d58019dbed366885cdc209e8b7 [file] [log] [blame]
Tatu Salorantae4f23bb2011-12-23 00:31:35 -08001package com.fasterxml.jackson.databind.jsontype.impl;
2
Tatu Saloranta1b253d32011-12-23 00:44:25 -08003import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
Tatu Salorantae4f23bb2011-12-23 00:31:35 -08004
5import com.fasterxml.jackson.databind.BeanProperty;
Tatu Salorantad92c1ed2011-12-23 18:23:31 -08006import com.fasterxml.jackson.databind.JavaType;
Tatu Saloranta49b71212012-01-30 22:13:21 -08007import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
Tatu Salorantae4f23bb2011-12-23 00:31:35 -08008import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
9
10/**
11 * Type deserializer used with {@link As#EXTERNAL_PROPERTY} inclusion mechanism.
12 * Actual implementation may look bit strange since it depends on comprehensive
13 * pre-processing done by {@link com.fasterxml.jackson.databind.deser.BeanDeserializer}
14 * to basically transform external type id into structure that looks more like
15 * "wrapper-array" style inclusion. This intermediate form is chosen to allow
16 * supporting all possible JSON structures.
Tatu Salorantae4f23bb2011-12-23 00:31:35 -080017 */
18public class AsExternalTypeDeserializer extends AsArrayTypeDeserializer
19{
Tatu Saloranta65d186e2012-10-05 23:51:38 -070020 private static final long serialVersionUID = 1L;
21
Tatu Saloranta596c6dd2016-03-20 18:24:04 -070022 /**
23 * @since 2.8
24 */
Tatu Saloranta49b71212012-01-30 22:13:21 -080025 public AsExternalTypeDeserializer(JavaType bt, TypeIdResolver idRes,
Tatu Saloranta596c6dd2016-03-20 18:24:04 -070026 String typePropertyName, boolean typeIdVisible, JavaType defaultImpl)
Tatu Salorantae4f23bb2011-12-23 00:31:35 -080027 {
Tatu Saloranta49b71212012-01-30 22:13:21 -080028 super(bt, idRes, typePropertyName, typeIdVisible, defaultImpl);
Tatu Salorantae4f23bb2011-12-23 00:31:35 -080029 }
30
Tatu Saloranta596c6dd2016-03-20 18:24:04 -070031 public AsExternalTypeDeserializer(AsExternalTypeDeserializer src,
32 BeanProperty property) {
Tatu Saloranta49b71212012-01-30 22:13:21 -080033 super(src, property);
34 }
35
36 @Override
Tatu Saloranta10af6d32013-12-31 22:27:57 -080037 public TypeDeserializer forProperty(BeanProperty prop) {
Tatu Saloranta49b71212012-01-30 22:13:21 -080038 if (prop == _property) { // usually if it's null
39 return this;
40 }
41 return new AsExternalTypeDeserializer(this, prop);
42 }
43
Tatu Salorantae4f23bb2011-12-23 00:31:35 -080044 @Override
Tatu Saloranta10af6d32013-12-31 22:27:57 -080045 public As getTypeInclusion() { return As.EXTERNAL_PROPERTY; }
Tatu Salorantaadd3cc32014-10-06 22:25:44 -070046
47 // yes, very important distinction...
48 @Override
49 protected boolean _usesExternalId() {
50 return true;
51 }
Tatu Salorantae4f23bb2011-12-23 00:31:35 -080052}