users@jersey.java.net

[Jersey] Re: Response.getStatus() and code readability

From: Miles, Eric (CONT) <"Miles,>
Date: Mon, 11 Nov 2013 08:07:33 -0500

javax.ws.rs.core.Response.Status is the enum you're looking for

Also look at Response.getStatusInfo()

Eric Miles






On 11/8/13 3:44 PM, "cowwoc" <cowwoc_at_bbs.darktech.org> wrote:

>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

________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.