Tostring Equals Hashcode with annotations
Java
Switch branches/tags
Nothing to show
Pull request Compare This branch is 1 commit ahead, 17 commits behind wokier:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
javadoc
src
.gitignore
README.markdown
TEH Tests.launch
pom.xml

README.markdown

TEH

TEH stands for __T__oString __E__quals __H__ashCode


TEH uses annotations to implement toString, equals and hashCode, and enforces these 2 rules

  • any attribute used for hashCode will be used for equals and toString
  • any attribute used for equals will be used for toString

The annotations are

  • @ToString
  • @ToStringEquals
  • @ToStringEqualsHashCode

You can activate TEH on a given class by 2 ways

inheritance

class MyTEHObject extends TEHObject{
...

annotation

@TEH
class MyTEHObject{
	public String toString() {
		return TEHUtils.toString(this);
	}

	public boolean equals(Object other) {
		return TEHUtils.equals(this, other);
	}

	public int hashCode() {
		return TEHUtils.hashCode(this);
	}
...