diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-17 08:52:13 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-17 08:52:13 -0400 |
| commit | 7f59d0b9de4536705b3122cb5a85d9c9f85846a3 (patch) | |
| tree | 8aeed52ab4a18385f63dae2f51c792b88da669bb /BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java | |
| parent | 9d89261fedf23c11b684eb66cefdd86a9378ad20 (diff) | |
Add toString/equals/hashCode/compareTo part 1
Adds utility methods to classes that need them.
This covers the cli & component packages.
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java b/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java index 13132ed..b750848 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java +++ b/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java @@ -82,4 +82,52 @@ public class ComponentDescription implements IDescribedComponent { public String toString() { return name + " component v" + version + ", written by " + author; } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + result = prime * result + ((author == null) ? 0 : author.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + version; + + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if(this == obj) return true; + if(obj == null) return false; + if(getClass() != obj.getClass()) return false; + + ComponentDescription other = (ComponentDescription) obj; + + if(author == null) { + if(other.author != null) return false; + } else if(!author.equals(other.author)) return false; + + if(description == null) { + if(other.description != null) return false; + } else if(!description.equals(other.description)) return false; + + if(name == null) { + if(other.name != null) return false; + } else if(!name.equals(other.name)) return false; + + if(version != other.version) return false; + + return true; + } } |
