bluelinelabs / LoganSquare

Screaming fast JSON parsing and serialization library for Android.
Apache License 2.0
3.21k stars 306 forks source link

Generated JsonObjectMapper always use setters if setter exists #202

Closed september669 closed 7 years ago

september669 commented 7 years ago

For example:

@JsonObject public final class Foo { @NonNull @JsonField(name = "camera_model") public String cameraModel;

public void setCameraModel(@NonNull String cameraModel){
    this.cameraModel = cameraModel;
}

}

And in Foo$$JsonObjectMapper:

@Override public void parseField(CameraDeviceHardware instance, String fieldName, JsonParser jsonParser) throws IOException { if ("camera_model".equals(fieldName)) { instance.setCameraModel(jsonParser.getValueAsString(null)); } .. }

And only if setter not exists Mapper uses direct access to field. Is it correct?

mannodermaus commented 7 years ago

Yes

september669 commented 7 years ago

thx