package com.example.computers.entity;

import jakarta.persistence.*;
import java.util.List;

@Entity
@Table(name = "manufacturer")
public class Manufacturer {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;

    private String country;

    // Связь с компьютерами
    @OneToMany(mappedBy = "manufacturer")
    private List<Computer> computers;

    public Manufacturer() { }

    public Manufacturer(Long id, String name, String country) {
        this.id = id;
        this.name = name;
        this.country = country;
    }

    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

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

    public String getCountry() { return country; }
    public void setCountry(String country) { this.country = country; }

    public List<Computer> getComputers() { return computers; }
    public void setComputers(List<Computer> computers) { this.computers = computers; }

    @Override
    public String toString() {
        return name + " (" + country + ")";
    }
}