users@jersey.java.net

[Jersey] Response.getStatus() and code readability

From: cowwoc <cowwoc_at_bbs.darktech.org>
Date: Fri, 08 Nov 2013 15:44:27 -0500

Hi,

I noticed Jersey 2.0 moved from returning an enum Status to returning an
int code. Can you please explain the reasoning and suggest a way to use
switch() statements on response codes while keeping things readable? In
Jersey 1.0 I used to do:

ClientResponse response = ...;
switch (response.getStatus())
{
   case OK: doThis(); break;
   case NOT_FOUND: doThat(); break;
   // etc...
}

and it was quite readable. I am afraid that

Response response = ...;
switch (response.getStatus())
{
   case 200: doThis(); break;
   case 404: doThat(); break;
   // etc...
}

is a lot less readable (requiring me to remember what each code means).

Thanks,
Gili