package leigh.astro.iraf;

import java.util.List;
import java.util.Objects;

public class StarInfo {
    private final double x;
    private final double y;
    private final double mag;
    private final double area;
    private final double hwhm;
    private final double round;
    private final double pa;
    private final double sharp;

    public StarInfo(double x, double y, double mag, double area, double hwhm, double round, double pa, double sharp) {
        this.x = x;
        this.y = y;
        this.mag = mag;
        this.area = area;
        this.hwhm = hwhm;
        this.round = round;
        this.pa = pa;
        this.sharp = sharp;
    }

    public StarInfo(List<String> lst) {
        this.x = Double.parseDouble(lst.get(0));
        this.y = Double.parseDouble(lst.get(1));
        this.mag = Double.parseDouble(lst.get(2));
        this.area = Double.parseDouble(lst.get(3));
        this.hwhm = Double.parseDouble(lst.get(4));
        this.round = Double.parseDouble(lst.get(5));
        this.pa = Double.parseDouble(lst.get(6));
        this.sharp = Double.parseDouble(lst.get(7));
    }

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    public double getMag() {
        return mag;
    }

    public double getArea() {
        return area;
    }

    public double getHwhm() {
        return hwhm;
    }

    public double getRound() {
        return round;
    }

    public double getPa() {
        return pa;
    }

    public double getSharp() {
        return sharp;
    }

    @Override
    public String toString() {
        return "StarInfo{" +
                "x=" + x +
                ", y=" + y +
                ", mag=" + mag +
                ", area=" + area +
                ", hwhm=" + hwhm +
                ", round=" + round +
                ", pa=" + pa +
                ", sharp=" + sharp +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        StarInfo starInfo = (StarInfo) o;
        return Double.compare(starInfo.x, x) == 0 &&
                Double.compare(starInfo.y, y) == 0 &&
                Double.compare(starInfo.mag, mag) == 0 &&
                Double.compare(starInfo.area, area) == 0 &&
                Double.compare(starInfo.hwhm, hwhm) == 0 &&
                Double.compare(starInfo.round, round) == 0 &&
                Double.compare(starInfo.pa, pa) == 0 &&
                Double.compare(starInfo.sharp, sharp) == 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y, mag, area, hwhm, round, pa, sharp);
    }
}
