From 5d44152bbc3253938f912b36f2c56e543e7e3354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Mon, 27 May 2024 14:49:28 +0300 Subject: [PATCH] docs: update value object --- value-object/README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/value-object/README.md b/value-object/README.md index 840b60083..33226a0bb 100644 --- a/value-object/README.md +++ b/value-object/README.md @@ -51,7 +51,6 @@ Here is the `HeroStat` class that is the value object. Notice the use of [Lombok @Value(staticConstructor = "valueOf") @ToString class HeroStat { - int strength; int intelligence; int luck; @@ -61,16 +60,18 @@ class HeroStat { The example creates three different `HeroStat`s and compares their equality. ```java -var statA = HeroStat.valueOf(10, 5, 0); -var statB = HeroStat.valueOf(10, 5, 0); -var statC = HeroStat.valueOf(5, 1, 8); +public static void main(String[] args) { + var statA = HeroStat.valueOf(10, 5, 0); + var statB = HeroStat.valueOf(10, 5, 0); + var statC = HeroStat.valueOf(5, 1, 8); -LOGGER.info("statA: {}", statA); -LOGGER.info("statB: {}", statB); -LOGGER.info("statC: {}", statC); + LOGGER.info("statA: {}", statA); + LOGGER.info("statB: {}", statB); + LOGGER.info("statC: {}", statC); -LOGGER.info("Are statA and statB equal? {}", statA.equals(statB)); -LOGGER.info("Are statA and statC equal? {}", statA.equals(statC)); + LOGGER.info("Are statA and statB equal? {}", statA.equals(statB)); + LOGGER.info("Are statA and statC equal? {}", statA.equals(statC)); +} ``` Here's the console output. @@ -137,4 +138,4 @@ Trade-offs: * [Effective Java](https://amzn.to/4cGk2Jz) * [J2EE Design Patterns](https://amzn.to/4dpzgmx) * [Patterns of Enterprise Application Architecture](https://amzn.to/3WfKBPR) -* [ValueObject - Martin Fowler](https://martinfowler.com/bliki/ValueObject.html) +* [ValueObject (Martin Fowler)](https://martinfowler.com/bliki/ValueObject.html)