diff --git a/lombok/pom.xml b/lombok/pom.xml index b67320909e..5e2ad33f66 100644 --- a/lombok/pom.xml +++ b/lombok/pom.xml @@ -77,10 +77,11 @@ 1.18.10 + 1.0.0.Final - 1.18.4.0 + 1.18.10.0 3.8.0 diff --git a/lombok/src/main/java/com/baeldung/lombok/accessors/model/BasicAccount.java b/lombok/src/main/java/com/baeldung/lombok/accessors/model/BasicAccount.java index 74ae51c040..a9332735c7 100644 --- a/lombok/src/main/java/com/baeldung/lombok/accessors/model/BasicAccount.java +++ b/lombok/src/main/java/com/baeldung/lombok/accessors/model/BasicAccount.java @@ -3,8 +3,8 @@ package com.baeldung.lombok.accessors.model; import java.math.BigDecimal; public class BasicAccount { - String name; - BigDecimal balance; + private String name; + private BigDecimal balance; public BigDecimal getBalance() { return this.balance; diff --git a/lombok/src/main/java/com/baeldung/lombok/accessors/model/ChainedAccount.java b/lombok/src/main/java/com/baeldung/lombok/accessors/model/ChainedAccount.java index 8fa9a2e8aa..0437d8f60e 100644 --- a/lombok/src/main/java/com/baeldung/lombok/accessors/model/ChainedAccount.java +++ b/lombok/src/main/java/com/baeldung/lombok/accessors/model/ChainedAccount.java @@ -10,6 +10,6 @@ import java.math.BigDecimal; @Getter @Setter public class ChainedAccount { - String name; - BigDecimal balance; + private String name; + private BigDecimal balance; } diff --git a/lombok/src/main/java/com/baeldung/lombok/accessors/model/ChainedFluentAccount.java b/lombok/src/main/java/com/baeldung/lombok/accessors/model/ChainedFluentAccount.java index 22e85848bd..6ebc080c94 100644 --- a/lombok/src/main/java/com/baeldung/lombok/accessors/model/ChainedFluentAccount.java +++ b/lombok/src/main/java/com/baeldung/lombok/accessors/model/ChainedFluentAccount.java @@ -10,6 +10,6 @@ import java.math.BigDecimal; @Getter @Setter public class ChainedFluentAccount { - String name; - BigDecimal balance; + private String name; + private BigDecimal balance; } diff --git a/lombok/src/main/java/com/baeldung/lombok/accessors/model/FluentAccount.java b/lombok/src/main/java/com/baeldung/lombok/accessors/model/FluentAccount.java index bc5e6ba70e..4c2e1f7976 100644 --- a/lombok/src/main/java/com/baeldung/lombok/accessors/model/FluentAccount.java +++ b/lombok/src/main/java/com/baeldung/lombok/accessors/model/FluentAccount.java @@ -10,6 +10,6 @@ import java.math.BigDecimal; @Getter @Setter public class FluentAccount { - String name; - BigDecimal balance; + private String name; + private BigDecimal balance; } diff --git a/lombok/src/main/java/com/baeldung/lombok/accessors/model/PrefixedAccount.java b/lombok/src/main/java/com/baeldung/lombok/accessors/model/PrefixedAccount.java index e3e3ae620b..506d7adc75 100644 --- a/lombok/src/main/java/com/baeldung/lombok/accessors/model/PrefixedAccount.java +++ b/lombok/src/main/java/com/baeldung/lombok/accessors/model/PrefixedAccount.java @@ -11,6 +11,10 @@ import java.math.BigDecimal; @Getter @Setter public class PrefixedAccount { - String sName; - BigDecimal bdBalance; + private String sName; + private BigDecimal bdBalance; + + @Accessors(prefix = "s_") + private String s_notes; + } diff --git a/lombok/src/main/java/com/baeldung/lombok/accessors/model/PrefixedFluentAccount.java b/lombok/src/main/java/com/baeldung/lombok/accessors/model/PrefixedFluentAccount.java index 462a9b41ec..eb23bf58e2 100644 --- a/lombok/src/main/java/com/baeldung/lombok/accessors/model/PrefixedFluentAccount.java +++ b/lombok/src/main/java/com/baeldung/lombok/accessors/model/PrefixedFluentAccount.java @@ -10,6 +10,6 @@ import java.math.BigDecimal; @Getter @Setter public class PrefixedFluentAccount { - String sName; - BigDecimal bdBalance; + private String sName; + private BigDecimal bdBalance; } diff --git a/lombok/src/main/java/com/baeldung/lombok/accessors/model/StandardAccount.java b/lombok/src/main/java/com/baeldung/lombok/accessors/model/StandardAccount.java index 89727fef19..4d0d578a4d 100644 --- a/lombok/src/main/java/com/baeldung/lombok/accessors/model/StandardAccount.java +++ b/lombok/src/main/java/com/baeldung/lombok/accessors/model/StandardAccount.java @@ -8,6 +8,6 @@ import java.math.BigDecimal; @Getter @Setter public class StandardAccount { - String name; - BigDecimal balance; + private String name; + private BigDecimal balance; } diff --git a/lombok/src/test/java/com/baeldung/lombok/accessors/AccessorsUnitTest.java b/lombok/src/test/java/com/baeldung/lombok/accessors/AccessorsUnitTest.java index 679c7d39ef..04f38bfc32 100644 --- a/lombok/src/test/java/com/baeldung/lombok/accessors/AccessorsUnitTest.java +++ b/lombok/src/test/java/com/baeldung/lombok/accessors/AccessorsUnitTest.java @@ -12,11 +12,11 @@ public class AccessorsUnitTest { @Test public void givenBasicAccount_thenUseBasicAccessors() { BasicAccount account = new BasicAccount(); - account.setBalance(BigDecimal.TEN); account.setName("Basic Accessors"); + account.setBalance(BigDecimal.TEN); - assertEquals(BigDecimal.TEN, account.getBalance()); assertEquals("Basic Accessors", account.getName()); + assertEquals(BigDecimal.TEN, account.getBalance()); } @Test @@ -25,8 +25,8 @@ public class AccessorsUnitTest { account.name("Fluent Account"); account.balance(BigDecimal.TEN); - assertEquals(BigDecimal.TEN, account.balance()); assertEquals("Fluent Account", account.name()); + assertEquals(BigDecimal.TEN, account.balance()); } @Test @@ -34,8 +34,8 @@ public class AccessorsUnitTest { ChainedAccount account = new ChainedAccount(); account.setName("Chained Account").setBalance(BigDecimal.TEN); - assertEquals(BigDecimal.TEN, account.getBalance()); assertEquals("Chained Account", account.getName()); + assertEquals(BigDecimal.TEN, account.getBalance()); } @Test @@ -44,8 +44,8 @@ public class AccessorsUnitTest { .name("Fluent Account") .balance(BigDecimal.TEN); - assertEquals(BigDecimal.TEN, account.balance()); assertEquals("Fluent Account", account.name()); + assertEquals(BigDecimal.TEN, account.balance()); } @Test @@ -53,9 +53,11 @@ public class AccessorsUnitTest { PrefixedAccount account = new PrefixedAccount(); account.setName("Prefixed Fields"); account.setBalance(BigDecimal.TEN); + account.setNotes("Notes"); - assertEquals(BigDecimal.TEN, account.getBalance()); assertEquals("Prefixed Fields", account.getName()); + assertEquals(BigDecimal.TEN, account.getBalance()); + assertEquals("Notes", account.getNotes()); } @Test @@ -65,8 +67,8 @@ public class AccessorsUnitTest { .name("Prefixed Fluent Fields") .balance(BigDecimal.TEN); - assertEquals(BigDecimal.TEN, account.balance()); assertEquals("Prefixed Fluent Fields", account.name()); + assertEquals(BigDecimal.TEN, account.balance()); } }