Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code quality fix - "equals(Object obj)" and "hashCode()" should be overridden in pairs. #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,29 @@ public WebElement findElement(SearchContext context) {
public int hashCode() {
return toString().hashCode();
}


@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
ByAttribute other = (ByAttribute) obj;
if (attribute == null) {
if (other.attribute != null)
return false;
} else if (!attribute.equals(other.attribute))
return false;
if (word == null) {
if (other.word != null)
return false;
} else if (!word.equals(other.word))
return false;
return true;
}

@Override
public String toString() {
return "ByAttribute(\"" + attribute + "\"): " + word;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,34 @@ public WebElement findElement(SearchContext context) {
return ((FindsByXPath) context).findElementByXPath(".//*["
+ attributeContains(attribute, word) + "]");
}

@Override
public int hashCode() {
return toString().hashCode();
}


@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
ByPartialAttribute other = (ByPartialAttribute) obj;
if (attribute == null) {
if (other.attribute != null)
return false;
} else if (!attribute.equals(other.attribute))
return false;
if (word == null) {
if (other.word != null)
return false;
} else if (!word.equals(other.word))
return false;
return true;
}

@Override
public String toString() {
return "ByPartialAttribute(\"" + attribute + "\"): " + word;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,29 @@ public WebElement findElement(SearchContext context) {
return ((FindsByXPath) context).findElementByXPath(".//*["
+ textContains(text) + "]");
}

@Override
public int hashCode() {
return toString().hashCode();
}


@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
ByPartialVisibleText other = (ByPartialVisibleText) obj;
if (text == null) {
if (other.text != null)
return false;
} else if (!text.equals(other.text))
return false;
return true;
}

@Override
public String toString() {
return "ByPartialVisibleText: " + text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,29 @@ public WebElement findElement(SearchContext context) {
return ((FindsByXPath) context).findElementByXPath(".//*["
+ textContainsIgnoringCase(text) + "]");
}

@Override
public int hashCode() {
return toString().hashCode();
}


@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
ByPartialVisibleTextIgnoreCase other = (ByPartialVisibleTextIgnoreCase) obj;
if (text == null) {
if (other.text != null)
return false;
} else if (!text.equals(other.text))
return false;
return true;
}

@Override
public String toString() {
return "ByPartialVisibleTextIgnoreCase: " + text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,34 @@ public List<WebElement> findElements(SearchContext context) {

return result;
}

@Override
public int hashCode() {
return toString().hashCode();
}


@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
ByVisibleText other = (ByVisibleText) obj;
if (byPartialVisibleText == null) {
if (other.byPartialVisibleText != null)
return false;
} else if (!byPartialVisibleText.equals(other.byPartialVisibleText))
return false;
if (text == null) {
if (other.text != null)
return false;
} else if (!text.equals(other.text))
return false;
return true;
}

@Override
public String toString() {
return "ByVisibleText: " + text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,35 @@ public List<WebElement> findElements(SearchContext context) {

return result;
}

@Override
public int hashCode() {
return toString().hashCode();
}


@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
ByVisibleTextIgnoreCase other = (ByVisibleTextIgnoreCase) obj;
if (byPartialVisibleTextIgnoreCase == null) {
if (other.byPartialVisibleTextIgnoreCase != null)
return false;
} else if (!byPartialVisibleTextIgnoreCase
.equals(other.byPartialVisibleTextIgnoreCase))
return false;
if (text == null) {
if (other.text != null)
return false;
} else if (!text.equals(other.text))
return false;
return true;
}

@Override
public String toString() {
return "ByVisibleTextIgnoreCase: " + text;
Expand Down