package com.uca.data_validation;


import java.util.regex.Pattern;


public final class IdentifierValidator {

  private static final Pattern companyPrefixRegex = Pattern.compile("^[A-Z]\\d|\\d[A-Z]|[A-Z]{2}$");
  private static final Pattern cityIdRegex        = Pattern.compile("^[A-Z]{3}$");
  private static final Pattern airportIdRegex     = Pattern.compile("^[A-Z]{3}$");
  private static final Pattern flightIdRegex      = Pattern.compile("^([A-Z]\\d|\\d[A-Z]|[A-Z]{2})(\\d{3})$");


  public static boolean isCompanyPrefixValid(String companyPrefix) {
    return companyPrefix != null && companyPrefixRegex.matcher(companyPrefix).matches();
  }


  public static boolean isCityIdValid(String cityId) {
    return cityId != null && cityIdRegex.matcher(cityId).matches();
  }


  public static boolean isAirportIdValid(String airportId) {
    return airportId != null && airportIdRegex.matcher(airportId).matches();
  }


  public static boolean isFlightIdValid(String flightId) {
    return flightId != null && flightIdRegex.matcher(flightId).matches();
  }

}
