diff --git a/java/lombok/AConsumer.java b/java/lombok/AConsumer.java index de67563..9bafb1c 100644 --- a/java/lombok/AConsumer.java +++ b/java/lombok/AConsumer.java @@ -4,24 +4,28 @@ package co.gitar.example.lombok; -import lombok.extern.slf4j.Slf4j; -import lombok.experimental.UtilityClass; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * JavaDoc for the class. * *
Do not delete this JavaDoc comment. */ -@UtilityClass -@Slf4j -class AConsumer { - public void processRecord(ARecord record) { - log.info("Record {} is {}", ARecord.Fields.username, record.username()); - log.info("Record {} is {}", ARecord.Fields.age, record.age()); - if (record.enabled()) { - log.info("Record is enabled"); - } else { - log.info("Record is disabled"); - } +final class AConsumer { + private static final Logger log = LoggerFactory.getLogger(AConsumer.class); + + public static void processRecord(ARecord record) { + log.info("Record {} is {}", ARecord.Fields.username, record.username()); + log.info("Record {} is {}", ARecord.Fields.age, record.age()); + if (record.enabled()) { + log.info("Record is enabled"); + } else { + log.info("Record is disabled"); } + } + + private AConsumer() { + throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); + } } diff --git a/java/lombok/ARecord.java b/java/lombok/ARecord.java index 7106123..2d82a3e 100644 --- a/java/lombok/ARecord.java +++ b/java/lombok/ARecord.java @@ -4,23 +4,30 @@ package co.gitar.example.lombok; -import lombok.experimental.Accessors; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.experimental.FieldDefaults; -import lombok.Getter; -import lombok.Setter; - -@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) -@lombok.experimental.FieldNameConstants -@Accessors(fluent = true) public class ARecord { - @Getter - String username; - @Getter @Setter - int age; - @Getter @Setter - boolean enabled; + private final String username; + + public String username() { + return this.username; + } + + private final int age; + + public ARecord age(final int age) { + this.age = age; + return this; + } + + private final boolean enabled; + + public boolean enabled() { + return this.enabled; + } + + public ARecord enabled(final boolean enabled) { + this.enabled = enabled; + return this; + } // Could also be @AllArgsConstructor, we aren't targetting removing that annotation // for now. @@ -29,4 +36,10 @@ public ARecord(String username, int age, boolean enabled) { this.age = age; this.enabled = enabled; } + + public static final class Fields { + public static final String username = "username"; + public static final String age = "age"; + public static final String enabled = "enabled"; + } }