1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
28
28
* @author Brian Clozel
29
29
* @since 6.0
30
30
*/
31
- public class JavaSerializationHint implements ConditionalHint {
31
+ public final class JavaSerializationHint implements ConditionalHint {
32
32
33
33
private final TypeReference type ;
34
34
35
35
@ Nullable
36
36
private final TypeReference reachableType ;
37
37
38
+
38
39
JavaSerializationHint (Builder builder ) {
39
40
this .type = builder .type ;
40
41
this .reachableType = builder .reachableType ;
41
42
}
42
43
44
+
43
45
/**
44
- * Return the {@link TypeReference type} that needs to be serialized using
45
- * Java serialization at runtime.
46
+ * Return the {@link TypeReference type} that needs to be serialized using Java serialization at runtime.
46
47
* @return a {@link Serializable} type
47
48
*/
48
49
public TypeReference getType () {
@@ -56,16 +57,9 @@ public TypeReference getReachableType() {
56
57
}
57
58
58
59
@ Override
59
- public boolean equals (@ Nullable Object o ) {
60
- if (this == o ) {
61
- return true ;
62
- }
63
- if (o == null || getClass () != o .getClass ()) {
64
- return false ;
65
- }
66
- JavaSerializationHint that = (JavaSerializationHint ) o ;
67
- return this .type .equals (that .type )
68
- && Objects .equals (this .reachableType , that .reachableType );
60
+ public boolean equals (@ Nullable Object other ) {
61
+ return (this == other || (other instanceof JavaSerializationHint that &&
62
+ this .type .equals (that .type ) && Objects .equals (this .reachableType , that .reachableType )));
69
63
}
70
64
71
65
@ Override
@@ -84,16 +78,13 @@ public static class Builder {
84
78
@ Nullable
85
79
private TypeReference reachableType ;
86
80
87
-
88
81
Builder (TypeReference type ) {
89
82
this .type = type ;
90
83
}
91
84
92
85
/**
93
- * Make this hint conditional on the fact that the specified type
94
- * can be resolved.
95
- * @param reachableType the type that should be reachable for this
96
- * hint to apply
86
+ * Make this hint conditional on the fact that the specified type can be resolved.
87
+ * @param reachableType the type that should be reachable for this hint to apply
97
88
* @return {@code this}, to facilitate method chaining
98
89
*/
99
90
public Builder onReachableType (TypeReference reachableType ) {
@@ -108,6 +99,6 @@ public Builder onReachableType(TypeReference reachableType) {
108
99
JavaSerializationHint build () {
109
100
return new JavaSerializationHint (this );
110
101
}
111
-
112
102
}
103
+
113
104
}
0 commit comments