class DateRangeAndType {

  public static DateRangeAndType fromValues(LocalDate startDate, LocalDate endDate,
      ReportDefinitionDateRangeType type) {
    if (startDate != null && endDate != null) {
      // Overwrite type to custom if start date & end date are provided.
      return new DateRangeAndType(startDate, endDate, ReportDefinitionDateRangeType.CUSTOM_DATE);
    } else if (type != null && type != ReportDefinitionDateRangeType.CUSTOM_DATE) {
      // Overwrite the provided start/end date if type is custom.
      return parseEnumFormat(type);
    } else {
      throw new IllegalArgumentException(
          "Must provide either: 'startDate' and 'endData', or 'type'.");
      }
  }

  private  DateRangeAndType(
      LocalDate startDate, LocalDate endDate, ReportDefinitionDateRangeType type);

}