package ru.kirillius.pf.sdn.entity;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import ru.kirillius.pf.sdn.api.Networking.IPv4Subnet;

@Converter
public class IPv4SubnetConverter implements AttributeConverter<IPv4Subnet, String> {

    @Override
    public String convertToDatabaseColumn(IPv4Subnet attribute) {
        return attribute == null ? null : attribute.toString();
    }

    @Override
    public IPv4Subnet convertToEntityAttribute(String dbData) {
        return dbData == null ? null : new IPv4Subnet(dbData);
    }
}
