Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7711071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:17:02+00:00 2026-06-01T01:17:02+00:00

For converting a integer into an enum (out of a json file), I declared

  • 0

For converting a integer into an enum (out of a json file), I declared some HashMaps like this:

final static HashMap<Integer, Types> getType = new HashMap<Integer, Types>() {
    {
        put(1, Types.TYPE1);
        put(2, Types.TYPE2);
        ....
    }
};

Now eclipse gives me the following warning:

The serializable class  does not declare a static final serialVersionUID field of type long

I already found a pretty good explanation for the error message here. However I don’t know how this is with GWT. Does GWT use the SerialVersionUID anywhere, or is it actually deleted by the closur compiler? As far as I see it, it isn’t needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:17:03+00:00Added an answer on June 1, 2026 at 1:17 am

    serialVersionUID is only used for Java serialization (using the JVM Serializable contract), which is (quite obviously) not supported in GWT.

    That means you can safely ignore the warning; and you can also safely add a serialVersionUID to appease Eclipse, as it’ll be pruned by the compiler.
    (I believe you could also configure Eclipse so it doesn’t generate the warning)

    Also, you shouldn’t initialze your HashMap that way (that is, create an anonymous subclass of HashMap that initializes itself in its initializer). You’d better use a static initializer:

    final static Map<Integer, Types> getType;
    static {
       getType = new HashMap<Integer, types>();
       getType.put(1, Types.TYPE1);
       getType.put(2, Types.TYPE2);
       ...
       // you could even use Collections.unmodifiableMap here
    }
    

    or use Guava’s ImmutableMap:
    final static Map getType = ImmutableMap.builder()
    .put(1, Types.TYPE1)
    .put(1, Types.TYPE2)
    …
    .build();

    Better yet, if your integer values map with the enum constants’ declaration order, you can simply use Enum#values() instead of map:

    Types typeFromInt(int i) {
       return Types.values()[i];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an efficient method of converting an integer into the written numbers, for
How does C handle converting between integers and characters? Say you've declared an integer
I'm having trouble converting a string into a double. My string has been declared
In C++ I have only seen this done by converting the string object into
I would like an elegant, efficient means of taking any unsigned integer and converting
I'd like to know a good solution for converting a LEFT JOIN into a
I want to know the method of converting an integer into char/string and vice-versa
I have the following code for converting the integer(a score) into the character and
I'm having a problem with converting a formatted date string into a integer timestamp.
Any have any good code for converting a IPv6 address string into an integer?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.