Java Code Examples for com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping#NON_FINAL
The following examples show how to use
com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping#NON_FINAL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonJacksonCodec.java From redisson with Apache License 2.0 | 5 votes |
protected void initTypeInclusion(ObjectMapper mapObjectMapper) { TypeResolverBuilder<?> mapTyper = new DefaultTypeResolverBuilder(DefaultTyping.NON_FINAL) { public boolean useForType(JavaType t) { switch (_appliesFor) { case NON_CONCRETE_AND_ARRAYS: while (t.isArrayType()) { t = t.getContentType(); } // fall through case OBJECT_AND_NON_CONCRETE: return (t.getRawClass() == Object.class) || !t.isConcrete(); case NON_FINAL: while (t.isArrayType()) { t = t.getContentType(); } // to fix problem with wrong long to int conversion if (t.getRawClass() == Long.class) { return true; } if (t.getRawClass() == XMLGregorianCalendar.class) { return false; } return !t.isFinal(); // includes Object.class default: // case JAVA_LANG_OBJECT: return t.getRawClass() == Object.class; } } }; mapTyper.init(JsonTypeInfo.Id.CLASS, null); mapTyper.inclusion(JsonTypeInfo.As.PROPERTY); mapObjectMapper.setDefaultTyping(mapTyper); }
Example 2
Source File: ClassAliasTypeResolverBuilderTest.java From simple-spring-memcached with MIT License | 4 votes |
@Before public void setUp() { builder = new ClassAliasTypeResolverBuilder(DefaultTyping.NON_FINAL); }