From bf800c95ca677992795a16dd02947ce1820b2af9 Mon Sep 17 00:00:00 2001 From: Brian Pellin Date: Wed, 9 Jun 2010 22:09:53 -0500 Subject: [PATCH] Drop .equals to fix entry deletion. --- src/com/keepassdroid/database/PwEntry.java | 16 -- src/com/keepassdroid/database/PwEntryV4.java | 146 ------------------ src/com/keepassdroid/database/PwGroupV4.java | 93 ----------- .../com/keepassdroid/tests/PwEntryTestV4.java | 2 + 4 files changed, 2 insertions(+), 255 deletions(-) diff --git a/src/com/keepassdroid/database/PwEntry.java b/src/com/keepassdroid/database/PwEntry.java index fd8abafe4..a9712aa3e 100644 --- a/src/com/keepassdroid/database/PwEntry.java +++ b/src/com/keepassdroid/database/PwEntry.java @@ -73,20 +73,4 @@ public abstract class PwEntry implements Cloneable { return false; } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PwEntry other = (PwEntry) obj; - if (imageId != other.imageId) - return false; - return true; - } - - - } diff --git a/src/com/keepassdroid/database/PwEntryV4.java b/src/com/keepassdroid/database/PwEntryV4.java index 17c1926ff..80d8b410f 100644 --- a/src/com/keepassdroid/database/PwEntryV4.java +++ b/src/com/keepassdroid/database/PwEntryV4.java @@ -65,52 +65,6 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { windowSeqPairs.put(key, value); } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + getOuterType().hashCode(); - result = prime - * result - + ((defaultSequence == null) ? 0 : defaultSequence - .hashCode()); - result = prime * result + (enabled ? 1231 : 1237); - result = prime * result - + (int) (obfuscationOptions ^ (obfuscationOptions >>> 32)); - result = prime - * result - + ((windowSeqPairs == null) ? 0 : windowSeqPairs.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; - AutoType other = (AutoType) obj; - if (!getOuterType().equals(other.getOuterType())) - return false; - if (defaultSequence == null) { - if (other.defaultSequence != null) - return false; - } else if (!defaultSequence.equals(other.defaultSequence)) - return false; - if (enabled != other.enabled) - return false; - if (obfuscationOptions != other.obfuscationOptions) - return false; - if (windowSeqPairs == null) { - if (other.windowSeqPairs != null) - return false; - } else if (!windowSeqPairs.equals(other.windowSeqPairs)) - return false; - return true; - } - private PwEntryV4 getOuterType() { return PwEntryV4.this; } @@ -317,104 +271,4 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger { return getString(STR_URL); } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - PwEntryV4 other = (PwEntryV4) obj; - if (additional == null) { - if (other.additional != null) - return false; - } else if (!additional.equals(other.additional)) - return false; - if (autoType == null) { - if (other.autoType != null) - return false; - } else if (!autoType.equals(other.autoType)) - return false; - if (backgroupColor == null) { - if (other.backgroupColor != null) - return false; - } else if (!backgroupColor.equals(other.backgroupColor)) - return false; - if (binaries == null) { - if (other.binaries != null) - return false; - } else if (!binaries.equals(other.binaries)) - return false; - if (creation == null) { - if (other.creation != null) - return false; - } else if (!creation.equals(other.creation)) - return false; - if (customIconUuid == null) { - if (other.customIconUuid != null) - return false; - } else if (!customIconUuid.equals(other.customIconUuid)) - return false; - if (expireDate == null) { - if (other.expireDate != null) - return false; - } else if (!expireDate.equals(other.expireDate)) - return false; - if (expires != other.expires) - return false; - if (foregroundColor == null) { - if (other.foregroundColor != null) - return false; - } else if (!foregroundColor.equals(other.foregroundColor)) - return false; - if (history == null) { - if (other.history != null) - return false; - } else if (!history.equals(other.history)) - return false; - if (lastAccess == null) { - if (other.lastAccess != null) - return false; - } else if (!lastAccess.equals(other.lastAccess)) - return false; - if (lastMod == null) { - if (other.lastMod != null) - return false; - } else if (!lastMod.equals(other.lastMod)) - return false; - if (overrideURL == null) { - if (other.overrideURL != null) - return false; - } else if (!overrideURL.equals(other.overrideURL)) - return false; - if (parent == null) { - if (other.parent != null) - return false; - } else if (!parent.equals(other.parent)) - return false; - if (parentGroupLastMod == null) { - if (other.parentGroupLastMod != null) - return false; - } else if (!parentGroupLastMod.equals(other.parentGroupLastMod)) - return false; - if (strings == null) { - if (other.strings != null) - return false; - } else if (!strings.equals(other.strings)) - return false; - if (url == null) { - if (other.url != null) - return false; - } else if (!url.equals(other.url)) - return false; - if (usageCount != other.usageCount) - return false; - if (uuid == null) { - if (other.uuid != null) - return false; - } else if (!uuid.equals(other.uuid)) - return false; - return true; - } } diff --git a/src/com/keepassdroid/database/PwGroupV4.java b/src/com/keepassdroid/database/PwGroupV4.java index 862338c45..a92f6a43f 100644 --- a/src/com/keepassdroid/database/PwGroupV4.java +++ b/src/com/keepassdroid/database/PwGroupV4.java @@ -190,97 +190,4 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger { expires = exp; } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PwGroupV4 other = (PwGroupV4) obj; - if (creation == null) { - if (other.creation != null) - return false; - } else if (!creation.equals(other.creation)) - return false; - if (customIconUuid == null) { - if (other.customIconUuid != null) - return false; - } else if (!customIconUuid.equals(other.customIconUuid)) - return false; - if (defaultAutoTypeSequence == null) { - if (other.defaultAutoTypeSequence != null) - return false; - } else if (!defaultAutoTypeSequence - .equals(other.defaultAutoTypeSequence)) - return false; - if (enableAutoType == null) { - if (other.enableAutoType != null) - return false; - } else if (!enableAutoType.equals(other.enableAutoType)) - return false; - if (enableSearching == null) { - if (other.enableSearching != null) - return false; - } else if (!enableSearching.equals(other.enableSearching)) - return false; - if (expireDate == null) { - if (other.expireDate != null) - return false; - } else if (!expireDate.equals(other.expireDate)) - return false; - if (expires != other.expires) - return false; - if (iconId != other.iconId) - return false; - if (isExpanded != other.isExpanded) - return false; - if (lastAccess == null) { - if (other.lastAccess != null) - return false; - } else if (!lastAccess.equals(other.lastAccess)) - return false; - if (lastMod == null) { - if (other.lastMod != null) - return false; - } else if (!lastMod.equals(other.lastMod)) - return false; - if (lastTopVisibleEntry == null) { - if (other.lastTopVisibleEntry != null) - return false; - } else if (!lastTopVisibleEntry.equals(other.lastTopVisibleEntry)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (notes == null) { - if (other.notes != null) - return false; - } else if (!notes.equals(other.notes)) - return false; - if (parent == null) { - if (other.parent != null) - return false; - } else if (!parent.equals(other.parent)) - return false; - if (parentGroupLastMod == null) { - if (other.parentGroupLastMod != null) - return false; - } else if (!parentGroupLastMod.equals(other.parentGroupLastMod)) - return false; - if (usageCount != other.usageCount) - return false; - if (uuid == null) { - if (other.uuid != null) - return false; - } else if (!uuid.equals(other.uuid)) - return false; - return true; - } - - - } diff --git a/tests/src/com/keepassdroid/tests/PwEntryTestV4.java b/tests/src/com/keepassdroid/tests/PwEntryTestV4.java index 63d20c188..cfbf5c9a0 100644 --- a/tests/src/com/keepassdroid/tests/PwEntryTestV4.java +++ b/tests/src/com/keepassdroid/tests/PwEntryTestV4.java @@ -53,7 +53,9 @@ public class PwEntryTestV4 extends TestCase { PwEntryV4 target = new PwEntryV4(); target.assign(entry); + /* This test is not so useful now that I am not implementing value equality for Entries assertTrue("Entries do not match.", entry.equals(target)); + */ }