I have created a class with 2 fields. A Double and a Line2D. I want to override the equals method so that the following code return true
public class Main {
    public static void main(String[] args) {
        StatusLinePair slp1 = new StatusLinePair(25.0, new Line2D.Double(123.0, 32.0, 342.0, 54.0));  
        StatusLinePair slp2 = new StatusLinePair(25.0, new Line2D.Double(123.0, 32.0, 342.0, 54.0));
        System.out.println(slp1.equals(slp2));
    }
}
This is what I've tried but I am still not getting the desired results
public class StatusLinePair {
    public Double yAxisOrder;
    public Line2D line;
    public StatusLinePair(Double yAxisOrder, Line2D line) {
        this.yAxisOrder = yAxisOrder;
        this.line = line;
    }
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((line == null) ? 0 : line.hashCode());
        result = prime * result + ((yAxisOrder == null) ? 0 : yAxisOrder.hashCode());
        return result;
    }
    @Override
    public boolean equals(Object obj) {
        StatusLinePair other = (StatusLinePair) obj;
        if (this.yAxisOrder == other.yAxisOrder && this.line.getX1() == other.line.getX1()
                && this.line.getX2() == other.line.getX2() && this.line.getY1() == other.line.getY1()
                && this.line.getY2() == other.line.getY2())
            return true;        
        return false;
    }
}
Please help me. Thanks in advance!
 
     
     
     
     
    