/**
   * Sets a header parameter with the specified key and value.
   *
   * <p>If the key matches one of the reserved header parameter names, then the relevant
   * <tt>set</tt> method is called to set that header parameter with the specified value.
   *
   * @param key The key of the header parameter.
   * @param value The value of the header parameter.
   */
  public void setParameter(String key, Object value) {
    JwtHeaderKey headerKey = getHeaderKey(key.toUpperCase());

    switch (headerKey) {
      case TYP:
        {
          if (isValueOfType(value, JwtType.class)) {
            setType((JwtType) value);
          } else {
            checkValueIsOfType(value, String.class);
            setType(JwtType.jwtType((String) value));
          }
          break;
        }
      case ALG:
        {
          if (isValueOfType(value, Algorithm.class)) {
            setAlgorithm((Algorithm) value);
          } else {
            checkValueIsOfType(value, String.class);
            put(ALG.value(), value);
          }
          break;
        }
      default:
        {
          put(key, value);
        }
    }
  }
 /**
  * Gets the type of JWT this header represents.
  *
  * @return The JwtType.
  */
 public JwtType getType() {
   return JwtType.valueOf(get(TYP.value()).asString().toUpperCase());
 }
 /**
  * Sets the type of JWT this header represents.
  *
  * <p>For non-nested JWTs then the "JWT" type is RECOMMENDED to be used but it is OPTIONAL to set
  * the "typ" property. For nested signed or encrypted JWTs the JWT type MUST be "JWS" and "JWE"
  * respectively and the "typ" property MUST be set.
  *
  * @see JwtType
  * @param jwtType The JwtType.
  */
 public void setType(JwtType jwtType) {
   put(TYP.value(), jwtType.toString());
 }