QueryParam binding with enum in jersey

From the Javadoc, the @QueryParam annotated type must either:

  1. Be a primitive type
  2. Have a constructor that accepts a single String argument
  3. Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String))
  4. Be List<T>, Set<T> or SortedSet<T>, where T satisfies 2 or 3 above. The resulting collection is read-only.

For your case I would go with the second option by wrapping the enum in a simple class:

public class StatusList {
  private List<STATUS> statusList;

  public StatusList(String toParse) {
    //code to split the parameter into a list of statuses 
  }

  public List<STATUS> getStatusList() {
    return this.statusList;
  }
}

Then change your method to:

@GET
public Resource resource(@QueryParam("status") StatusList statusList){
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)