Repository: assertj/assertj

Problem statement:
Must AbstractAssert#equals  throw UnsupportedOperationException
#### Summary
@joel-costigliola Is it necessary for the `AbstractAssert#equals` to throw the `UnsupportedOperationException`?
This is against the contract of `Object#equals` and brakes other libraries which are not handling this. I know that it should be the deal of the libraries, if they can handle this error but this situation is absolutely not obvious. Is is possible, to change this?

In fact, currently it breaks the coroutines of Kotlin.

#### Example

```java
org.assertj.core.api.AbstractAssert

  /**
   * {@inheritDoc}
   *
   * @deprecated use {@link #isEqualTo} instead
   *
   * @throws UnsupportedOperationException if this method is called.
   */
  @Override
  @Deprecated
  public boolean equals(Object obj) {
    throw new UnsupportedOperationException("'equals' is not supported...maybe you intended to call 'isEqualTo'");
  }

```

#### Java 8 specific ?

* YES : create Pull Request from the `master` branch
* NO  : create Pull Request from the `2.x` branch





Hints:
This is done to avoid misusing the API like that: 
```java
// BAD
assertThat(actual).equals(expected);

// GOOD
assertThat(actual).isEqualTo(expected);
``` 
`*Assert` are not meant to be compared, what is the concrete use case for that (I don't know what coroutines are) ? is it Kotlin specific ?
Ok, I understand the reason why you added the exception to the method. From this point of view it is useful to prevent the user to use the `equals`-method unintentionally.

The problem itself is in a kotlin library. When a lambda is used like the following

```
doSomething {
    assertThat(foo).isNull()
}
```

the `isNull` itself returns again the `...AbstractAsserter`. When the lambda can handle return values, this `....AbstractAsserter` is returned to the caller. 
In this case, the `coroutines` library does some magic under the hood. One step in the magic is to compare the result with the last result `thisone.equals(lastone)` and here the problem happens, because the equals throws an exception which the library doesn't handles.
I know that this is the problem of the library, but as I said, IMO breaking the contract of `equals` isn't the best way to do. 


Patch:
diff --git a/src/main/java/org/assertj/core/api/AbstractAssert.java b/src/main/java/org/assertj/core/api/AbstractAssert.java
--- a/src/main/java/org/assertj/core/api/AbstractAssert.java
+++ b/src/main/java/org/assertj/core/api/AbstractAssert.java
@@ -50,6 +50,9 @@
  */
 public abstract class AbstractAssert<SELF extends AbstractAssert<SELF, ACTUAL>, ACTUAL> implements Assert<SELF, ACTUAL> {
 
+  // https://github.com/joel-costigliola/assertj-core/issues/1128
+  public static boolean throwUnsupportedExceptionOnEquals = true;
+
   private static final String ORG_ASSERTJ = "org.assert";
 
   @VisibleForTesting
@@ -540,7 +543,10 @@ public SELF withRepresentation(Representation representation) {
   @Override
   @Deprecated
   public boolean equals(Object obj) {
-    throw new UnsupportedOperationException("'equals' is not supported...maybe you intended to call 'isEqualTo'");
+    if (throwUnsupportedExceptionOnEquals) {
+      throw new UnsupportedOperationException("'equals' is not supported...maybe you intended to call 'isEqualTo'");
+    }
+    return super.equals(obj);
   }
 
   /**


Test patch:
diff --git a/src/test/java/org/assertj/core/api/abstract_/AbstractAssert_equal_hashCode_Test.java b/src/test/java/org/assertj/core/api/abstract_/AbstractAssert_equal_hashCode_Test.java
--- a/src/test/java/org/assertj/core/api/abstract_/AbstractAssert_equal_hashCode_Test.java
+++ b/src/test/java/org/assertj/core/api/abstract_/AbstractAssert_equal_hashCode_Test.java
@@ -41,9 +41,17 @@ public void should_fail_because_not_supported_operation() {
     assertions.equals("anotherString");
   }
 
+  @Test
+  @SuppressWarnings("deprecation")
+  public void should_not_fail_when_equals_exceptions_is_deactivated() {
+    AbstractAssert.throwUnsupportedExceptionOnEquals = false;
+    assertions.equals("anotherString");
+  }
+
+
   @Test
   public void shouldReturnOneAsHashCode() {
     assertThat(assertions.hashCode()).isEqualTo(1);
   }
 
-}
\ No newline at end of file
+}