[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/rlwing/java_upgrade/master/src/main/java/optional/Product.java [Back]  [Original]

package optional;

import java.util.Objects;

public class Product {
    private Integer id;
    private String name;
    private double price;

    public Product(Integer id, String name, double price) {
        System.out.println("Inside Product constructor with id=" + id);
        this.id = id;
        this.name = name;
        this.price = price;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Product{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", price=" + price +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Product product = (Product) o;
        return Double.compare(product.price, price) == 0 &&
                Objects.equals(id, product.id) &&
                Objects.equals(name, product.name);
    }

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

Web Proxy Viewer  |  New URL  |  Original Page