From 5832ef0286430d04484b70d49c73e081a80ec9c7 Mon Sep 17 00:00:00 2001 From: bjculkin Date: Fri, 17 Mar 2017 19:28:59 -0400 Subject: Add more toString/hashCode/equals --- .../src/main/java/bjc/utils/data/ListHolder.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java b/BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java index 84ea01d..f460941 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java @@ -71,4 +71,40 @@ public class ListHolder implements IHolder { public UnwrappedType unwrap(Function unwrapper) { return unwrapper.apply(heldValues.randItem()); } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + + builder.append("ListHolder [heldValues="); + builder.append(heldValues); + builder.append("]"); + + return builder.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + result = prime * result + ((heldValues == null) ? 0 : heldValues.hashCode()); + + return result; + } + + @Override + public boolean equals(Object obj) { + if(this == obj) return true; + if(obj == null) return false; + if(getClass() != obj.getClass()) return false; + + ListHolder other = (ListHolder) obj; + + if(heldValues == null) { + if(other.heldValues != null) return false; + } else if(!heldValues.equals(other.heldValues)) return false; + + return true; + } } -- cgit v1.2.3