Skip to content

Simplify some equals statement by use Objects.equals#377

Merged
kkrugler merged 1 commit into
apache:mainfrom
PeterAlfredLee:simplify-equals
Nov 9, 2020
Merged

Simplify some equals statement by use Objects.equals#377
kkrugler merged 1 commit into
apache:mainfrom
PeterAlfredLee:simplify-equals

Conversation

@PeterAlfredLee
Copy link
Copy Markdown
Member

No description provided.

if (relativeSourceFilePath != null ? !relativeSourceFilePath.equals(that.relativeSourceFilePath) : that.relativeSourceFilePath != null)
return false;
return extractFile != null ? extractFile.equals(that.extractFile) : that.extractFile == null;
if (!Objects.equals(relativeSourceFilePath, that.relativeSourceFilePath)) return false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think Tika uses a "always braces" style, so this would be better as:

if (!blah) {
    return false;
} else {
    return Objects.equals(blah);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. And this is also the style I prefer. I made the if clause like this cause I want to have the same style as line 83, 84. Will modify all these 3 lines.

if (name != colInfo.name) return false;
if (precision != null ? !precision.equals(colInfo.precision) : colInfo.precision != null) return false;
return !(constraints != null ? !constraints.equals(colInfo.constraints) : colInfo.constraints != null);
if (!Objects.equals(precision, colInfo.precision)) return false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

if (tag != null ? !tag.equals(htmlTag.tag) : htmlTag.tag != null) return false;
return clazz != null ? clazz.equals(htmlTag.clazz) : htmlTag.clazz == null;
if (!Objects.equals(tag, htmlTag.tag)) return false;
return Objects.equals(clazz, htmlTag.clazz);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Copy link
Copy Markdown
Contributor

@kkrugler kkrugler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kkrugler kkrugler merged commit b417bf7 into apache:main Nov 9, 2020
@PeterAlfredLee PeterAlfredLee deleted the simplify-equals branch November 10, 2020 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants