Skip to content

Commit 0d3c80e

Browse files
Cleanup code
1 parent f04d70f commit 0d3c80e

5 files changed

Lines changed: 11 additions & 29 deletions

File tree

src/main/java/io/github/problem4j/core/DefaultProblem.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
package io.github.problem4j.core;
1818

19+
import static java.util.Collections.unmodifiableMap;
20+
1921
import java.io.Serializable;
2022
import java.net.URI;
21-
import java.util.Collections;
2223
import java.util.HashMap;
2324
import java.util.Map;
2425
import org.jspecify.annotations.Nullable;
@@ -76,7 +77,7 @@ public int getStatus() {
7677

7778
@Override
7879
public Map<String, Object> getExtensions() {
79-
return Collections.unmodifiableMap(extensions);
80+
return unmodifiableMap(extensions);
8081
}
8182

8283
@Override
@@ -87,8 +88,7 @@ public boolean equals(@Nullable Object obj) {
8788
if (!(obj instanceof Problem)) {
8889
return false;
8990
}
90-
Problem other = (Problem) obj;
91-
return ProblemSupport.equals(this, other);
91+
return ProblemSupport.equals(this, (Problem) obj);
9292
}
9393

9494
@Override
@@ -129,8 +129,7 @@ public boolean equals(@Nullable Object obj) {
129129
if (!(obj instanceof Problem.Extension)) {
130130
return false;
131131
}
132-
Problem.Extension other = (Problem.Extension) obj;
133-
return ProblemSupport.equals(this, other);
132+
return ProblemSupport.equals(this, (Problem.Extension) obj);
134133
}
135134

136135
@Override

src/main/java/io/github/problem4j/core/DefaultProblemContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
package io.github.problem4j.core;
1818

19+
import static java.util.Collections.unmodifiableMap;
20+
1921
import java.io.Serializable;
20-
import java.util.Collections;
2122
import java.util.HashMap;
2223
import java.util.Map;
2324
import org.jspecify.annotations.Nullable;
@@ -54,7 +55,7 @@ public ProblemContext put(String key, @Nullable String value) {
5455

5556
@Override
5657
public Map<String, String> toMap() {
57-
return Collections.unmodifiableMap(new HashMap<>(context));
58+
return unmodifiableMap(new HashMap<>(context));
5859
}
5960

6061
@Override
@@ -65,8 +66,7 @@ public boolean equals(@Nullable Object obj) {
6566
if (!(obj instanceof ProblemContext)) {
6667
return false;
6768
}
68-
ProblemContext other = (ProblemContext) obj;
69-
return ProblemSupport.equals(this, other);
69+
return ProblemSupport.equals(this, (ProblemContext) obj);
7070
}
7171

7272
@Override

src/main/java/io/github/problem4j/core/Problem.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@
3939
*
4040
* In addition, custom extensions can be added to provide extra context.
4141
*
42-
* <p>Use {@link ProblemSupport#equals(Problem, Problem)}, {@link ProblemSupport#hashCode(Problem)},
43-
* and {@link ProblemSupport#toString(Problem)} as the canonical reference implementations of these
44-
* methods.
45-
*
4642
* @since 1.3.0
4743
*/
4844
public interface Problem {
@@ -247,13 +243,6 @@ default ProblemBuilder toBuilder() {
247243
/**
248244
* Represents a single key-value extension in a {@link Problem}.
249245
*
250-
* <p><b>Well-known contracts:</b>
251-
*
252-
* <p>Use {@link ProblemSupport#equals(Problem.Extension, Problem.Extension)}, {@link
253-
* ProblemSupport#hashCode(Problem.Extension)}, and {@link
254-
* ProblemSupport#toString(Problem.Extension)} as the canonical reference implementations of these
255-
* methods.
256-
*
257246
* @since 1.3.0
258247
*/
259248
interface Extension {

src/main/java/io/github/problem4j/core/ProblemContext.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
* Context passed for problem processing. Used by {@link ProblemMapper}. Provides access to values
2424
* used for message interpolation or metadata enrichment.
2525
*
26-
* <p><b>Well-known contracts:</b>
27-
*
28-
* <p>Use {@link ProblemSupport#equals(ProblemContext, ProblemContext)}, {@link
29-
* ProblemSupport#hashCode(ProblemContext)}, and {@link ProblemSupport#toString(ProblemContext)} as
30-
* the canonical reference implementations of these methods.
31-
*
3226
* @since 1.3.0
3327
*/
3428
public interface ProblemContext {

src/test/java/io/github/problem4j/core/DefaultProblemBuilderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
import static io.github.problem4j.core.Problem.extension;
2020
import static java.util.Collections.emptyMap;
21+
import static java.util.Collections.singletonList;
2122
import static org.assertj.core.api.Assertions.assertThat;
2223
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2324

2425
import java.net.URI;
2526
import java.util.Arrays;
26-
import java.util.Collections;
2727
import java.util.HashMap;
2828
import java.util.Map;
2929
import java.util.Optional;
@@ -249,7 +249,7 @@ void givenExtensionSetThenUnsetViaCollection_shouldRemoveExtension() {
249249
Problem problem =
250250
newInstance()
251251
.extension("name", "Mark")
252-
.extensions(Collections.singletonList(Problem.extension("name", null)))
252+
.extensions(singletonList(Problem.extension("name", null)))
253253
.build();
254254

255255
assertThat(problem.getExtensions()).isEmpty();

0 commit comments

Comments
 (0)