uk.gov.service.payments.commons.jpa.CardExpiryDateConverter Maven / Gradle / Ivy
package uk.gov.service.payments.commons.jpa;
import uk.gov.service.payments.commons.model.CardExpiryDate;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter
public class CardExpiryDateConverter implements AttributeConverter {
@Override
public String convertToDatabaseColumn(CardExpiryDate cardExpiryDate) {
if (cardExpiryDate == null) {
return null;
}
return cardExpiryDate.toString();
}
@Override
public CardExpiryDate convertToEntityAttribute(String cardExpiryDate) {
if (cardExpiryDate == null) {
return null;
}
return CardExpiryDate.valueOf(cardExpiryDate);
}
}