Skip to content

Commit e65197c

Browse files
committed
using lombok for getters
1 parent 74d9a11 commit e65197c

File tree

9 files changed

+22
-186
lines changed

9 files changed

+22
-186
lines changed

iam/iam-client/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
<artifactId>sts-client</artifactId>
2525
</dependency>
2626

27+
<!-- Lombok -->
28+
<dependency>
29+
<groupId>org.projectlombok</groupId>
30+
<artifactId>lombok</artifactId>
31+
<version>1.18.34</version>
32+
<scope>provided</scope>
33+
</dependency>
34+
2735
<!-- Test dependencies -->
2836
<dependency>
2937
<groupId>org.junit.jupiter</groupId>

iam/iam-client/src/main/java/com/salesforce/multicloudj/iam/client/IamClient.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
* // Attach policy
4141
* client.attachInlinePolicy(policy, "123456789012", "us-west-2", "my-bucket");
4242
* </pre>
43-
*
44-
* @since 0.3.0
4543
*/
4644
public class IamClient {
4745

iam/iam-client/src/main/java/com/salesforce/multicloudj/iam/model/CreateOptions.java

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.salesforce.multicloudj.iam.model;
22

3+
import lombok.Getter;
4+
35
import java.util.Objects;
46

57
/**
@@ -11,14 +13,13 @@
1113
* <p>Usage example:
1214
* <pre>
1315
* CreateOptions options = CreateOptions.builder()
14-
* .path("/orgstore/")
16+
* .path("/foo/")
1517
* .maxSessionDuration(43200) // 12 hours
1618
* .permissionBoundary("arn:aws:iam::123456789012:policy/PowerUserBoundary")
1719
* .build();
1820
* </pre>
19-
*
20-
* @since 0.3.0
2121
*/
22+
@Getter
2223
public class CreateOptions {
2324
private final String path;
2425
private final Integer maxSessionDuration;
@@ -39,32 +40,6 @@ public static Builder builder() {
3940
return new Builder();
4041
}
4142

42-
/**
43-
* Gets the path for the identity.
44-
*
45-
* @return the path, or null if not set
46-
*/
47-
public String getPath() {
48-
return path;
49-
}
50-
51-
/**
52-
* Gets the maximum session duration in seconds.
53-
*
54-
* @return the maximum session duration, or null if not set
55-
*/
56-
public Integer getMaxSessionDuration() {
57-
return maxSessionDuration;
58-
}
59-
60-
/**
61-
* Gets the permission boundary ARN.
62-
*
63-
* @return the permission boundary ARN, or null if not set
64-
*/
65-
public String getPermissionBoundary() {
66-
return permissionBoundary;
67-
}
6843

6944
@Override
7045
public boolean equals(Object o) {
@@ -104,7 +79,7 @@ private Builder() {
10479
/**
10580
* Sets the path for the identity.
10681
*
107-
* @param path the path (e.g., "/orgstore/") for organizing identities
82+
* @param path the path (e.g., "/foo/") for organizing identities
10883
* @return this Builder instance
10984
*/
11085
public Builder path(String path) {

iam/iam-client/src/main/java/com/salesforce/multicloudj/iam/model/PolicyDocument.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.salesforce.multicloudj.iam.model;
22

3+
import lombok.Getter;
4+
35
import java.util.ArrayList;
46
import java.util.List;
57
import java.util.Objects;
@@ -25,9 +27,8 @@
2527
* .endStatement()
2628
* .build();
2729
* </pre>
28-
*
29-
* @since 0.3.0
3030
*/
31+
@Getter
3132
public class PolicyDocument {
3233
private final String version;
3334
private final List<Statement> statements;
@@ -46,23 +47,7 @@ public static Builder builder() {
4647
return new Builder();
4748
}
4849

49-
/**
50-
* Gets the policy version.
51-
*
52-
* @return the policy version
53-
*/
54-
public String getVersion() {
55-
return version;
56-
}
5750

58-
/**
59-
* Gets the list of statements.
60-
*
61-
* @return an immutable copy of the statements list
62-
*/
63-
public List<Statement> getStatements() {
64-
return new ArrayList<>(statements);
65-
}
6651

6752
@Override
6853
public boolean equals(Object o) {

iam/iam-client/src/main/java/com/salesforce/multicloudj/iam/model/Statement.java

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.salesforce.multicloudj.iam.model;
22

3+
import lombok.Getter;
4+
35
import java.util.ArrayList;
46
import java.util.HashMap;
57
import java.util.List;
@@ -24,9 +26,8 @@
2426
* .addCondition("StringEquals", "aws:RequestedRegion", "us-west-2")
2527
* .build();
2628
* </pre>
27-
*
28-
* @since 0.3.0
2929
*/
30+
@Getter
3031
public class Statement {
3132
private final String sid;
3233
private final String effect;
@@ -53,59 +54,7 @@ public static Builder builder() {
5354
return new Builder();
5455
}
5556

56-
/**
57-
* Gets the statement ID.
58-
*
59-
* @return the statement ID, or null if not set
60-
*/
61-
public String getSid() {
62-
return sid;
63-
}
64-
65-
/**
66-
* Gets the effect (Allow or Deny).
67-
*
68-
* @return the effect
69-
*/
70-
public String getEffect() {
71-
return effect;
72-
}
73-
74-
/**
75-
* Gets the list of principals.
76-
*
77-
* @return an immutable copy of the principals list
78-
*/
79-
public List<String> getPrincipals() {
80-
return new ArrayList<>(principals);
81-
}
82-
83-
/**
84-
* Gets the list of actions.
85-
*
86-
* @return an immutable copy of the actions list
87-
*/
88-
public List<String> getActions() {
89-
return new ArrayList<>(actions);
90-
}
9157

92-
/**
93-
* Gets the list of resources.
94-
*
95-
* @return an immutable copy of the resources list
96-
*/
97-
public List<String> getResources() {
98-
return new ArrayList<>(resources);
99-
}
100-
101-
/**
102-
* Gets the conditions map.
103-
*
104-
* @return an immutable copy of the conditions map
105-
*/
106-
public Map<String, Map<String, Object>> getConditions() {
107-
return new HashMap<>(conditions);
108-
}
10958

11059
@Override
11160
public boolean equals(Object o) {

iam/iam-client/src/main/java/com/salesforce/multicloudj/iam/model/TrustConfiguration.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.salesforce.multicloudj.iam.model;
22

3+
import lombok.Getter;
4+
35
import java.util.ArrayList;
46
import java.util.HashMap;
57
import java.util.List;
@@ -20,9 +22,8 @@
2022
* .addCondition("StringEquals", "aws:RequestedRegion", "us-west-2")
2123
* .build();
2224
* </pre>
23-
*
24-
* @since 0.3.0
2525
*/
26+
@Getter
2627
public class TrustConfiguration {
2728
private final List<String> trustedPrincipals;
2829
private final Map<String, Map<String, Object>> conditions;
@@ -41,23 +42,6 @@ public static Builder builder() {
4142
return new Builder();
4243
}
4344

44-
/**
45-
* Gets the list of trusted principals.
46-
*
47-
* @return an immutable copy of the trusted principals list
48-
*/
49-
public List<String> getTrustedPrincipals() {
50-
return new ArrayList<>(trustedPrincipals);
51-
}
52-
53-
/**
54-
* Gets the trust conditions.
55-
*
56-
* @return an immutable copy of the conditions map
57-
*/
58-
public Map<String, Map<String, Object>> getConditions() {
59-
return new HashMap<>(conditions);
60-
}
6145

6246
@Override
6347
public boolean equals(Object o) {

iam/iam-client/src/test/java/com/salesforce/multicloudj/iam/model/PolicyDocumentTest.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -303,23 +303,6 @@ public void testPolicyDocumentToString() {
303303
assertTrue(result.contains("PolicyDocument"));
304304
}
305305

306-
@Test
307-
public void testGetStatementsReturnsImmutableCopy() {
308-
PolicyDocument policy = PolicyDocument.builder()
309-
.statement("TestStatement")
310-
.effect("Allow")
311-
.addAction("storage:GetObject")
312-
.addResource("storage://test-bucket/*")
313-
.endStatement()
314-
.build();
315-
316-
List<Statement> statements = policy.getStatements();
317-
statements.clear();
318-
319-
// Original should be unaffected
320-
assertFalse(policy.getStatements().isEmpty());
321-
assertEquals(1, policy.getStatements().size());
322-
}
323306

324307
@Test
325308
public void testEndStatementWithoutCurrentStatement() {

iam/iam-client/src/test/java/com/salesforce/multicloudj/iam/model/StatementTest.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -303,33 +303,4 @@ public void testStatementToString() {
303303
assertTrue(result.contains("StringEquals"));
304304
}
305305

306-
@Test
307-
public void testGettersReturnImmutableCopies() {
308-
Statement.Builder builder = Statement.builder()
309-
.sid("TestStatement")
310-
.effect("Allow")
311-
.addAction("storage:GetObject")
312-
.addResource("storage://test-bucket/*")
313-
.addPrincipal("principal1")
314-
.addCondition("StringEquals", "aws:RequestedRegion", "us-west-2");
315-
316-
Statement statement = builder.build();
317-
318-
// Verify that modifying returned lists doesn't affect the original
319-
List<String> actions = statement.getActions();
320-
actions.clear();
321-
assertFalse(statement.getActions().isEmpty());
322-
323-
List<String> resources = statement.getResources();
324-
resources.clear();
325-
assertFalse(statement.getResources().isEmpty());
326-
327-
List<String> principals = statement.getPrincipals();
328-
principals.clear();
329-
assertFalse(statement.getPrincipals().isEmpty());
330-
331-
Map<String, Map<String, Object>> conditions = statement.getConditions();
332-
conditions.clear();
333-
assertFalse(statement.getConditions().isEmpty());
334-
}
335306
}

iam/iam-client/src/test/java/com/salesforce/multicloudj/iam/model/TrustConfigurationTest.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -230,23 +230,6 @@ public void testTrustConfigurationToString() {
230230
assertTrue(toString.contains("arn:aws:iam::123456789012:root"));
231231
}
232232

233-
@Test
234-
public void testTrustConfigurationImmutable() {
235-
TrustConfiguration trustConfig = TrustConfiguration.builder()
236-
.addTrustedPrincipal("arn:aws:iam::123456789012:root")
237-
.build();
238-
239-
List<String> principals = trustConfig.getTrustedPrincipals();
240-
Map<String, Map<String, Object>> conditions = trustConfig.getConditions();
241-
242-
// Modifying returned lists/maps should not affect the original
243-
principals.add("new-principal");
244-
conditions.put("NewOperator", Map.of("key", "value"));
245-
246-
// Original should remain unchanged
247-
assertEquals(1, trustConfig.getTrustedPrincipals().size());
248-
assertEquals(0, trustConfig.getConditions().size());
249-
}
250233

251234
@Test
252235
public void testTrustConfigurationEqualsAndHashCodeWithNullChecks() {

0 commit comments

Comments
 (0)