@Test public void testPropertyOrderRule() { TypeSpec.Builder builder = TypeSpec.classBuilder("Test"); TypeModel model = mock(TypeModel.class); when(model.getFieldOrder()).thenReturn(Arrays.asList("one", "two")); new JacksonStyle().processPropertyOrderRule(builder, model); TypeSpec typeSpec = builder.build(); assertEquals("Test", typeSpec.name); assertEquals(1, typeSpec.annotations.size()); AnnotationSpec orderAnnotation = typeSpec.annotations.get(0); assertEquals(1, orderAnnotation.members.size()); assertEquals(2, orderAnnotation.members.get("value").size()); }
@Override public void processPropertyOrderRule(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<String> fieldOrder = typeModel.getFieldOrder(); AnnotationSpec.Builder propertyOrderBuilder = AnnotationSpec.builder(JsonPropertyOrder.class); for (String field : fieldOrder) { propertyOrderBuilder.addMember("value", "$S", field); } typeSpec.addAnnotation(propertyOrderBuilder.build()); }
JacksonStyle extends AnnotatorStyle { @Override public void processPropertyOrderRule(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<String> fieldOrder = typeModel.getFieldOrder(); AnnotationSpec.Builder propertyOrderBuilder = AnnotationSpec.builder(JsonPropertyOrder.class); for (String field : fieldOrder) { propertyOrderBuilder.addMember("value", "$S", field); } typeSpec.addAnnotation(propertyOrderBuilder.build()); } }
JacksonStyle extends AnnotatorStyle { @Override public void processPropertyOrderRule(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<String> fieldOrder = typeModel.getFieldOrder(); AnnotationSpec.Builder propertyOrderBuilder = AnnotationSpec.builder(JsonPropertyOrder.class); for (String field : fieldOrder) { propertyOrderBuilder.addMember("value", "$S", field); } typeSpec.addAnnotation(propertyOrderBuilder.build()); }  }
JacksonStyle extends AnnotatorStyle { @Override public void processPropertyOrderRule(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<String> fieldOrder = typeModel.getFieldOrder(); AnnotationSpec.Builder propertyOrderBuilder = AnnotationSpec.builder(JsonPropertyOrder.class); for (String field : fieldOrder) { propertyOrderBuilder.addMember("value", "$S", field); } typeSpec.addAnnotation(propertyOrderBuilder.build()); }  @Override void processNamedAsRule(FieldSpec.Builder fieldSpec, FieldModel fieldModel); @Override void processInclusionRule(FieldSpec.Builder fieldSpec, FieldModel fieldModel); @Override void processGlobalInclusionRule(TypeSpec.Builder typeSpec, TypeModel typeModel); @Override void processSubTypeRule(TypeSpec.Builder typeSpec, TypeModel typeModel); @Override void processIgnoreUnknownsRule(TypeSpec.Builder typeSpec, TypeModel typeModel); @Override void processPropertyOrderRule(TypeSpec.Builder typeSpec, TypeModel typeModel); @Override void processConstructorOrderRule(MethodSpec.Builder methodSpec, TypeModel typeModel, List<String> constructorFields); }
JacksonStyle extends AnnotatorStyle { @Override public void processPropertyOrderRule(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<String> fieldOrder = typeModel.getFieldOrder(); AnnotationSpec.Builder propertyOrderBuilder = AnnotationSpec.builder(JsonPropertyOrder.class); for (String field : fieldOrder) { propertyOrderBuilder.addMember("value", "$S", field); } typeSpec.addAnnotation(propertyOrderBuilder.build()); }  @Override void processNamedAsRule(FieldSpec.Builder fieldSpec, FieldModel fieldModel); @Override void processInclusionRule(FieldSpec.Builder fieldSpec, FieldModel fieldModel); @Override void processGlobalInclusionRule(TypeSpec.Builder typeSpec, TypeModel typeModel); @Override void processSubTypeRule(TypeSpec.Builder typeSpec, TypeModel typeModel); @Override void processIgnoreUnknownsRule(TypeSpec.Builder typeSpec, TypeModel typeModel); @Override void processPropertyOrderRule(TypeSpec.Builder typeSpec, TypeModel typeModel); @Override void processConstructorOrderRule(MethodSpec.Builder methodSpec, TypeModel typeModel, List<String> constructorFields);  }