package net.northking.cctp.common.s3;

public enum ContentType
{
  Application_Octet_Stream("application/octet-stream"),
  txt("text/plain"),
  xml("text/xml"),
  jpe("image/jpeg"),
  jpeg("image/jpeg"),
  jpg("image/jpeg"),
  gif("image/gif"),
  tif("image/tiff"),
  json("application/json"),
  pdf("application/pdf"),
  doc("application/msword"),
  docx("application/msword"),
  xls("application/vnd.ms-excel"),
  xlsx("application/vnd.ms-excel");


  private String code;

  ContentType(String code)
  {
    this.code = code;
  }

  public String getCode()
  {
    return code;
  }

  public static String findCode(String postfix)
  {
    String value = Application_Octet_Stream.getCode();
    if (postfix == null || "".equals(postfix))
    {
      return value;
    }

    for (ContentType type : values())
    {
      if (type.name().equalsIgnoreCase(postfix))
      {
        value = type.getCode();
        break;
      }
    }
    return value;
  }
}
