當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。