Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I changed my mind to use the reflective approach because of the performance issue. Now I'm using the <a href="http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/builder/EqualsBuilder.html" rel="nofollow"><code>EqualsBuilder</code></a> and the <a href="http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/builder/HashCodeBuilder.html" rel="nofollow"><code>HashCodeBuilder</code></a> utilities of the Apache commons project (Thanks for the suggestions and feedback), because they hides the complexity of the methods. For quick generation of the <code>#equals</code> and <code>#hashCode</code> method I use the <a href="http://fast-code.sourceforge.net/" rel="nofollow">Fast Code Eclipse plugin</a> with a customized code template:</p> <hr> <pre><code>&lt;template type="EQUALS_AND_HASHCODE_METHOD"&gt; &lt;variation&gt;&lt;/variation&gt; &lt;variation-field&gt;&lt;/variation-field&gt; &lt;allow-multiple-variation&gt;&lt;/allow-multiple-variation&gt; &lt;class-pattern&gt;&lt;/class-pattern&gt; &lt;allowed-file-extensions&gt;java&lt;/allowed-file-extensions&gt; &lt;number-required-classes&gt;1&lt;/number-required-classes&gt; &lt;description&gt;Generates the equals and hashCode method with EqualsBuilder and HashCodeBuilder&lt;/description&gt; &lt;template-body&gt; &lt;![CDATA[ @Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } ${class_name} rhs = (${class_name}) obj; return new EqualsBuilder().appendSuper(super.equals(obj)) #foreach ($field in ${fields}) .append(${field.name}, rhs.${field.name}) #end .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(17, 37).appendSuper(super.hashCode()) #foreach ($field in ${fields}) .append(${field.name}) #end .toHashCode(); } ]]&gt; &lt;/template-body&gt; &lt;/template&gt; </code></pre> <p>I'm using Fast Code plugin because it's able to grap all fields of a selected class. But I'm not happy with the usability of the plugin. It would be nice if eclipse code templating engine would be able to do that too. If anyone knows a similar plugin, then let me know please!</p> <p>Cheers, Kevin</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload