@Test public void buildFields() throws Exception { underTest.addProperty("foo", TypeName.INT) .addProperty("bar", TypeName.OBJECT) .addProperty("baz", TypeName.BOOLEAN); final List<FieldSpec> actual = underTest.buildFields(); assertThat(actual) .hasSize(3) .doesNotContainNull(); assertThat(actual.get(0)) .hasType(TypeName.INT) .hasName("foo") .isPrivate() .isFinal() .hasNoInitializer() .hasAnnotation(AnnotationSpec.builder(SerializedName.class) .addMember("value", "$S", "foo") .build()); assertThat(actual.get(1)) .hasType(TypeName.OBJECT) .hasName("bar") .isPrivate() .isFinal() .hasNoInitializer() .hasAnnotation(AnnotationSpec.builder(SerializedName.class) .addMember("value", "$S", "bar") .build()); assertThat(actual.get(2)) .hasType(TypeName.BOOLEAN) .hasName("baz") .isPrivate() .isFinal() .hasNoInitializer() .hasAnnotation(AnnotationSpec.builder(SerializedName.class) .addMember("value", "$S", "baz") .build()); }
@Nonnull @Override protected List<FieldSpec> buildFields() { return getProperties() .entrySet() .stream() .map(property -> { final String name = property.getKey(); final TypeName type = property.getValue(); final String fieldName = fieldNamePolicy.convert(name, type); return FieldSpec.builder(type, fieldName) .addModifiers(Modifier.PRIVATE, Modifier.FINAL) .addAnnotation(AnnotationSpec.builder(SerializedName.class) .addMember("value", "$S", name) .build()) .build(); }) .collect(Collectors.toList()); }
GsonClassBuilder extends ClassBuilder { @Nonnull @Override protected List<FieldSpec> buildFields() { return getProperties() .entrySet() .stream() .map(property -> { final String name = property.getKey(); final TypeName type = property.getValue(); final String fieldName = fieldNamePolicy.convert(name, type); return FieldSpec.builder(type, fieldName) .addModifiers(Modifier.PRIVATE, Modifier.FINAL) .addAnnotation(AnnotationSpec.builder(SerializedName.class) .addMember("value", "$S", name) .build()) .build(); }) .collect(Collectors.toList()); } }
GsonClassBuilder extends ClassBuilder { @Nonnull @Override protected List<FieldSpec> buildFields() { return getProperties() .entrySet() .stream() .map(property -> { final String name = property.getKey(); final TypeName type = property.getValue(); final String fieldName = fieldNamePolicy.convert(name, type); return FieldSpec.builder(type, fieldName) .addModifiers(Modifier.PRIVATE, Modifier.FINAL) .addAnnotation(AnnotationSpec.builder(SerializedName.class) .addMember("value", "$S", name) .build()) .build(); }) .collect(Collectors.toList()); } GsonClassBuilder(@Nonnull NamePolicy fieldNamePolicy,
                            @Nonnull NamePolicy methodNamePolicy,
                            @Nonnull NamePolicy parameterNamePolicy); }
GsonClassBuilder extends ClassBuilder { @Nonnull @Override protected List<FieldSpec> buildFields() { return getProperties() .entrySet() .stream() .map(property -> { final String name = property.getKey(); final TypeName type = property.getValue(); final String fieldName = fieldNamePolicy.convert(name, type); return FieldSpec.builder(type, fieldName) .addModifiers(Modifier.PRIVATE, Modifier.FINAL) .addAnnotation(AnnotationSpec.builder(SerializedName.class) .addMember("value", "$S", name) .build()) .build(); }) .collect(Collectors.toList()); } GsonClassBuilder(@Nonnull NamePolicy fieldNamePolicy,
                            @Nonnull NamePolicy methodNamePolicy,
                            @Nonnull NamePolicy parameterNamePolicy);  }
GsonClassBuilder extends ClassBuilder { @Nonnull @Override protected List<FieldSpec> buildFields() { return getProperties() .entrySet() .stream() .map(property -> { final String name = property.getKey(); final TypeName type = property.getValue(); final String fieldName = fieldNamePolicy.convert(name, type); return FieldSpec.builder(type, fieldName) .addModifiers(Modifier.PRIVATE, Modifier.FINAL) .addAnnotation(AnnotationSpec.builder(SerializedName.class) .addMember("value", "$S", name) .build()) .build(); }) .collect(Collectors.toList()); } GsonClassBuilder(@Nonnull NamePolicy fieldNamePolicy,
                            @Nonnull NamePolicy methodNamePolicy,
                            @Nonnull NamePolicy parameterNamePolicy);   }