Coder Social home page Coder Social logo

Comments (10)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
Example:
class Product {
  public enum Condition{NEW, USED, BROKEN};

  @Key("condition")
  public Condition condition;
}

Original comment by [email protected] on 26 Aug 2010 at 6:06

  • Added labels: ****
  • Removed labels: ****

from google-api-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
Problem is that we would also need to define how it gets serialized/parsed.  
For example if we wanted <condition>new</condition> to map to/from 
condition.NEW.

Another problem is that if the server adds another supported value like 
"excellent" it would break the parser.

The current best practice is to simply use String.

But I can also see the user-friendliness of supporting Java enums.  Note that 
it may be useful for both JSON and XML.

Original comment by [email protected] on 26 Aug 2010 at 6:27

  • Added labels: ****
  • Removed labels: ****

from google-api-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
For seralization/parsing, we could possibly use the @Key annotation on enum 
values, e.g.:

public enum Condition {
  @Key("new") NEW,
  @Key("used") USED,
  @Key("broken") BROKEN
}

For the case where a value is added on the server, throwing an exception seems 
like a reasonable behavior.  Anyway, chances are that even if a String is used, 
the application like only know how to handle the set of values specified, and 
won't operate correctly if it encounters a new value.  Also, application 
writers will have a choice of enum vs. String and will be best able to make the 
trade-off between usability and flexibility.

Original comment by [email protected] on 20 Oct 2010 at 6:39

  • Added labels: Priority-Medium
  • Removed labels: Priority-Low

from google-api-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024

Original comment by [email protected] on 12 Nov 2010 at 1:59

  • Added labels: Milestone-Version1.3.0
  • Removed labels: Usability

from google-api-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024

Original comment by [email protected] on 8 Jan 2011 at 6:23

  • Added labels: Component-Util
  • Removed labels: ****

from google-api-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024

Original comment by [email protected] on 15 Feb 2011 at 8:30

  • Added labels: Milestone-Version1.4.0
  • Removed labels: Milestone-Version1.3.0

from google-api-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024

Original comment by [email protected] on 11 Mar 2011 at 12:13

  • Added labels: Priority-High
  • Removed labels: Priority-Medium

from google-api-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024

Original comment by [email protected] on 21 Apr 2011 at 4:02

  • Changed state: Started
  • Added labels: ****
  • Removed labels: ****

from google-api-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
http://codereview.appspot.com/4437045

Original comment by [email protected] on 27 Apr 2011 at 1:02

  • Added labels: ****
  • Removed labels: ****

from google-api-java-client.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024

Original comment by [email protected] on 2 May 2011 at 5:57

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****

from google-api-java-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.