Skip to content

Simplify if statements #17785

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

Closed
wants to merge 2 commits into from
Closed
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 @@ -165,7 +165,7 @@ private boolean nullSafeEquals(Object o1, Object o2) {
if (o1 == o2) {
return true;
}
return o1 != null && o2 != null && o1.equals(o2);
return o1 != null && o1.equals(o2);
}

public static String nestedPrefix(String prefix, String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ public boolean matches(ConfigurationMetadata value) {
if (this.deprecation == null && itemMetadata.getDeprecation() != null) {
return false;
}
if (this.deprecation != null && !this.deprecation.equals(itemMetadata.getDeprecation())) {
return false;
}
return true;
return this.deprecation == null || this.deprecation.equals(itemMetadata.getDeprecation());
}

public MetadataItemCondition ofType(Class<?> dataType) {
Expand Down Expand Up @@ -342,10 +339,7 @@ public boolean matches(ItemHint value) {
if (this.value != null && !this.value.equals(valueHint.getValue())) {
return false;
}
if (this.description != null && !this.description.equals(valueHint.getDescription())) {
return false;
}
return true;
return this.description == null || this.description.equals(valueHint.getDescription());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,14 @@ public boolean equals(Object obj) {
return false;
}
if (this.script == null) {
if (other.script != null) {
return false;
}
return other.script == null;
}
else if (!this.script.equals(other.script)) {
return false;
}
else if (!equalContents(this.script, other.script)) {
return false;
else {
return equalContents(this.script, other.script);
}
return true;
}

private boolean equalContents(File one, File two) {
Expand All @@ -132,7 +129,7 @@ private boolean equalContents(File one, File two) {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.properties == null) ? 0 : this.properties.hashCode());
result = prime * result + this.properties.hashCode();
result = prime * result + ((this.script == null) ? 0 : this.script.hashCode());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,7 @@ public boolean equals(Object obj) {
return false;
}
MainClass other = (MainClass) obj;
if (!this.name.equals(other.name)) {
return false;
}
return true;
return this.name.equals(other.name);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ public Properties getData() {

@Override
public boolean canTransformResource(String resource) {
if (this.resource != null && this.resource.equalsIgnoreCase(resource)) {
return true;
}
return false;
return this.resource != null && this.resource.equalsIgnoreCase(resource);
}

@Override
Expand Down