private static ContainerRequest ensureValidRequest(final ContainerRequest request)
        throws IllegalStateException {
      if (request.getMethod().equals("GET")) {
        throw new IllegalStateException(LocalizationMessages.FORM_PARAM_METHOD_ERROR());
      }

      if (!MediaTypes.typeEqual(
          MediaType.APPLICATION_FORM_URLENCODED_TYPE, request.getMediaType())) {
        throw new IllegalStateException(LocalizationMessages.FORM_PARAM_CONTENT_TYPE_ERROR());
      }
      return request;
    }
    private Form getFormParameters(ContainerRequest request) {
      if (MediaTypes.typeEqual(
          MediaType.APPLICATION_FORM_URLENCODED_TYPE, request.getMediaType())) {
        request.bufferEntity();
        Form form;
        if (decode) {
          form = request.readEntity(Form.class);
        } else {
          Annotation[] annotations = new Annotation[1];
          annotations[0] = encodedAnnotation;
          form = request.readEntity(Form.class, annotations);
        }

        return (form == null ? new Form() : form);
      } else {
        return new Form();
      }
    }