-
-
Save dfparker2002/1d52dd26f46e6025269f148dc2a38b13 to your computer and use it in GitHub Desktop.
Eclipse Templates for Java logging, hashCode, equals, and toString with SLF4J and Guava
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Just download the template file and import it in your Eclipse IDE via Window/Preferences/Java/Editor/Templates -> Import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="java" deleted="false" description="equals (Guava)" enabled="true" name="equals">${:import(com.google.common.base.Objects)} | |
@Override | |
public boolean equals(final Object obj) { | |
if (this == obj) { | |
return true; | |
} | |
if (obj == null) { | |
return false; | |
} | |
if (getClass() != obj.getClass()) { | |
return false; | |
} | |
| |
final ${enclosing_type} other = (${enclosing_type}) obj; | |
return Objects.equal(this.${field}, other.${field}) | |
&& ${cursor}; | |
}</template><template autoinsert="true" context="java" deleted="false" description="hashCode (Guava)" enabled="true" name="hashCode">${:import(com.google.common.base.Objects)} | |
@Override | |
public int hashCode() { | |
return Objects.hashCode(this.${field}, ${cursor}); | |
}</template><template autoinsert="true" context="java" deleted="false" description="Logger Instantiation (SL4J)" enabled="true" name="log">${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)} | |
private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class); | |
</template><template autoinsert="true" context="java" deleted="false" description="toString (Guava)" enabled="true" name="toString">${:import(com.google.common.base.Objects)} | |
@Override | |
public String toString() { | |
return Objects.toStringHelper(this) | |
.add("${field}", this.${field}) | |
.add(${cursor}) | |
.tostring(); | |
}</template></templates> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment