Skip to content

Commit 1f5f223

Browse files
committed
Fixing checkstyle violations
1 parent 8b719d5 commit 1f5f223

File tree

3 files changed

+160
-139
lines changed

3 files changed

+160
-139
lines changed
Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.salesforce.multicloudj.iam.model;
22

3+
import java.util.Objects;
34
import lombok.Builder;
45
import lombok.Getter;
56

6-
import java.util.Objects;
7-
87
/**
98
* Optional configuration for identity creation operations.
109
*
@@ -27,32 +26,35 @@
2726
@Getter
2827
@Builder
2928
public class CreateOptions {
30-
private final String path;
31-
private final Integer maxSessionDuration;
32-
private final String permissionBoundary;
33-
29+
private final String path;
30+
private final Integer maxSessionDuration;
31+
private final String permissionBoundary;
3432

35-
@Override
36-
public boolean equals(Object o) {
37-
if (this == o) return true;
38-
if (o == null || getClass() != o.getClass()) return false;
39-
CreateOptions that = (CreateOptions) o;
40-
return Objects.equals(path, that.path) &&
41-
Objects.equals(maxSessionDuration, that.maxSessionDuration) &&
42-
Objects.equals(permissionBoundary, that.permissionBoundary);
33+
@Override
34+
public boolean equals(Object o) {
35+
if (this == o) {
36+
return true;
4337
}
44-
45-
@Override
46-
public int hashCode() {
47-
return Objects.hash(path, maxSessionDuration, permissionBoundary);
38+
if (o == null || getClass() != o.getClass()) {
39+
return false;
4840
}
41+
CreateOptions that = (CreateOptions) o;
42+
return Objects.equals(path, that.path)
43+
&& Objects.equals(maxSessionDuration, that.maxSessionDuration)
44+
&& Objects.equals(permissionBoundary, that.permissionBoundary);
45+
}
4946

50-
@Override
51-
public String toString() {
52-
return "CreateOptions{" +
53-
"path='" + path + '\'' +
54-
", maxSessionDuration=" + maxSessionDuration +
55-
", permissionBoundary='" + permissionBoundary + '\'' +
56-
'}';
57-
}
47+
@Override
48+
public int hashCode() {
49+
return Objects.hash(path, maxSessionDuration, permissionBoundary);
50+
}
51+
52+
@Override
53+
public String toString() {
54+
return "CreateOptions{"
55+
+ "path='" + path + '\''
56+
+ ", maxSessionDuration=" + maxSessionDuration
57+
+ ", permissionBoundary='" + permissionBoundary + '\''
58+
+ '}';
59+
}
5860
}
Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.salesforce.multicloudj.iam.model;
22

33
import com.salesforce.multicloudj.common.exceptions.InvalidArgumentException;
4+
import java.util.List;
5+
import java.util.Objects;
46
import lombok.Builder;
57
import lombok.Getter;
68
import lombok.Singular;
79

8-
import java.util.List;
9-
import java.util.Objects;
10-
1110
/**
1211
* Represents a substrate-neutral policy document containing multiple statements.
1312
*
@@ -33,50 +32,55 @@
3332
*/
3433
@Getter
3534
public class PolicyDocument {
36-
private final String version;
37-
private final List<Statement> statements;
38-
39-
@Builder
40-
private PolicyDocument(String version, @Singular List<Statement> statements) {
41-
// Validate version is provided
42-
if (version == null) {
43-
throw new InvalidArgumentException("Version is required");
44-
}
35+
private final String version;
36+
private final List<Statement> statements;
4537

46-
// Filter out null statements and validate at least one exists
47-
List<Statement> filteredStatements = statements != null
48-
? statements.stream().filter(Objects::nonNull).collect(java.util.stream.Collectors.toList())
49-
: new java.util.ArrayList<>();
38+
@Builder
39+
private PolicyDocument(String version, @Singular List<Statement> statements) {
40+
// Validate version is provided
41+
if (version == null) {
42+
throw new InvalidArgumentException("Version is required");
43+
}
5044

51-
if (filteredStatements.isEmpty()) {
52-
throw new InvalidArgumentException("At least one statement is required");
53-
}
45+
// Filter out null statements and validate at least one exists
46+
List<Statement> filteredStatements = statements != null
47+
? statements.stream().filter(Objects::nonNull)
48+
.collect(java.util.stream.Collectors.toList())
49+
: new java.util.ArrayList<>();
5450

55-
this.version = version;
56-
this.statements = filteredStatements;
51+
if (filteredStatements.isEmpty()) {
52+
throw new InvalidArgumentException("At least one statement is required");
5753
}
5854

55+
this.version = version;
56+
this.statements = filteredStatements;
57+
}
5958

6059

61-
@Override
62-
public boolean equals(Object o) {
63-
if (this == o) return true;
64-
if (o == null || getClass() != o.getClass()) return false;
65-
PolicyDocument that = (PolicyDocument) o;
66-
return Objects.equals(version, that.version) &&
67-
Objects.equals(statements, that.statements);
68-
}
6960

70-
@Override
71-
public int hashCode() {
72-
return Objects.hash(version, statements);
61+
@Override
62+
public boolean equals(Object o) {
63+
if (this == o) {
64+
return true;
7365
}
74-
75-
@Override
76-
public String toString() {
77-
return "PolicyDocument{" +
78-
"version='" + version + '\'' +
79-
", statements=" + statements +
80-
'}';
66+
if (o == null || getClass() != o.getClass()) {
67+
return false;
8168
}
69+
PolicyDocument that = (PolicyDocument) o;
70+
return Objects.equals(version, that.version)
71+
&& Objects.equals(statements, that.statements);
72+
}
73+
74+
@Override
75+
public int hashCode() {
76+
return Objects.hash(version, statements);
77+
}
78+
79+
@Override
80+
public String toString() {
81+
return "PolicyDocument{"
82+
+ "version='" + version + '\''
83+
+ ", statements=" + statements
84+
+ '}';
85+
}
8286
}
Lines changed: 89 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.salesforce.multicloudj.iam.model;
22

33
import com.salesforce.multicloudj.common.exceptions.InvalidArgumentException;
4-
import lombok.Builder;
5-
import lombok.Getter;
6-
import lombok.Singular;
7-
84
import java.util.List;
95
import java.util.Map;
106
import java.util.Objects;
7+
import lombok.Builder;
8+
import lombok.Getter;
9+
import lombok.Singular;
1110

1211
/**
1312
* Represents a single statement within a policy document.
@@ -30,89 +29,105 @@
3029
*/
3130
@Getter
3231
public class Statement {
33-
private final String sid;
34-
private final String effect;
35-
private final List<String> principals;
36-
private final List<String> actions;
37-
private final List<String> resources;
38-
private final Map<String, Map<String, Object>> conditions;
39-
40-
@Builder
41-
private Statement(String sid, String effect,
42-
@Singular List<String> principals,
43-
@Singular List<String> actions,
44-
@Singular List<String> resources,
45-
Map<String, Map<String, Object>> conditions) {
46-
// Validate effect
47-
if (effect == null || effect.trim().isEmpty()) {
48-
throw new InvalidArgumentException("Effect is required and cannot be empty");
49-
}
32+
private final String sid;
33+
private final String effect;
34+
private final List<String> principals;
35+
private final List<String> actions;
36+
private final List<String> resources;
37+
private final Map<String, Map<String, Object>> conditions;
5038

51-
// Filter out null/empty/whitespace values and validate actions
52-
this.sid = sid;
53-
this.effect = effect;
54-
this.principals = filterValidStrings(principals);
55-
this.actions = filterValidStrings(actions);
56-
this.resources = filterValidStrings(resources);
39+
@Builder
40+
private Statement(String sid, String effect,
41+
@Singular List<String> principals,
42+
@Singular List<String> actions,
43+
@Singular List<String> resources,
44+
Map<String, Map<String, Object>> conditions) {
45+
// Validate effect
46+
if (effect == null || effect.trim().isEmpty()) {
47+
throw new InvalidArgumentException("Effect is required and cannot be empty");
48+
}
5749

58-
// Validate that at least one action exists after filtering
59-
if (this.actions.isEmpty()) {
60-
throw new InvalidArgumentException("At least one action is required");
61-
}
50+
// Filter out null/empty/whitespace values and validate actions
51+
this.sid = sid;
52+
this.effect = effect;
53+
this.principals = filterValidStrings(principals);
54+
this.actions = filterValidStrings(actions);
55+
this.resources = filterValidStrings(resources);
6256

63-
this.conditions = conditions != null ? conditions : new java.util.HashMap<>();
57+
// Validate that at least one action exists after filtering
58+
if (this.actions.isEmpty()) {
59+
throw new InvalidArgumentException("At least one action is required");
6460
}
6561

66-
private static List<String> filterValidStrings(List<String> input) {
67-
if (input == null) {
68-
return new java.util.ArrayList<>();
69-
}
70-
return input.stream()
71-
.filter(s -> s != null && !s.trim().isEmpty())
72-
.collect(java.util.stream.Collectors.toList());
62+
this.conditions = conditions != null ? conditions : new java.util.HashMap<>();
63+
}
64+
65+
private static List<String> filterValidStrings(List<String> input) {
66+
if (input == null) {
67+
return new java.util.ArrayList<>();
7368
}
69+
return input.stream()
70+
.filter(s -> s != null && !s.trim().isEmpty())
71+
.collect(java.util.stream.Collectors.toList());
72+
}
7473

75-
public static class StatementBuilder {
76-
public StatementBuilder condition(String operator, String key, Object value) {
77-
if (operator != null && key != null && value != null) {
78-
if (this.conditions == null) {
79-
this.conditions = new java.util.HashMap<>();
80-
}
81-
this.conditions.computeIfAbsent(operator, k -> new java.util.HashMap<>()).put(key, value);
82-
}
83-
return this;
74+
/**
75+
* Custom builder for Statement to handle conditions.
76+
*/
77+
public static class StatementBuilder {
78+
/**
79+
* Adds a condition to the statement.
80+
*
81+
* @param operator the condition operator
82+
* @param key the condition key
83+
* @param value the condition value
84+
* @return this builder
85+
*/
86+
public StatementBuilder condition(String operator, String key, Object value) {
87+
if (operator != null && key != null && value != null) {
88+
if (this.conditions == null) {
89+
this.conditions = new java.util.HashMap<>();
8490
}
91+
this.conditions.computeIfAbsent(operator, k -> new java.util.HashMap<>())
92+
.put(key, value);
93+
}
94+
return this;
8595
}
96+
}
8697

8798

8899

89-
@Override
90-
public boolean equals(Object o) {
91-
if (this == o) return true;
92-
if (o == null || getClass() != o.getClass()) return false;
93-
Statement statement = (Statement) o;
94-
return Objects.equals(sid, statement.sid) &&
95-
Objects.equals(effect, statement.effect) &&
96-
Objects.equals(principals, statement.principals) &&
97-
Objects.equals(actions, statement.actions) &&
98-
Objects.equals(resources, statement.resources) &&
99-
Objects.equals(conditions, statement.conditions);
100+
@Override
101+
public boolean equals(Object o) {
102+
if (this == o) {
103+
return true;
100104
}
101-
102-
@Override
103-
public int hashCode() {
104-
return Objects.hash(sid, effect, principals, actions, resources, conditions);
105+
if (o == null || getClass() != o.getClass()) {
106+
return false;
105107
}
108+
Statement statement = (Statement) o;
109+
return Objects.equals(sid, statement.sid)
110+
&& Objects.equals(effect, statement.effect)
111+
&& Objects.equals(principals, statement.principals)
112+
&& Objects.equals(actions, statement.actions)
113+
&& Objects.equals(resources, statement.resources)
114+
&& Objects.equals(conditions, statement.conditions);
115+
}
106116

107-
@Override
108-
public String toString() {
109-
return "Statement{" +
110-
"sid='" + sid + '\'' +
111-
", effect='" + effect + '\'' +
112-
", principals=" + principals +
113-
", actions=" + actions +
114-
", resources=" + resources +
115-
", conditions=" + conditions +
116-
'}';
117-
}
117+
@Override
118+
public int hashCode() {
119+
return Objects.hash(sid, effect, principals, actions, resources, conditions);
120+
}
121+
122+
@Override
123+
public String toString() {
124+
return "Statement{"
125+
+ "sid='" + sid + '\''
126+
+ ", effect='" + effect + '\''
127+
+ ", principals=" + principals
128+
+ ", actions=" + actions
129+
+ ", resources=" + resources
130+
+ ", conditions=" + conditions
131+
+ '}';
132+
}
118133
}

0 commit comments

Comments
 (0)