package com.sleekbyte.tailor.output;

/**
 * Note: this class has a natural ordering that is inconsistent with equals.
 */
public class ViolationMessage implements Comparable<ViolationMessage> {

    public static final ViolationMessage EMPTY = new ViolationMessage("", 0, 0, "", "");

    private String filePath;
    private int lineNumber;
    private int columnNumber;
    private String classification;
    private String violationMessage;

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public void setLineNumber(int lineNumber) {
        this.lineNumber = lineNumber;
    }

    public void setColumnNumber(int columnNumber) {
        this.columnNumber = columnNumber;
    }

    public void setClassification(String classification) {
        this.classification = classification;
    }

    public void setViolationMessage(String violationMessage) {
        this.violationMessage = violationMessage;
    }

    public ViolationMessage() {

    }

    public ViolationMessage(String filePath, int lineNumber, int columnNumber, String classification,
                            String violationMessage) {
        this.filePath = filePath;
        this.lineNumber = lineNumber;
        this.columnNumber = columnNumber;
        this.classification = classification;
        this.violationMessage = violationMessage;
    }

    @Override
    public int compareTo(final ViolationMessage message) {
        int ret = this.lineNumber - message.lineNumber;
        if (ret == 0) {
            ret = this.columnNumber - message.columnNumber;
        }
        return ret;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || this.getClass() != o.getClass()) { return false; }

        ViolationMessage that = (ViolationMessage) o;

        // Test primitives (int) for equality first, then objects (String)
        return (this.lineNumber == that.lineNumber)
            && (this.columnNumber == that.columnNumber)
            && (this.filePath.equals(that.filePath))
            && (this.classification.equals(that.classification))
            && (this.violationMessage.equals(that.violationMessage));
    }

    @Override
    public String toString() {
        // filePath, classification, violationMessage are optional in the output, but at least one must be present
        if (this.filePath.isEmpty() && this.classification.isEmpty() && this.violationMessage.isEmpty()) { return ""; }

        if (this.columnNumber == 0) {
            return String.format("%s:%d: %s: %s", this.filePath, this.lineNumber, this.classification,
                this.violationMessage);
        }
        return String.format("%s:%d:%d: %s: %s", this.filePath, this.lineNumber, this.columnNumber, this.classification,
            this.violationMessage);
    }

}

@@ -1721,55 +1721,41 @@
 if (
-o == null %7C%7C this.getClass() != o.getClass()) %7B
+!(o instanceof ViolationMessage))
  ret
@@ -1764,18 +1764,16 @@
 n false;
- %7D
 %0A%0A      
@@ -1791,19 +1791,30 @@
 Message 
-tha
+candidateObjec
 t = (Vio
@@ -1942,19 +1942,30 @@
 mber == 
-tha
+candidateObjec
 t.lineNu
@@ -2007,19 +2007,30 @@
 mber == 
-tha
+candidateObjec
 t.column
@@ -2074,19 +2074,30 @@
 .equals(
-tha
+candidateObjec
 t.filePa
@@ -2144,19 +2144,30 @@
 .equals(
-tha
+candidateObjec
 t.classi
@@ -2222,19 +2222,30 @@
 .equals(
-tha
+candidateObjec
 t.violat

Use instanceof check