JAXB2 HashCode Plugin (original) (raw)

HashCode plugin

HashCode plugin generates hashCode(...) methods:

public class PurchaseOrderType implements HashCode //, ...

// ...    
public int hashCode() {
    final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE;
    return this.hashCode(null, strategy);
}


public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) {
    int currentHashCode = 1;
    {
        USAddress theShipTo;
        theShipTo = this.getShipTo();
        currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "shipTo", theShipTo), currentHashCode, theShipTo);
    }
    {
        USAddress theBillTo;
        theBillTo = this.getBillTo();
        currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "billTo", theBillTo), currentHashCode, theBillTo);
    }
    // ...
    return currentHashCode;
}
// ...

}

Generated methods allow you to specify a custom hash code strategy (hash code strategy).

Activation

Use the -XhashCode argument to activate the plugin.

Configuration

By default, generated code uses :

You can specify class name of your custom strategy using the -XhashCode-hashCodeStrategyClass argument:

-XhashCode-hashCodeStrategyClass=com.acme.foo.CustomHashCodeStrategy

Add a custom footer