I can only assume that this solution is not documented, but when checking the MimeType class MimeType there are two matching methods: match(MimeType) and match(String) . The second performs this task by creating a MimeType object from the string argument and then calling the first match method.
Thus, by implementing matching methods, you can compare with MimeType and String objects. This would not be possible by implementing the equals(Object) method. Of course, you could implement the equals method so that it can be compared with both MimeType and String , but that would break the contract specified in the equals documentation:
It is symmetrical: for any non-empty reference values ββx and y x.equals (y) should return true if and only if y.equals (x) returns true.
This will only work if String.equals(Object o) uses o.toString() for comparison, but the String doc states:
Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.
This way you can use equals only for comparison with another MimeType , and if you want to compare with String , you will have to return to the match(String) method.
And I think the reason not to implement equals in this class is just to support the method that you use for comparison, consistent across different objects for comparison.
source share