Skip to content

Instantly share code, notes, and snippets.

@rasheedamir
Created April 10, 2017 20:35
Show Gist options
  • Save rasheedamir/013be66b76a393af676fa18bb2a35914 to your computer and use it in GitHub Desktop.
Save rasheedamir/013be66b76a393af676fa18bb2a35914 to your computer and use it in GitHub Desktop.
trying lombok with jackson with builder patter
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