BAEL-3475 Add code for Lombok Accessors including prefix with trailing _ (#8166)
* BAEL-3475 - Add code for Lombok Accessors * BAEL-3475 - Updated lombok.version to latest * BAEL-3475 - Rename Test to UnitTest * BAEL-3475 - Add prefix with trailing _, make fields private, and update delombok version
This commit is contained in:
parent
7b6a39fc70
commit
d3648eca9c
|
@ -77,10 +77,11 @@
|
|||
<properties>
|
||||
<!-- lombok: https://projectlombok.org/changelog.html -->
|
||||
<lombok.version>1.18.10</lombok.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version>
|
||||
<!-- delombok maven plugin -->
|
||||
<delombok-maven-plugin.version>1.18.4.0</delombok-maven-plugin.version>
|
||||
<delombok-maven-plugin.version>1.18.10.0</delombok-maven-plugin.version>
|
||||
<assertj-core.version>3.8.0</assertj-core.version>
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -10,6 +10,6 @@ import java.math.BigDecimal;
|
|||
@Getter
|
||||
@Setter
|
||||
public class ChainedAccount {
|
||||
String name;
|
||||
BigDecimal balance;
|
||||
private String name;
|
||||
private BigDecimal balance;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ import java.math.BigDecimal;
|
|||
@Getter
|
||||
@Setter
|
||||
public class ChainedFluentAccount {
|
||||
String name;
|
||||
BigDecimal balance;
|
||||
private String name;
|
||||
private BigDecimal balance;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ import java.math.BigDecimal;
|
|||
@Getter
|
||||
@Setter
|
||||
public class FluentAccount {
|
||||
String name;
|
||||
BigDecimal balance;
|
||||
private String name;
|
||||
private BigDecimal balance;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ import java.math.BigDecimal;
|
|||
@Getter
|
||||
@Setter
|
||||
public class PrefixedFluentAccount {
|
||||
String sName;
|
||||
BigDecimal bdBalance;
|
||||
private String sName;
|
||||
private BigDecimal bdBalance;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ import java.math.BigDecimal;
|
|||
@Getter
|
||||
@Setter
|
||||
public class StandardAccount {
|
||||
String name;
|
||||
BigDecimal balance;
|
||||
private String name;
|
||||
private BigDecimal balance;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue