Skip to content

Commit 67d3131

Browse files
committed
Final Lombok removal
1 parent 19aaaf1 commit 67d3131

File tree

7 files changed

+468
-79
lines changed

7 files changed

+468
-79
lines changed

msal4j-sdk/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<groupId>org.projectlombok</groupId>
6060
<artifactId>lombok</artifactId>
6161
<version>1.18.36</version>
62-
<scope>provided</scope>
62+
<scope>test</scope>
6363
</dependency>
6464
<dependency>
6565
<groupId>com.azure</groupId>

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/Account.java

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,63 @@
33

44
package com.microsoft.aad.msal4j;
55

6-
import lombok.AllArgsConstructor;
7-
import lombok.EqualsAndHashCode;
8-
import lombok.Getter;
9-
import lombok.Setter;
10-
import lombok.experimental.Accessors;
11-
126
import java.util.Map;
7+
import java.util.Objects;
138

149
/**
1510
* Representation of a single user account. If modifying this object, ensure it is compliant with
1611
* cache persistent model
1712
*/
18-
@Accessors(fluent = true)
19-
@Getter
20-
@Setter
21-
@EqualsAndHashCode(of = {"homeAccountId"})
22-
@AllArgsConstructor
2313
class Account implements IAccount {
2414

2515
String homeAccountId;
26-
2716
String environment;
28-
2917
String username;
30-
3118
Map<String, ITenantProfile> tenantProfiles;
3219

20+
Account(String homeAccountId, String environment, String username, Map<String, ITenantProfile> tenantProfiles) {
21+
this.homeAccountId = homeAccountId;
22+
this.environment = environment;
23+
this.username = username;
24+
this.tenantProfiles = tenantProfiles;
25+
}
26+
3327
public Map<String, ITenantProfile> getTenantProfiles() {
3428
return tenantProfiles;
3529
}
30+
31+
public String homeAccountId() {
32+
return this.homeAccountId;
33+
}
34+
35+
public String environment() {
36+
return this.environment;
37+
}
38+
39+
public String username() {
40+
return this.username;
41+
}
42+
43+
void username(String username) {
44+
this.username = username;
45+
}
46+
47+
//These methods are based on those generated by Lombok's @EqualsAndHashCode annotation.
48+
//They have the same functionality as the generated methods, but were refactored for readability.
49+
@Override
50+
public boolean equals(Object o) {
51+
if (this == o) return true;
52+
if (!(o instanceof Account)) return false;
53+
54+
Account other = (Account) o;
55+
56+
return Objects.equals(homeAccountId(), other.homeAccountId());
57+
}
58+
59+
@Override
60+
public int hashCode() {
61+
int result = 1;
62+
result = result * 59 + (this.homeAccountId == null ? 43 : this.homeAccountId.hashCode());
63+
return result;
64+
}
3665
}

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AccountCacheEntity.java

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@
44
package com.microsoft.aad.msal4j;
55

66
import com.fasterxml.jackson.annotation.JsonProperty;
7-
import lombok.*;
8-
import lombok.experimental.Accessors;
97

108
import java.io.Serializable;
119
import java.util.ArrayList;
1210
import java.util.List;
13-
import java.util.Map;
11+
import java.util.Objects;
1412

15-
@Accessors(fluent = true)
16-
@Getter
17-
@Setter
18-
@EqualsAndHashCode
1913
class AccountCacheEntity implements Serializable {
2014

2115
static final String MSSTS_ACCOUNT_TYPE = "MSSTS";
@@ -106,4 +100,111 @@ static AccountCacheEntity create(String clientInfoStr, Authority requestAuthorit
106100
IAccount toAccount() {
107101
return new Account(homeAccountId, environment, username, null);
108102
}
103+
104+
String homeAccountId() {
105+
return this.homeAccountId;
106+
}
107+
108+
String environment() {
109+
return this.environment;
110+
}
111+
112+
String realm() {
113+
return this.realm;
114+
}
115+
116+
String localAccountId() {
117+
return this.localAccountId;
118+
}
119+
120+
String username() {
121+
return this.username;
122+
}
123+
124+
String name() {
125+
return this.name;
126+
}
127+
128+
String clientInfoStr() {
129+
return this.clientInfoStr;
130+
}
131+
132+
String userAssertionHash() {
133+
return this.userAssertionHash;
134+
}
135+
136+
String authorityType() {
137+
return this.authorityType;
138+
}
139+
140+
void homeAccountId(String homeAccountId) {
141+
this.homeAccountId = homeAccountId;
142+
}
143+
144+
void environment(String environment) {
145+
this.environment = environment;
146+
}
147+
148+
void realm(String realm) {
149+
this.realm = realm;
150+
}
151+
152+
void localAccountId(String localAccountId) {
153+
this.localAccountId = localAccountId;
154+
}
155+
156+
void username(String username) {
157+
this.username = username;
158+
}
159+
160+
void name(String name) {
161+
this.name = name;
162+
}
163+
164+
void clientInfoStr(String clientInfoStr) {
165+
this.clientInfoStr = clientInfoStr;
166+
}
167+
168+
void userAssertionHash(String userAssertionHash) {
169+
this.userAssertionHash = userAssertionHash;
170+
}
171+
172+
void authorityType(String authorityType) {
173+
this.authorityType = authorityType;
174+
}
175+
176+
//These methods are based on those generated by Lombok's @EqualsAndHashCode annotation.
177+
//They have the same functionality as the generated methods, but were refactored for readability.
178+
@Override
179+
public boolean equals(Object o) {
180+
if (this == o) return true;
181+
if (!(o instanceof AccountCacheEntity)) return false;
182+
183+
AccountCacheEntity other = (AccountCacheEntity) o;
184+
185+
if (!Objects.equals(homeAccountId(), other.homeAccountId())) return false;
186+
if (!Objects.equals(environment(), other.environment())) return false;
187+
if (!Objects.equals(realm(), other.realm())) return false;
188+
if (!Objects.equals(localAccountId(), other.localAccountId())) return false;
189+
if (!Objects.equals(username(), other.username())) return false;
190+
if (!Objects.equals(name(), other.name())) return false;
191+
if (!Objects.equals(clientInfoStr(), other.clientInfoStr())) return false;
192+
if (!Objects.equals(userAssertionHash(), other.userAssertionHash())) return false;
193+
return Objects.equals(authorityType(), other.authorityType());
194+
}
195+
196+
@Override
197+
public int hashCode() {
198+
int result = 1;
199+
result = result * 59 + (this.homeAccountId == null ? 43 : this.homeAccountId.hashCode());
200+
result = result * 59 + (this.environment == null ? 43 : this.environment.hashCode());
201+
result = result * 59 + (this.realm == null ? 43 : this.realm.hashCode());
202+
result = result * 59 + (this.localAccountId == null ? 43 : this.localAccountId.hashCode());
203+
result = result * 59 + (this.username == null ? 43 : this.username.hashCode());
204+
result = result * 59 + (this.name() == null ? 43 : this.name().hashCode());
205+
result = result * 59 + (this.clientInfoStr == null ? 43 : this.clientInfoStr.hashCode());
206+
result = result * 59 + (this.userAssertionHash == null ? 43 : this.userAssertionHash.hashCode());
207+
result = result * 59 + (this.authorityType == null ? 43 : this.authorityType.hashCode());
208+
return result;
209+
}
109210
}

0 commit comments

Comments
 (0)