class CaseConversionHelper {

  private CaseConversionHelper() {
  }

  /**
   * Converts case of the string token according to match element attributes.
   * @param s Token to be converted.
   * @param sample the sample string used to determine how the original string looks like (used only on case preservation)
   * @return Converted string.
   */
  public static String convertCase(Match.CaseConversion conversion, String s, String sample, Language lang) {<FILL_FUNCTION_BODY>}

}

    if (StringTools.isEmpty(s)) {
      return s;
    }
    String token = s;
    switch (conversion) {
      case NONE:
        break;
      case PRESERVE:
        if (StringTools.startsWithUppercase(sample)) {
          if (StringTools.isAllUppercase(sample)) {
            token = token.toUpperCase(Locale.ENGLISH);
          } else {
            token = StringTools.uppercaseFirstChar(token, lang);
          }
        }
        break;
      case STARTLOWER:
        token = token.substring(0, 1).toLowerCase() + token.substring(1);
        break;
      case STARTUPPER:
        token = StringTools.uppercaseFirstChar(token, lang);
        break;
      case ALLUPPER:
        token = token.toUpperCase(Locale.ENGLISH);
        break;
      case FIRSTUPPER:
        token = token.toLowerCase();
        token = StringTools.uppercaseFirstChar(token, lang);
        break;
      case ALLLOWER:
        token = token.toLowerCase();
        break;
      case NOTASHKEEL:
        token = StringTools.removeTashkeel(token);
        break;
      default:
        break;
    }
    return token;
  
<no_super_class>