equals(Object)

hashCode()

toString()

java.lang.Object

Introduction-To-Pojomatic

@AutoProperty public class Item { @Property(policy=PojomaticPolicy.EQUALS_TO_STRING) private long id = 0; private String description = ""; @Property(policy=PojomaticPolicy.NONE) private transient int transientData; @Override public boolean equals(Object o) { return Pojomatic.equals(this, o); } @Override public int hashCode() { return Pojomatic.hashCode(this); } @Override public String toString() { return Pojomatic.toString(this); } // Constructors, Setters & Getters... }

equals()

hashCode()

toString()

@AutoProperty

The auto detect policy indicates whether FIELD s or METHOD s should be searched for properties to take into account. The search can also be disabled with NONE . By default, the FIELD s are searched for.

s or s should be searched for properties to take into account. The search can also be disabled with . By default, the s are searched for. The default Pojomatic policy which indicates whether the properties are going to be included in equals() , hashCode() and toString() . By default, the policy is set to ALL . Other values are: EQUALS , EQUALS_TO_STRING , HASHCODE_EQUALS , NONE , TO_STRING .

@Property

The name, which identifies the property in toString() .

. The policy, which is very similar to the default Pojomatic policy, but at the field/method level. It can take the same values, plus one: DEFAULT , which means 'the class level policy' (or ALL if none is defined).

Item item = new Item(); item.setDescription("Blue furniture"); item.setId(123456); item.setTransientData(9999); System.out.println("equals : " + item.equals(new Object())); System.out.println("hashCode : " + item.hashCode()); System.out.println("toString : " + item.toString());

equals : false hashCode : -2089463829 toString : Item{id: {123456}, description: {Blue furniture}}

a feature to control formatting in toString()

a mean to prevent a subclass from overridding equals()

Assuming B extends A, but you don't want an instance of B to be equal to an instance of A ever, there is a mean to notify Pojomatic

Assuming B extends A, and you would like to retrieve the difference in terms of properties used to compute equals() , Pojomatic.diff (...)

, One can retrieve the Pojomator used to compute equals() , hashCode() and toString() ; it also contains an interesting isCompatibleForEquality() method to check whether another class can be used in equals()

From the website itself: "This is best described with an example (available on Github , in thedirectory):Notice thatandare overriden to call Pojomatic.Theannotation enables Pojomatic on an class. It has two optional properties:The class level configuration can also be overridden at the field (or method) level with theannotation. It also has two properties The following:Generates the following output:Pojomatic also offers: