cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic enum and Static enum - Storage

06-02-2019 3:51 PM
6199 views 3 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hi guys, Dynamic enums contains valueOf(final String code) method and getting enum value from cache.get(key)

valueOf method definiton is:

 public static PaymentStatus valueOf(final String code)
     {
         final String key = code.toLowerCase();
         PaymentStatus result = cache.get(key);
         if (result == null)
         {
             PaymentStatus newValue = new PaymentStatus(code);
             PaymentStatus previous = cache.putIfAbsent(key, newValue);
             result = previous != null ? previous : newValue;
         }
         return result;
     }


and cache definition is:

 private static final ConcurrentMap<String, PaymentStatus> cache = new ConcurrentHashMap<String, PaymentStatus>();

Why static enums does not contains valueOf method? According to this, can we say?

  • -Dynamic enums are stored in java classes.

  • -Static enums are stored in database.

Where are they stored?

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

arvind-kumar_avinash
Active Contributor

Hi - whether it is static enum (no enumeration values can be created at runtime; they can only be created at initialization or update via items.xml) or dynamic enum (new enumeration values can be created at runtime), the values are stored in the database itself. You can verify it by using the following FS Query:

 SELECT * FROM {enumerationvalue}

Assuming you have the following definition of an enum in the items.xml:

 <enumtype code="MyEnum" dynamic="true" generate="true" autocreate="false" >
        <value code="new1"/>
        <value code="new2"/>
 </enumtype>

you can create new values using the following ImpEx:

 INSERT MyEnum;code[unique=true]
 ;new3

and then you can execute the following FS Query to get this new value from the database:

 SELECT * FROM {enumerationvalue} WHERE {code}='new3'
Former Member
0 Likes

Very good explanation. Thank you so much .

arvind-kumar_avinash
Active Contributor
0 Likes

You are most welcome.

Answers (0)