package edu.rutgers.css.Rutgers.api.bus.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import lombok.Data;

/**
 * Arrival time predictions for a bus stop.
 */
@Data
public final class Prediction implements Serializable {
    private String tag;
    private String title;
    private String direction;
    private List<Integer> minutes;
    
    public Prediction (String title, String tag) {
        this.tag = tag;
        this.title = title;
        minutes = new ArrayList<>();
    }
    
    public void addMinutes(int mins) { minutes.add(mins); }

    @Override
    public String toString() {
        return this.title + ", " + this.direction + ", " + this.minutes.toString();
    }

    /**
     * Compares two predictions by the route or stop they represent, but not the minute values.
     * @param other Prediction to be compared to
     * @return True if tag, title, and direction match. False if not.
     */
    @Override
    public boolean equals(Object other) {
        if (other == null) return false;
        if (!(other instanceof Prediction)) return false;

        if (this.getTag() == null || this.getTitle() == null) return false;

        Prediction otherPrediction = (Prediction) other;
        return  this.getTag().equals(otherPrediction.getTag()) &&
                this.getTitle().equals(otherPrediction.getTitle()) &&
                (
                        (otherPrediction.getDirection() == null && this.getDirection() == null) ||
                        (this.getDirection() != null && this.getDirection().equals(otherPrediction.getDirection()))
                );
    }

}

@@ -141,16 +141,49 @@
 ok.Data;
+%0Aimport lombok.EqualsAndHashCode;
 %0A%0A/**%0A *
@@ -234,16 +234,56 @@
 /%0A@Data%0A
+@EqualsAndHashCode(exclude = %22minutes%22)%0A
 public f
@@ -795,929 +795,12 @@
 ();%0A
+
     %7D%0A
-%0A    /**%0A     * Compares two predictions by the route or stop they represent, but not the minute values.%0A     * @param other Prediction to be compared to%0A     * @return True if tag, title, and direction match. False if not.%0A     */%0A    @Override%0A    public boolean equals(Object other) %7B%0A        if (other == null) return false;%0A        if (!(other instanceof Prediction)) return false;%0A%0A        if (this.getTag() == null %7C%7C this.getTitle() == null) return false;%0A%0A        Prediction otherPrediction = (Prediction) other;%0A        return  this.getTag().equals(otherPrediction.getTag()) &&%0A                this.getTitle().equals(otherPrediction.getTitle()) &&%0A                (%0A                        (otherPrediction.getDirection() == null && this.getDirection() == null) %7C%7C%0A                        (this.getDirection() != null && this.getDirection().equals(otherPrediction.getDirection()))%0A                );%0A    %7D%0A%0A
 %7D%0A

Add hashCode to prediction