Using enumeration in Java as an alternative to a small database

I have a Java application that uses the Country class. Business logic connects every country in the world:

  • Iso code.
  • Telephone Phone Code
  • A list of TZ database time zone identifiers suitable for this country.

Usually this data is ideal for a database. However, given the fact that this data is quite stable (of course, it changes from time to time, but it is usually not used to create / update / delete operations in these records). I was thinking about putting information into a list, like this:

public enum Country
{

   US(1,new String[]{"America\New York","America\California",...}),

   ...

   NL(31, new String[]{"Europe\Amsterdam"});

    ...

    public Country(int telephoneCode, String[] timezoneIds)
    {
       ...
    }
}

Possible benefits of this approach:

  • Data is directly accessible from Java source code, so there is no delay when querying the database.
  • - ( , JDBC)

:

  • , .
  • , . (. .)
  • "" ( 200 ) ?

( № 3), .

Locale java, , java-. , . . ?

+4
2

. , , . , .

, , ( ), , - №2, № 3. , , . , , , ? script .

, , , . - - . , ​​ MySQL. , ​​ h2 Apache Derby.


, :

ISO 3611-1 ( ) 17 2007 . 2,4 .

+3

Enum: , .

:

+1

All Articles