package xyz.danielcortes.framework;

import java.time.Year;
import javax.persistence.AttributeConverter;

public class YearAttributeConverter implements AttributeConverter<Year, Integer> {


  @Override
  public Integer convertToDatabaseColumn(Year year) {
    if (year != null)
      return year.getValue();
    else
      return null;
  }

  @Override
  public Year convertToEntityAttribute(Integer integer) {
    if (integer != null)
      return Year.of(integer);
    else
      return null;
  }
}
