当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationIntrospector.Pair方法代码示例

本文整理汇总了Java中org.codehaus.jackson.map.AnnotationIntrospector.Pair方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationIntrospector.Pair方法的具体用法?Java AnnotationIntrospector.Pair怎么用?Java AnnotationIntrospector.Pair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.jackson.map.AnnotationIntrospector的用法示例。


在下文中一共展示了AnnotationIntrospector.Pair方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
public static void main(String[] args) throws JsonMappingException {
	ObjectMapper jsonMapper = new ObjectMapper();
    AnnotationIntrospector introspector = new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(), 
    		new JacksonAnnotationIntrospector());
    jsonMapper.setAnnotationIntrospector(introspector);
    JsonSchema schema = jsonMapper.generateJsonSchema(Testi.class);
    if(Testi.class.getAnnotation(XmlRootElement.class)!=null
    		&& !Testi.class.getAnnotation(XmlRootElement.class).name().equals("##default"))
    	schema.getSchemaNode().put("name", Testi.class.getAnnotation(XmlRootElement.class).name());
    else if(Testi.class.getAnnotation(XmlType.class)!=null
    		&& !Testi.class.getAnnotation(XmlType.class).name().equals("##default"))
    	schema.getSchemaNode().put("name", Testi.class.getAnnotation(XmlType.class).name());
    else
    	schema.getSchemaNode().put("name", Testi.class.getSimpleName());
    String schemaJson = schema.toString();
	System.out.println(schemaJson);
}
 
开发者ID:sumeetchhetri,项目名称:test-html-generator-plugin,代码行数:18,代码来源:Testi.java

示例2: getObjectMapper

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
@Bean(name="defaultObjectMapper")
public ObjectMapper getObjectMapper() {
    if(defaultObjectMapper==null) {
        ObjectMapper mapper = new ObjectMapper();
        AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
        AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
        AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
        mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
        mapper.getDeserializationConfig().set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.getSerializationConfig().setAnnotationIntrospector(pair);
        mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
        mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
        mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
        this.defaultObjectMapper = mapper;
    }
    return defaultObjectMapper;
}
 
开发者ID:parekhparth,项目名称:SimpleJavaWS,代码行数:18,代码来源:ServiceConfiguration.java

示例3: updateGenerator

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
/**
 * Update the generator with a default codec and pretty printer
 *
 * @param jsonFactory   Factory to set as codec
 * @param jsonGenerator Generator to configure
 */
private static void updateGenerator(JsonFactory jsonFactory, JsonGenerator jsonGenerator) {
    ObjectMapper mapper = new ObjectMapper(jsonFactory);

    //Update the annotation interceptor to also include jaxb annotations as a second choice
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector() {

        /**
         * BUG FIX:
         * By contract, if findSerializationInclusion didn't encounter any annotations that should change the
         * inclusion value, it should return the default value it has received; but actually returns null, which
         * overrides the NON_NULL option we set.
         * The doc states issue JACKSON-256 which was supposed to be fixed in 1.5.0. *twilight zone theme song*
         */

        @Override
        public JsonSerialize.Inclusion findSerializationInclusion(Annotated a, JsonSerialize.Inclusion defValue) {
            JsonSerialize.Inclusion inclusion = super.findSerializationInclusion(a, defValue);
            if (inclusion == null) {
                return defValue;
            }
            return inclusion;
        }
    };
    AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);
    mapper.getSerializationConfig().setAnnotationIntrospector(pair);
    mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);

    jsonGenerator.setCodec(mapper);
    jsonGenerator.useDefaultPrettyPrinter();
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:38,代码来源:JacksonFactory.java

示例4: updateParser

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
/**
 * Update the parser with a default codec
 *
 * @param jsonFactory Factory to set as codec
 * @param jsonParser  Parser to configure
 */
private static void updateParser(JsonFactory jsonFactory, JsonParser jsonParser) {
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
    AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);

    ObjectMapper mapper = new ObjectMapper(jsonFactory);
    mapper.getSerializationConfig().setAnnotationIntrospector(pair);
    mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
    mapper.getDeserializationConfig().disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
    jsonParser.setCodec(mapper);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:18,代码来源:JacksonFactory.java

示例5: JsonProvider

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
public JsonProvider() {
    ObjectMapper mapper = getMapper();
    //Update the annotation interceptor to also include jaxb annotations as a second choice
    AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
    AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);

    mapper.getSerializationConfig().setAnnotationIntrospector(pair);
    mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);

    mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
    //Ignore missing properties
    mapper.getDeserializationConfig().disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:15,代码来源:JsonProvider.java

示例6: JacksonJaxbContextResolver

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
public JacksonJaxbContextResolver() {
    this.objectMapper = new ObjectMapper();
    final AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
    final AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
    final AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);

    this.objectMapper.getDeserializationConfig().setAnnotationIntrospector(pair);
    this.objectMapper.getSerializationConfig().setAnnotationIntrospector(pair);
}
 
开发者ID:a-jullien,项目名称:cirrus,代码行数:10,代码来源:JacksonJaxbContextResolver.java

示例7: ObjectMapperFactoryBean

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
public ObjectMapperFactoryBean() {
	this.objectMapper = new ObjectMapper();
	this.objectMapper.setSerializationInclusion(Inclusion.NON_NULL);
	this.objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);

	AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
	AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
	AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary, secondary);

	this.objectMapper.setAnnotationIntrospector(pair);
}
 
开发者ID:doanduyhai,项目名称:Cassandra-rate-limiting-demo,代码行数:12,代码来源:ObjectMapperFactoryBean.java

示例8: locateMapper

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
@Override
public ObjectMapper locateMapper(Class<?> type, MediaType mediaType) {
  ObjectMapper mapper = super.locateMapper(type, mediaType);
  AnnotationIntrospector introspector = new AnnotationIntrospector.Pair(
      new JaxbAnnotationIntrospector(),
      new JacksonAnnotationIntrospector()
  );
  mapper.setAnnotationIntrospector(introspector);
  //mapper.setSerializationInclusion(Inclusion.NON_NULL);
  return mapper;
}
 
开发者ID:apache,项目名称:incubator-slider,代码行数:12,代码来源:SliderJacksonJaxbJsonProvider.java

示例9: createJsonMapper

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
/**
 * Creates json mapper.
 *
 * @return json mapper
 */
public static ObjectMapper createJsonMapper() {
    final AnnotationIntrospector jaxb = new JaxbAnnotationIntrospector();
    final AnnotationIntrospector jackson = new JacksonAnnotationIntrospector();

    final AnnotationIntrospector pair = new AnnotationIntrospector.Pair(jackson, jaxb);

    final ObjectMapper mapper = new ObjectMapper();
    mapper.getDeserializationConfig().withAnnotationIntrospector(pair);
    mapper.getSerializationConfig().withAnnotationIntrospector(pair);
    return mapper;
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:17,代码来源:Util.java

示例10: createJsonMapper

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
public static ObjectMapper createJsonMapper() {
    final AnnotationIntrospector jaxb = new JaxbAnnotationIntrospector();
    final AnnotationIntrospector jackson = new JacksonAnnotationIntrospector();

    final AnnotationIntrospector pair = new AnnotationIntrospector.Pair(jackson, jaxb);

    final ObjectMapper mapper = new ObjectMapper();
    mapper.getDeserializationConfig().withAnnotationIntrospector(pair);
    mapper.getSerializationConfig().withAnnotationIntrospector(pair);
    return mapper;
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:12,代码来源:ServerUtil.java

示例11: createJaxbJacksonAnnotationIntrospector

import org.codehaus.jackson.map.AnnotationIntrospector; //导入方法依赖的package包/类
private static Pair createJaxbJacksonAnnotationIntrospector() {

        AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector();
        AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector();

        return new AnnotationIntrospector.Pair(jacksonIntrospector, jaxbIntrospector);
    }
 
开发者ID:ShoppinPal,项目名称:cloud-pos-router,代码行数:8,代码来源:ConfigureJackson.java


注:本文中的org.codehaus.jackson.map.AnnotationIntrospector.Pair方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。