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

use java 7 and 8 features #755

Merged
merged 1 commit into from
Apr 15, 2020
Merged
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
@@ -1,6 +1,7 @@
package org.pitest.mutationtest;

import java.io.Serializable;
import java.util.Objects;

import org.pitest.classinfo.ClassName;
import org.pitest.classinfo.HierarchicalClassId;
Expand Down Expand Up @@ -31,41 +32,19 @@ public ClassName getName() {

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result)
+ ((this.coverageId == null) ? 0 : this.coverageId.hashCode());
result = (prime * result) + ((this.id == null) ? 0 : this.id.hashCode());
return result;
return Objects.hash(id, coverageId);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final ClassHistory other = (ClassHistory) obj;
if (this.coverageId == null) {
if (other.coverageId != null) {
return false;
}
} else if (!this.coverageId.equals(other.coverageId)) {
return false;
}
if (this.id == null) {
if (other.id != null) {
return false;
}
} else if (!this.id.equals(other.id)) {
return false;
}
return true;
return Objects.equals(id, other.id)
&& Objects.equals(coverageId, other.coverageId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;

import org.pitest.classinfo.ClassName;

Expand Down Expand Up @@ -40,33 +41,19 @@ public String getPackageName() {

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result)
+ ((this.mutations == null) ? 0 : this.mutations.hashCode());
return result;
return Objects.hash(mutations);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final ClassMutationResults other = (ClassMutationResults) obj;
if (this.mutations == null) {
if (other.mutations != null) {
return false;
}
} else if (!this.mutations.equals(other.mutations)) {
return false;
}
return true;
return Objects.equals(mutations, other.mutations);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

import org.pitest.classinfo.ClassName;

Expand All @@ -35,7 +35,7 @@ public Collection<MutationResult> getMutations() {
}

public Collection<ClassMutationResults> toClassResults() {
Collections.sort(this.mutations, comparator());
this.mutations.sort(comparator());
final List<ClassMutationResults> cmrs = new ArrayList<>();
final List<MutationResult> buffer = new ArrayList<>();
ClassName cn = null;
Expand All @@ -55,38 +55,23 @@ public Collection<ClassMutationResults> toClassResults() {
}

private static Comparator<MutationResult> comparator() {
return (arg0, arg1) -> arg0.getDetails().getId().compareTo(arg1.getDetails().getId());
return Comparator.comparing(arg0 -> arg0.getDetails().getId());
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result)
+ ((this.mutations == null) ? 0 : this.mutations.hashCode());
return result;
return Objects.hash(mutations);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final MutationMetaData other = (MutationMetaData) obj;
if (this.mutations == null) {
if (other.mutations != null) {
return false;
}
} else if (!this.mutations.equals(other.mutations)) {
return false;
}
return true;
return Objects.equals(mutations, other.mutations);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.pitest.mutationtest;

import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.pitest.mutationtest.engine.MutationDetails;

Expand Down Expand Up @@ -67,42 +68,20 @@ public String getKillingTestDescription() {

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result)
+ ((this.details == null) ? 0 : this.details.hashCode());
result = (prime * result)
+ ((this.status == null) ? 0 : this.status.hashCode());
return result;
return Objects.hash(details, status);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final MutationResult other = (MutationResult) obj;
if (this.details == null) {
if (other.details != null) {
return false;
}
} else if (!this.details.equals(other.details)) {
return false;
}
if (this.status == null) {
if (other.status != null) {
return false;
}
} else if (!this.status.equals(other.status)) {
return false;
}
return true;
return Objects.equals(details, other.details)
&& Objects.equals(status, other.status);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.pitest.mutationtest.build.intercept.javafeatures;

import java.util.Objects;

public class LineMutatorPair {

private final int lineNumber;
Expand All @@ -12,37 +14,19 @@ public LineMutatorPair(final int lineNumber, final String mutator) {

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result) + this.lineNumber;
result = (prime * result)
+ ((this.mutator == null) ? 0 : this.mutator.hashCode());
return result;
return Objects.hash(lineNumber, mutator);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final LineMutatorPair other = (LineMutatorPair) obj;
if (this.lineNumber != other.lineNumber) {
return false;
}
if (this.mutator == null) {
if (other.mutator != null) {
return false;
}
} else if (!this.mutator.equals(other.mutator)) {
return false;
}
return true;
return lineNumber == other.lineNumber
&& Objects.equals(mutator, other.mutator);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,32 @@

import org.objectweb.asm.tree.AbstractInsnNode;

import java.util.Objects;

class Loc {
int index;
AbstractInsnNode node;

@Override
public String toString() {
return "[" + this.index + "] " + this.node;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result) + this.index;
result = (prime * result) + ((this.node == null) ? 0 : this.node.hashCode());
return result;
return Objects.hash(index, node);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final Loc other = (Loc) obj;
if (this.index != other.index) {
return false;
}
if (this.node == null) {
if (other.node != null) {
return false;
}
} else if (!this.node.equals(other.node)) {
return false;
}
return true;
return index == other.index
&& Objects.equals(node, other.node);
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.pitest.mutationtest.report.html;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class PackageSummaryData implements Comparable<PackageSummaryData> {

Expand Down Expand Up @@ -50,39 +50,25 @@ public String getPackageDirectory() {
public List<MutationTestSummaryData> getSummaryData() {
final ArrayList<MutationTestSummaryData> values = new ArrayList<>(
this.fileNameToSummaryData.values());
Collections.sort(values, new MutationTestSummaryDataFileNameComparator());
values.sort(new MutationTestSummaryDataFileNameComparator());
return values;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result)
+ ((this.packageName == null) ? 0 : this.packageName.hashCode());
return result;
return Objects.hash(packageName);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final PackageSummaryData other = (PackageSummaryData) obj;
if (this.packageName == null) {
if (other.packageName != null) {
return false;
}
} else if (!this.packageName.equals(other.packageName)) {
return false;
}
return true;
return Objects.equals(packageName, other.packageName);
}

@Override
Expand Down
Loading