<?php

namespace App\Entity;

use App\Repository\EnergieRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Ignore;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ORM\Entity(repositoryClass=EnergieRepository::class)
 * @ORM\Table(schema="sav")
 */
class Energie
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api"})
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=5, nullable=true)
     * @Groups({"api"})
     */
    private $libelle_court;

    /**
     * @ORM\Column(type="string", length=30)
     * @Groups({"api"})
     */
    private $libelle_long;

    /**
     * @ORM\Column(type="boolean")
     */
    private $affichage_tablette;

    /**
     * @ORM\OneToMany(targetEntity=Equipement::class, mappedBy="energie")
     * @Ignore()
     */
    private $equipements;

    /**
     * @ORM\ManyToOne(targetEntity=TypeEnergie::class, inversedBy="energies")
     * @ORM\JoinColumn(name="idtype_energie")
     * @Groups({"api"})
     */
    private $type_energie;

    public function __construct()
    {
        $this->equipements = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function setId(?int $id): self
    {
        $this->id = $id;

        return $this;
    }

    public function getLibelleCourt(): ?string
    {
        return $this->libelle_court;
    }

    public function setLibelleCourt(?string $libelle_court): self
    {
        $this->libelle_court = $libelle_court;

        return $this;
    }

    public function getLibelleLong(): ?string
    {
        return $this->libelle_long;
    }

    public function setLibelleLong(string $libelle_long): self
    {
        $this->libelle_long = $libelle_long;

        return $this;
    }

    public function getAffichageTablette(): ?bool
    {
        return $this->affichage_tablette;
    }

    public function setAffichageTablette(bool $affichage_tablette): self
    {
        $this->affichage_tablette = $affichage_tablette;

        return $this;
    }

    /**
     * @return Collection<int, Equipement>
     */
    public function getEquipements(): Collection
    {
        return $this->equipements;
    }

    public function addEquipement(Equipement $equipement): self
    {
        if (!$this->equipements->contains($equipement)) {
            $this->equipements[] = $equipement;
            $equipement->setEnergie($this);
        }

        return $this;
    }

    public function removeEquipement(Equipement $equipement): self
    {
        if ($this->equipements->removeElement($equipement)) {
            // set the owning side to null (unless already changed)
            if ($equipement->getEnergie() === $this) {
                $equipement->setEnergie(null);
            }
        }

        return $this;
    }

    public function getTypeEnergie(): ?TypeEnergie
    {
        return $this->type_energie;
    }

    public function setTypeEnergie(?TypeEnergie $type_energie): self
    {
        $this->type_energie = $type_energie;

        return $this;
    }
}
