Created
December 12, 2018 16:02
-
-
Save gberche-orange/58ef24889e96080a50dc325721bb7fa0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JsonDeserialize(builder = Catalog.CatalogBuilder.class) | |
abstract class CatalogMixIn{ | |
} | |
static class CatalogInstantiator extends ValueInstantiator.Base | |
{ | |
public CatalogInstantiator() { | |
super(Object.class); | |
} | |
@Override | |
public boolean canCreateUsingDelegate() { return false; } | |
@Override | |
public String getValueTypeDesc() { | |
return Catalog.CatalogBuilder.class.getName(); | |
} | |
@Override | |
public boolean canCreateUsingDefault() { return true; } | |
@Override | |
public Catalog.CatalogBuilder createUsingDefault(DeserializationContext ctxt) { | |
return Catalog.builder(); | |
} | |
} | |
static class ValueInstanciatorModule extends SimpleModule | |
{ | |
public ValueInstanciatorModule(Class<?> cls, ValueInstantiator inst) | |
{ | |
super("Test", Version.unknownVersion()); | |
this.addValueInstantiator(cls, inst); | |
} | |
} | |
@Autowired | |
public void configureJacksonBuilders(ObjectMapper jackson2ObjectMapper) { | |
jackson2ObjectMapper.addMixIn(Catalog.class, CatalogMixIn.class); | |
jackson2ObjectMapper.registerModule(new ValueInstanciatorModule(Catalog.CatalogBuilder.class, new CatalogInstantiator())); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment