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


Java JsonPropertyOrder类代码示例

本文整理汇总了Java中com.fasterxml.jackson.annotation.JsonPropertyOrder的典型用法代码示例。如果您正苦于以下问题:Java JsonPropertyOrder类的具体用法?Java JsonPropertyOrder怎么用?Java JsonPropertyOrder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: annotationStyleGsonProducesGsonAnnotations

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void annotationStyleGsonProducesGsonAnnotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException, NoSuchFieldException {

    Class generatedType = schemaRule.generateAndCompile("/json/examples/torrent.json", "com.example",
            config("annotationStyle", "gson",
                    "propertyWordDelimiters", "_",
                    "sourceType", "json"))
            .loadClass("com.example.Torrent");

    assertThat(schemaRule.getGenerateDir(), not(containsText("org.codehaus.jackson")));
    assertThat(schemaRule.getGenerateDir(), not(containsText("com.fasterxml.jackson")));
    assertThat(schemaRule.getGenerateDir(), containsText("com.google.gson"));
    assertThat(schemaRule.getGenerateDir(), containsText("@SerializedName"));

    Method getter = generatedType.getMethod("getBuild");

    assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(nullValue()));
    assertThat(generatedType.getAnnotation(JsonInclude.class), is(nullValue()));
    assertThat(getter.getAnnotation(JsonProperty.class), is(nullValue()));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:GsonIT.java

示例2: annotationStyleMoshi1ProducesMoshi1Annotations

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void annotationStyleMoshi1ProducesMoshi1Annotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException, NoSuchFieldException {

    Class generatedType = schemaRule.generateAndCompile("/json/examples/torrent.json", "com.example",
            config("annotationStyle", "moshi1",
                    "propertyWordDelimiters", "_",
                    "sourceType", "json"))
            .loadClass("com.example.Torrent");

    assertThat(schemaRule.getGenerateDir(), not(containsText("org.codehaus.jackson")));
    assertThat(schemaRule.getGenerateDir(), not(containsText("com.fasterxml.jackson")));
    assertThat(schemaRule.getGenerateDir(), not(containsText("com.google.gson")));
    assertThat(schemaRule.getGenerateDir(), not(containsText("@SerializedName")));
    assertThat(schemaRule.getGenerateDir(), containsText("com.squareup.moshi"));
    assertThat(schemaRule.getGenerateDir(), containsText("@Json"));

    Method getter = generatedType.getMethod("getBuild");

    assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(nullValue()));
    assertThat(generatedType.getAnnotation(JsonInclude.class), is(nullValue()));
    assertThat(getter.getAnnotation(JsonProperty.class), is(nullValue()));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:Moshi1IT.java

示例3: annotationStyleJackson2ProducesJackson2Annotations

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void annotationStyleJackson2ProducesJackson2Annotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    Class generatedType = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example",
            config("annotationStyle", "jackson2"))
            .loadClass("com.example.PrimitiveProperties");

    assertThat(schemaRule.getGenerateDir(), not(containsText("org.codehaus.jackson")));
    assertThat(schemaRule.getGenerateDir(), containsText("com.fasterxml.jackson"));

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(JsonInclude.class), is(notNullValue()));
    assertThat(getter.getAnnotation(JsonProperty.class), is(notNullValue()));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:AnnotationStyleIT.java

示例4: annotationStyleJackson1ProducesJackson1Annotations

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void annotationStyleJackson1ProducesJackson1Annotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    Class generatedType = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example",
            config("annotationStyle", "jackson1"))
            .loadClass("com.example.PrimitiveProperties");

    assertThat(schemaRule.getGenerateDir(), not(containsText("com.fasterxml.jackson")));
    assertThat(schemaRule.getGenerateDir(), containsText("org.codehaus.jackson"));

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(org.codehaus.jackson.annotate.JsonPropertyOrder.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(org.codehaus.jackson.map.annotate.JsonSerialize.class), is(notNullValue()));
    assertThat(getter.getAnnotation(org.codehaus.jackson.annotate.JsonProperty.class), is(notNullValue()));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:AnnotationStyleIT.java

示例5: customAnnotatorCanBeAppliedAlongsideCoreAnnotator

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void customAnnotatorCanBeAppliedAlongsideCoreAnnotator() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example",
            config("customAnnotator", DeprecatingAnnotator.class.getName()));

    Class generatedType = resultsClassLoader.loadClass("com.example.PrimitiveProperties");

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(JsonInclude.class), is(notNullValue()));
    assertThat(getter.getAnnotation(JsonProperty.class), is(notNullValue()));

    assertThat(generatedType.getAnnotation(Deprecated.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(Deprecated.class), is(notNullValue()));
    assertThat(getter.getAnnotation(Deprecated.class), is(notNullValue()));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:CustomAnnotatorIT.java

示例6: build

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
public ResourceInformation build(Class<?> resourceClass, boolean allowNonResourceBaseClass) {
	List<ResourceField> resourceFields = getResourceFields(resourceClass);

	String resourceType = getResourceType(resourceClass, allowNonResourceBaseClass);

	Optional<JsonPropertyOrder> propertyOrder = ClassUtils.getAnnotation(resourceClass, JsonPropertyOrder.class);
	if (propertyOrder.isPresent()) {
		JsonPropertyOrder propertyOrderAnnotation = propertyOrder.get();
		Collections.sort(resourceFields, new FieldOrderedComparator(propertyOrderAnnotation.value(), propertyOrderAnnotation.alphabetic()));
	}

	DefaultResourceInstanceBuilder<?> instanceBuilder = new DefaultResourceInstanceBuilder(resourceClass);

	Class<?> superclass = resourceClass.getSuperclass();
	String superResourceType = superclass != Object.class && context.accept(superclass) ? context.getResourceType(superclass) : null;

	ResourceInformation information = new ResourceInformation(context.getTypeParser(), resourceClass, resourceType, superResourceType, instanceBuilder,

			resourceFields);
	if (!allowNonResourceBaseClass && information.getIdField() == null) {
		throw new ResourceIdNotFoundException(resourceClass.getCanonicalName());
	}
	return information;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:25,代码来源:DefaultResourceInformationProvider.java

示例7: orderedFields

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
protected List<Element> orderedFields() {
    TypeElement typeElement = (TypeElement) typeUtils.asElement(beanType);

    final List<Element> orderedProperties = new ArrayList<>();

    final List<Element> fields = typeElement.getEnclosedElements().stream().filter(e -> ElementKind.FIELD
            .equals(e.getKind()) && !e.getModifiers()
            .contains(Modifier.STATIC)).collect(Collectors.toList());

    Optional.ofNullable(typeUtils.asElement(beanType).getAnnotation(JsonPropertyOrder.class))
            .ifPresent(jsonPropertyOrder -> {
                final List<String> orderedFieldsNames = Arrays.asList(jsonPropertyOrder.value());
                orderedProperties.addAll(fields.stream()
                        .filter(f -> orderedFieldsNames.contains(f.getSimpleName().toString()))
                        .collect(Collectors.toList()));

                fields.removeAll(orderedProperties);
                if (jsonPropertyOrder.alphabetic()) {
                    fields.sort(Comparator.comparing(f -> f.getSimpleName().toString()));
                }

                fields.addAll(0, orderedProperties);
            });

    return fields;
}
 
开发者ID:vegegoku,项目名称:gwt-jackson-apt,代码行数:27,代码来源:AbstractJsonMapperGenerator.java

示例8: build

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public ResourceInformation build(Class<?> resourceClass) {
	List<AnnotatedResourceField> resourceFields = getResourceFields(resourceClass);

	String resourceType = getResourceType(resourceClass);

	Optional<JsonPropertyOrder> propertyOrder = ClassUtils.getAnnotation(resourceClass, JsonPropertyOrder.class);
	if (propertyOrder.isPresent()) {
		JsonPropertyOrder propertyOrderAnnotation = propertyOrder.get();
		Collections.sort(resourceFields, new FieldOrderedComparator(propertyOrderAnnotation.value(), propertyOrderAnnotation.alphabetic()));
	}

	DefaultResourceInstanceBuilder<?> instanceBuilder = new DefaultResourceInstanceBuilder(resourceClass);

	Class<?> superclass = resourceClass.getSuperclass();
	String superResourceType = superclass != Object.class && context.accept(superclass) ? context.getResourceType(superclass) : null;
	
	return new ResourceInformation(context.getTypeParser(), resourceClass, resourceType, superResourceType, instanceBuilder, (List) resourceFields);
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:20,代码来源:AnnotationResourceInformationBuilder.java

示例9: annotationStyleJackson2ProducesJackson2Annotations

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void annotationStyleJackson2ProducesJackson2Annotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    File generatedOutputDirectory = generate("/schema/properties/primitiveProperties.json", "com.example",
            config("annotationStyle", "jackson2"));

    assertThat(generatedOutputDirectory, not(containsText("org.codehaus.jackson")));
    assertThat(generatedOutputDirectory, containsText("com.fasterxml.jackson"));

    ClassLoader resultsClassLoader = compile(generatedOutputDirectory);

    Class generatedType = resultsClassLoader.loadClass("com.example.PrimitiveProperties");

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(JsonInclude.class), is(notNullValue()));
    assertThat(getter.getAnnotation(JsonProperty.class), is(notNullValue()));
}
 
开发者ID:fge,项目名称:jsonschema2pojo,代码行数:21,代码来源:AnnotationStyleIT.java

示例10: annotationStyleJackson1ProducesJackson1Annotations

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void annotationStyleJackson1ProducesJackson1Annotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    File generatedOutputDirectory = generate("/schema/properties/primitiveProperties.json", "com.example",
            config("annotationStyle", "jackson1"));

    assertThat(generatedOutputDirectory, not(containsText("com.fasterxml.jackson")));
    assertThat(generatedOutputDirectory, containsText("org.codehaus.jackson"));

    ClassLoader resultsClassLoader = compile(generatedOutputDirectory);

    Class generatedType = resultsClassLoader.loadClass("com.example.PrimitiveProperties");

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(org.codehaus.jackson.annotate.JsonPropertyOrder.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(org.codehaus.jackson.map.annotate.JsonSerialize.class), is(notNullValue()));
    assertThat(getter.getAnnotation(org.codehaus.jackson.annotate.JsonProperty.class), is(notNullValue()));
}
 
开发者ID:fge,项目名称:jsonschema2pojo,代码行数:21,代码来源:AnnotationStyleIT.java

示例11: customAnnotatorCanBeAppliedAlongsideCoreAnnotator

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void customAnnotatorCanBeAppliedAlongsideCoreAnnotator() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    ClassLoader resultsClassLoader = generateAndCompile("/schema/properties/primitiveProperties.json", "com.example",
            config("customAnnotator", DeprecatingAnnotator.class.getName()));

    Class generatedType = resultsClassLoader.loadClass("com.example.PrimitiveProperties");

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(JsonInclude.class), is(notNullValue()));
    assertThat(getter.getAnnotation(JsonProperty.class), is(notNullValue()));

    assertThat(generatedType.getAnnotation(Deprecated.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(Deprecated.class), is(notNullValue()));
    assertThat(getter.getAnnotation(Deprecated.class), is(notNullValue()));
}
 
开发者ID:fge,项目名称:jsonschema2pojo,代码行数:20,代码来源:CustomAnnotatorIT.java

示例12: propertyOrder

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Override
public void propertyOrder(JDefinedClass clazz, JsonNode propertiesNode) {
    JAnnotationArrayMember annotationValue = clazz.annotate(JsonPropertyOrder.class).paramArray("value");

    for (Iterator<String> properties = propertiesNode.fieldNames(); properties.hasNext();) {
        annotationValue.param(properties.next());
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Jackson2Annotator.java

示例13: defaultAnnotationStyeIsJackson2

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void defaultAnnotationStyeIsJackson2() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example");

    Class generatedType = resultsClassLoader.loadClass("com.example.PrimitiveProperties");

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(JsonInclude.class), is(notNullValue()));
    assertThat(getter.getAnnotation(JsonProperty.class), is(notNullValue()));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:AnnotationStyleIT.java

示例14: annotationStyleJacksonProducesJackson2Annotations

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void annotationStyleJacksonProducesJackson2Annotations() throws ClassNotFoundException, SecurityException, NoSuchMethodException {

    ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/properties/primitiveProperties.json", "com.example",
            config("annotationStyle", "jackson"));

    Class generatedType = resultsClassLoader.loadClass("com.example.PrimitiveProperties");

    Method getter = generatedType.getMethod("getA");

    assertThat(generatedType.getAnnotation(JsonPropertyOrder.class), is(notNullValue()));
    assertThat(generatedType.getAnnotation(JsonInclude.class), is(notNullValue()));
    assertThat(getter.getAnnotation(JsonProperty.class), is(notNullValue()));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:AnnotationStyleIT.java

示例15: onGetAnnotationShouldReturnParentAnnotation

import com.fasterxml.jackson.annotation.JsonPropertyOrder; //导入依赖的package包/类
@Test
public void onGetAnnotationShouldReturnParentAnnotation() {
	// WHEN
	Optional<JsonPropertyOrder> result = ClassUtils.getAnnotation(ChildClass.class, JsonPropertyOrder.class);

	// THEN
	assertThat(result.get()).isInstanceOf(JsonPropertyOrder.class);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:9,代码来源:ClassUtilsTest.java


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