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?
Request clarification before answering.
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'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.