X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbits%2FCellAttributes.java;h=d1aea2cfded151f64b7fab265f48e328afa1ebd7;hb=e826b451baf0d1e66d09ce03a6fefee2eb8386f5;hp=a3d912cc433805c2a771af156732bc06fe999d7d;hpb=2b9c27db318b916730aa04f2b41bd3bff795a5dc;p=fanfix.git diff --git a/src/jexer/bits/CellAttributes.java b/src/jexer/bits/CellAttributes.java index a3d912c..d1aea2c 100644 --- a/src/jexer/bits/CellAttributes.java +++ b/src/jexer/bits/CellAttributes.java @@ -242,12 +242,32 @@ public class CellAttributes { && (backColor == that.backColor)); } + /** + * Hashcode uses all fields in equals(). + * + * @return the hash + */ + @Override + public int hashCode() { + int A = 13; + int B = 23; + int hash = A; + hash = (B * hash) + (bold ? 1 : 0); + hash = (B * hash) + (blink ? 1 : 0); + hash = (B * hash) + (underline ? 1 : 0); + hash = (B * hash) + (reverse ? 1 : 0); + hash = (B * hash) + (protect ? 1 : 0); + hash = (B * hash) + foreColor.hashCode(); + hash = (B * hash) + backColor.hashCode(); + return hash; + } + /** * Set my field values to that's field. * * @param rhs another CellAttributes instance */ - public void setTo(Object rhs) { + public void setTo(final Object rhs) { CellAttributes that = (CellAttributes) rhs; this.bold = that.bold;