/*
 * Copyright (C) 2022 - Florindo Smilari (spherIC)
 */
package ch.spherIC.recurvebowsight.model.impl;

import java.text.DecimalFormat;
import java.util.Objects;

import ch.spherIC.recurvebowsight.model.IRiser;


/**
 * @author F. Smilari
 */
public class Riser implements IRiser {

    private static final DecimalFormat DF = new DecimalFormat("0.###");

    private long id;
    private String manufacturer;
    private String model;
    private Double size;
    private Double vVisH;
    private Double vVisV;

    /**
     * Konstruktor.
     *
     * @param id
     * @param maufacturer
     * @param model
     * @param size
     * @param vVisH
     * @param vVisV
     */
    public Riser(final long id, final String manufacturer, final String model, final Double size,
                 final Double vVisH, final Double vVisV) {
        super();
        this.id = id;
        this.manufacturer = manufacturer;
        this.model = model;
        this.size = size;
        this.vVisH = vVisH;
        this.vVisV = vVisV;
    }

    /**
     * @return the id
     */
    @Override
    public long getId() {
        return this.id;
    }

    /**
     * @param id the id to set
     */
    @Override
    public void setId(final long id) {
        this.id = id;
    }

    /**
     * @return the manufacturer
     */
    @Override
    public String getManufacturer() {
        return this.manufacturer;
    }

    /**
     * @param maufacturer the maufacturer to set
     */
    @Override
    public void setManufacturer(final String maufacturer) {
        this.manufacturer = maufacturer;
    }

    /**
     * @return the model
     */
    @Override
    public String getModel() {
        return this.model;
    }

    /**
     * @param model the model to set
     */
    @Override
    public void setModel(final String model) {
        this.model = model;
    }

    /**
     * @return the size
     */
    @Override
    public Double getSize() {
        return this.size;
    }

    /**
     * @param size the size to set
     */
    @Override
    public void setSize(final Double size) {
        this.size = size;
    }

    /**
     * @return the vVisH
     */
    @Override
    public Double getVVisH() {
        return this.vVisH;
    }

    /**
     * @param vVisH the vVisH to set
     */
    @Override
    public void setVVisH(final Double vVisH) {
        this.vVisH = vVisH;
    }

    /**
     * @return the vVisV
     */
    @Override
    public Double getVVisV() {
        return this.vVisV;
    }

    /**
     * @param vVisV the vVisV to set
     */
    @Override
    public void setVVisV(final Double vVisV) {
        this.vVisV = vVisV;
    }


    @Override
    public String toString() {
        if (this.id == -999) {
            return getManufacturer();
        }
        return getManufacturer() + " " + getModel() + " " + DF.format(getSize()) + "\"";
    }

    //TODO: equals and hashCode


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Riser riser = (Riser) o;
        return id == riser.id && manufacturer.equals(riser.manufacturer) && model.equals(riser.model);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, manufacturer, model);
    }
}
