Skip to content

Instantly share code, notes, and snippets.

@kapresoft
Last active November 3, 2021 22:55
Show Gist options
  • Save kapresoft/fe4e67bc8bd62efa4994c7fab8692e89 to your computer and use it in GitHub Desktop.
Save kapresoft/fe4e67bc8bd62efa4994c7fab8692e89 to your computer and use it in GitHub Desktop.
Immutable Account using Lombok `@Value` Annotation
package com.kapresoft.springboot.serializeimmutableobjects.dto.simple;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.Builder;
import lombok.Value;
/**
* Immutable Account using Lombok {@code @Value}.
*/
@Value
@JsonPropertyOrder({"username", "email", "firstName", "lastName"})
public class Account {
String username;
String email;
String firstName;
String lastName;
@Builder
public Account(@JsonProperty("username") String username,
@JsonProperty("email") String email,
@JsonProperty("firstName") String firstName,
@JsonProperty("lastName") String lastName) {
this.username = username;
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment