dev@jsr311.java.net

RE: Re: Issue 1: Adding additional conneg metadata to _at_Produce/ConsumeXXX

From: Larry Cable <lcable_at_bea.com>
Date: Fri, 18 May 2007 16:08:11 -0700

although I think it is stretching/breaking the meaning of an enumeration and introducing these constants as enums may make their usage harder rather than simpler actually we could ala:
 
public enum Language {
     EN("en"),
     // ...
     FR("fr");
 
     private Language(final String l) { language = l;}
 
     public boolean equals(Object o) { return language.equals(o); }
 
     public int hashCode() { return language.hashCode(); }
 
     public String toString() { return language.toString(); }
 
     private final String language;
}
 
likewise:
 
public enum MediaType {
    public final static String APPLICATION = "APPLICATION";
    // ...
 
   APPLICATION_XML(APPLICATION, XML),
   // ...
   APPLICATION_TEXT(TEXT, PLAIN);
 
   private MediaType(String t, String st) { type = t; subtype = st; }
 
   public boolean equals(Object o) {
       // ...
   }
 
   public int hashCode() {
      // ...
   }
 
   public String toString() {
      return type + "/" + subtype;
   }
 
   public String getType() { return type; }
   public String getSubtype() { return subType; }
 
   private final String type;
   private final String subtype;
}
 
the problem I see with that is that if we did not provide a rich enough set of values in the enum a developer would
be forced to extend that set by inheritance ... so maybe just simple string constants will be enough
 
- Larry

________________________________

From: Dhanji R. Prasanna [mailto:dhanji_at_gmail.com]
Sent: Fri 5/18/2007 3:22 PM
To: dev_at_jsr311.dev.java.net
Subject: Re: Issue 1: Adding additional conneg metadata to @Produce/ConsumeXXX




On 5/18/07, Larry Cable <lcable_at_bea.com> wrote:



        @ProduceXXX(value=APPLICATION_XML, language=EN)


+1 on the constant reference-safety. I wish there were a way to use enums here. too =(

Dhanji.


Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.