Skip to content

Commit ba56561

Browse files
kunaljani1100vietj
authored andcommitted
Add javadocs for JsonUtil.compare.
1 parent 86b30d0 commit ba56561

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

vertx-core/src/main/java/io/vertx/core/json/impl/JsonUtil.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,27 @@ public static int hashCode(Object value) {
121121
}
122122
}
123123

124+
/**
125+
* Compares two objects to check if they are equal. This method handled the equality comparison
126+
* in the following order.
127+
*
128+
* <ol>
129+
* <li>Check if both the objects are numbers. If both the objects are numbers, then the
130+
* equality of numbers will be checked.</li>
131+
* <li>If both the numbers are of different types, both the objects will be cast to the
132+
* class {@code Numbers}, and then both the numbers are compared for equality.</li>
133+
* <li>If both the objects are of a {@code CharSequence} type, then both the objects
134+
* will be converted to strings to check for the equality of the string representation
135+
* of the objects.</li>
136+
* <li>Finally, if none of the objects are equal, then the objets are compared to each
137+
* other for equality. In this case, it is the responsibility of the developer to define
138+
* the {@code equals(Object o1, Object o2)} for the class they define.</li>
139+
* </ol>
140+
*
141+
* @param o1 The first object that will be compared.
142+
* @param o2 The second object that will be compared.
143+
* @return True, if the two objects are equal, false otherwise.
144+
*/
124145
public static boolean compare(Object o1, Object o2) {
125146
if (o1 instanceof Number && o2 instanceof Number) {
126147
if (o1.getClass() == o2.getClass()) {

0 commit comments

Comments
 (0)