com.fasterxml.jackson.annotation.JsonRootName Java Examples
The following examples show how to use
com.fasterxml.jackson.annotation.JsonRootName.
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: ObjectMapperCreator.java From gwt-jackson with Apache License 2.0 | 6 votes |
/** * Build the constructor. * * @param mappedTypeClass the type to map * * @return the constructor method */ private MethodSpec buildConstructor( JClassType mappedTypeClass ) { Optional<JsonRootName> jsonRootName = findFirstEncounteredAnnotationsOnAllHierarchy( configuration, mappedTypeClass, JsonRootName.class ); String rootName; if ( !jsonRootName.isPresent() || Strings.isNullOrEmpty( jsonRootName.get().value() ) ) { rootName = mappedTypeClass.getSimpleSourceName(); } else { rootName = jsonRootName.get().value(); } return MethodSpec.constructorBuilder() .addModifiers( Modifier.PUBLIC ) .addStatement( "super($S)", rootName ) .build(); }
Example #2
Source File: Serialization.java From monasca-common with Apache License 2.0 | 4 votes |
private static String rootNameFor(Class<?> type) { JsonRootName rootName = type.getAnnotation(JsonRootName.class); return rootName == null ? type.getSimpleName() : rootName.value(); }