Skip to content
Snippets Groups Projects
Commit b63cf96a authored by a.croix's avatar a.croix
Browse files

End fix SpotBugs issues

parent 8479d573
No related branches found
No related tags found
No related merge requests found
Pipeline #1501 passed
package be.cylab.java.roc;
import java.util.Objects;
/**
* Class to represent element.
*/
......@@ -10,7 +12,8 @@ public class Point implements Comparable<Point> {
/**
* Constructor for Point.
* @param score double
*
* @param score double
* @param true_alert boolean
*/
public Point(final double score, final boolean true_alert) {
......@@ -29,8 +32,32 @@ public class Point implements Comparable<Point> {
}
}
/**
* @param o
* @return
*/
public final boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Point)) {
return false;
}
Point p = (Point) o;
return score == p.score;
}
/**
* @return
*/
public final int hashCode() {
return Objects.hash(score, true_alert);
}
/**
* Setter for Score.
*
* @param score
*/
public final void setScore(final double score) {
......@@ -42,6 +69,7 @@ public class Point implements Comparable<Point> {
/**
* Setter for True Alert.
*
* @param true_alert
*/
public final void setTrueAlert(final boolean true_alert) {
......@@ -50,6 +78,7 @@ public class Point implements Comparable<Point> {
/**
* Getter for Score.
*
* @return
*/
public final double getScore() {
......@@ -58,6 +87,7 @@ public class Point implements Comparable<Point> {
/**
* Getter for True Alert.
*
* @return
*/
public final boolean isTrueAlert() {
......
......@@ -49,28 +49,28 @@ public class Roc {
*/
public Roc(final String file_path) {
points = new ArrayList<>();
CSVReader reader = null;
CSVReader reader;
try {
reader = new CSVReader(new InputStreamReader(
new FileInputStream(file_path), StandardCharsets.UTF_8));
String[] next_record = null;
while (true) {
try {
next_record = reader.readNext();
if (!(next_record != null)) {
break;
}
} catch (IOException e) {
e.printStackTrace();
}
Point point = new Point(Double.parseDouble(next_record[0]),
Boolean.parseBoolean(next_record[1]));
points.add(point);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
String[] next_record = null;
while (true) {
try {
next_record = reader.readNext();
if (!(next_record != null)) {
break;
}
} catch (IOException e) {
e.printStackTrace();
}
Point point = new Point(Double.parseDouble(next_record[0]),
Boolean.parseBoolean(next_record[1]));
points.add(point);
}
Collections.sort(points);
positive_examples_number = Utils.countPositiveExamples(this.points);
negative_examples_number = Utils.countNegativeExamples(this.points);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment