本文整理汇总了Java中com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationIntrospectorPair类的具体用法?Java AnnotationIntrospectorPair怎么用?Java AnnotationIntrospectorPair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationIntrospectorPair类属于com.fasterxml.jackson.databind.introspect包,在下文中一共展示了AnnotationIntrospectorPair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createObjectMapper
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
/**
* Create an <code>ObjectMapper</code> for Pipeline configuration.
*
* @param injector The Guice <code>Injector</code> instance.
* @return An <code>ObjectMapper</code> for Pipeline configuration.
*/
public static ObjectMapper createObjectMapper(final Injector injector) {
final ObjectMapper objectMapper = ObjectMapperFactory.createInstance();
final SimpleModule module = new SimpleModule("Pipeline");
module.addDeserializer(Statistic.class, new StatisticDeserializer());
objectMapper.registerModules(module);
final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
objectMapper.setInjectableValues(new GuiceInjectableValues(injector));
objectMapper.setAnnotationIntrospectors(
new AnnotationIntrospectorPair(
guiceIntrospector, objectMapper.getSerializationConfig().getAnnotationIntrospector()),
new AnnotationIntrospectorPair(
guiceIntrospector, objectMapper.getDeserializationConfig().getAnnotationIntrospector()));
return objectMapper;
}
示例2: createJsonFactory
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
private JsonFactory createJsonFactory() {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setAnnotationIntrospector(
new AnnotationIntrospectorPair(
new JacksonAnnotationIntrospector(),
new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())));
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, true);
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
objectMapper.setDateFormat(df);
return objectMapper.getFactory();
}
示例3: reportXml
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
public static void reportXml(Writer out, Report report) throws IOException {
XmlMapper mapper = new XmlMapper();
mapper.addMixIn(Report.class, ReportMixIn.class);
AnnotationIntrospector first = new SimpleTypesAsAttributesAnnotationIntrospector();
AnnotationIntrospector second = new JacksonXmlAnnotationIntrospector(false);
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(first, second));
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
mapper.writeValue(out, report);
}
示例4: init
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
@PostConstruct
public void init() {
objectMapper = new ObjectMapper()
.setAnnotationIntrospector(
new AnnotationIntrospectorPair(
new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())
, new JacksonAnnotationIntrospector()
)
)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
示例5: RowSerializer
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
public RowSerializer(){
mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(
new JacksonAnnotationIntrospector(),
new JaxbAnnotationIntrospector(mapper.getTypeFactory())
));
}
示例6: getJAXBandJacksonSerializer
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
public static RowSerializer getJAXBandJacksonSerializer(){
RowSerializer serializer = new RowSerializer();
serializer.mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(
new JacksonAnnotationIntrospector(),
new JaxbAnnotationIntrospector(serializer.mapper.getTypeFactory())
));
return serializer;
}
示例7: JacksonProvider
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
public JacksonProvider() {
AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
// if using BOTH JAXB annotations AND Jackson annotations:
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
ObjectMapper mapper = new ObjectMapper().registerModule(new Hibernate4Module())
.setSerializationInclusion(Include.NON_NULL)
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false).enable(SerializationFeature.INDENT_OUTPUT)
.setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary));
// mapper = mapper.setSerializationInclusion(Include)
setMapper(mapper);
}
示例8: ObjectMapperResolver
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
public ObjectMapperResolver() {
objectMapper = new ObjectMapper();
AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
objectMapper = objectMapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(introspector, secondary));
objectMapper = objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
objectMapper.registerModule(new Hibernate4Module());
}
示例9: createJaxbMapper
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
/**
* Creates a configured mapper supporting JAXB.
* @see #createObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)
*/
public static ObjectMapper createJaxbMapper() {
ObjectMapper om = createObjectMapper(createObjectMapper());
JaxbAnnotationIntrospector jaxbIntr = new JaxbAnnotationIntrospector(om.getTypeFactory());
JacksonAnnotationIntrospector jsonIntr = new JacksonAnnotationIntrospector();
om.setAnnotationIntrospector(new AnnotationIntrospectorPair(jsonIntr, jaxbIntr));
return om;
}
示例10: build
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
public JacksonSerializer build() {
final ObjectMapper objectMapper = mapperFromJSONFactory(jsonFactory);
if (usePropertyForTypeInformation) {
objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "@class");
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
} else {
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
}
if (usePrettyOutput) {
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
}
if (injectableValues != null) {
// this is from jackson-module-guice's ObjectMapperModule.get()
// we do this in a separate method because we do not currently want to inject the ObjectMapper
objectMapper.setInjectableValues(injectableValues);
objectMapper.setAnnotationIntrospectors(
new AnnotationIntrospectorPair(
annotationIntrospector,
objectMapper.getSerializationConfig().getAnnotationIntrospector()
),
new AnnotationIntrospectorPair(
annotationIntrospector,
objectMapper.getDeserializationConfig().getAnnotationIntrospector()
)
);
}
return new JacksonSerializer(objectMapper);
}
示例11: StreamClient
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
private StreamClient(final String endpoint, final String username, final String password,
final SSLConfiguration sslConfiguration, final Consumer<Event> consumer,
final Runnable beforeReconnection, final Runnable afterReconnection,
final boolean reconnect, final int reconnectAttempts,
final int pauseBeforeReconnectInSeconds)
{
this.endpoint = checkNotNull(endpoint, "endpoint cannot be null");
this.username = checkNotNull(username, "username cannot be null");
this.password = checkNotNull(password, "password cannot be null");
this.consumer = checkNotNull(consumer, "consumer cannot be null");
this.sslConfiguration = sslConfiguration;
this.reconnect = checkNotNull(reconnect);
if (this.reconnect)
{
this.reconnectAttempts = checkNotNull(reconnectAttempts,
"reconnect attempts cannot be null if reconnection has been enabled");
this.pauseBeforeReconnectInSeconds = checkNotNull(pauseBeforeReconnectInSeconds,
"pause seconds before reconnect cannot be null if reconnection has been enabled");
this.beforeReconnection = beforeReconnection;
this.afterReconnection = afterReconnection;
}
else
{
this.beforeReconnection = null;
this.afterReconnection = null;
}
json = new ObjectMapper()
.setAnnotationIntrospector( //
new AnnotationIntrospectorPair(new JacksonAnnotationIntrospector(),
new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()))) //
.registerModule(new AbiquoModule());
}
示例12: JacksonJsonMapper
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
public JacksonJsonMapper() {
mapper = new ObjectMapper();
// mapper.setSerializationInclusion(Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
AnnotationIntrospector pair = AnnotationIntrospectorPair.create(primary, secondary);
mapper.setAnnotationIntrospector(pair);
}
示例13: AtmospherePermissionCheckResource
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
public AtmospherePermissionCheckResource() {
om = new ObjectMapper();
// JAXB annotation
AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector();
om.setAnnotationIntrospector(new AnnotationIntrospectorPair(jaxbIntrospector, jacksonIntrospector));
}
示例14: AbstractWSResource
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
public AbstractWSResource() {
//api = Freedomotic.INJECTOR.getInstance(API.class);
om = new ObjectMapper();
// JAXB annotation
AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector();
om.setAnnotationIntrospector(new AnnotationIntrospectorPair(jaxbIntrospector, jacksonIntrospector));
}
示例15: setAnnotationIntrospectors
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; //导入依赖的package包/类
private void setAnnotationIntrospectors(ObjectMapper mapper) {
AnnotationIntrospector curSerIntro = mapper.getSerializationConfig().getAnnotationIntrospector();
AnnotationIntrospector newSerIntro = AnnotationIntrospectorPair.pair(curSerIntro,
new MaskableSensitiveDataAnnotationIntrospector());
mapper.setAnnotationIntrospector(newSerIntro);
}