View Javadoc
1   package org.pojomatic.test;
2   
3   import org.pojomatic.Pojomatic;
4   import org.pojomatic.annotations.AutoProperty;
5   
6   /**
7    * Class where every instance is equal via {@link Pojomatic#equals(Object, Object)}, but never
8    * by {@code this.equals(other)}.
9    */
10  @AutoProperty
11  public class OnlyPojomaticEqual {
12    @SuppressWarnings("unused")
13    private final int number = 3;
14  
15    @Override
16    public boolean equals(Object obj) {
17      //cannot assert because only the unit under test should throw AssertionError
18      if (!Pojomatic.equals(this, obj)) {
19        throw new IllegalStateException("Invariant violated");
20      }
21      return false;
22    }
23  
24    @Override
25    public String toString() {
26      return "toString";
27    }
28  }