package ru.kirillius.pf.sdn.entity;

import jakarta.persistence.*;
import lombok.*;
import ru.kirillius.pf.sdn.api.Networking.IPv4Subnet;

import java.util.List;

@Entity
@Table(name = "as_cache_entry")
@Getter
@Setter
@NoArgsConstructor
@Builder
@AllArgsConstructor
public class AutonomousSystemCacheEntry {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false, unique = true)
    private int number;

    @ElementCollection
    @CollectionTable(name = "as_cache_entry_prefixes", joinColumns = @JoinColumn(name = "entry_id"))
    @Column(name = "prefix", nullable = false)
    @Convert(converter = IPv4SubnetConverter.class)
    private List<IPv4Subnet> prefixes;

}
