Class CountryConverter

java.lang.Object
com.endurancetrio.data.competitor.model.converter.CountryConverter
All Implemented Interfaces:
jakarta.persistence.AttributeConverter<Country,String>

public class CountryConverter extends Object implements jakarta.persistence.AttributeConverter<Country,String>
The CountryConverter class is responsible for converting the Country enum to its corresponding database column representation and vice versa.

This converter is used to persist the Country enum as a string in the database. It converts the enum to its NOC code when storing it in the database and converts the code back to the enum when retrieving it from the database.

  • Constructor Details

    • CountryConverter

      public CountryConverter()
  • Method Details

    • convertToDatabaseColumn

      public String convertToDatabaseColumn(Country country)
      Specified by:
      convertToDatabaseColumn in interface jakarta.persistence.AttributeConverter<Country,String>
    • convertToEntityAttribute

      public Country convertToEntityAttribute(String code)
      Specified by:
      convertToEntityAttribute in interface jakarta.persistence.AttributeConverter<Country,String>