Created
April 10, 2017 20:35
-
-
Save rasheedamir/013be66b76a393af676fa18bb2a35914 to your computer and use it in GitHub Desktop.
trying lombok with jackson with builder patter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample.producer.domain; | |
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | |
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | |
import lombok.AccessLevel; | |
import lombok.NoArgsConstructor; | |
import lombok.Value; | |
@Value /* to generate equals, hashCode, getters & toString ( immutable ) */ | |
@NoArgsConstructor(force = true, access = AccessLevel.PACKAGE) /* just for dehydration! as default ctor is used to create object & then fields are set using refection! */ | |
@JsonDeserialize(builder = WorkUnit.Builder.class) | |
public class WorkUnit | |
{ | |
private final String id; | |
private final String definition; | |
@lombok.Builder(builderClassName = "Builder", builderMethodName = "newBuilder", toBuilder = true) | |
private WorkUnit(String id, | |
String definition) { | |
this.id = id; | |
this.definition = definition; | |
} | |
@JsonPOJOBuilder(withPrefix = "") | |
public static class Builder | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment