diff --git a/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationInteger.java b/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationInteger.java index e319b68d6..11f0d200a 100644 --- a/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationInteger.java +++ b/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationInteger.java @@ -22,6 +22,8 @@ */ import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * Integer-based enumeration type. @@ -39,5 +41,20 @@ public BmmEnumerationInteger() { super(); } + /** + * Sets the list of names of the enumeration. If no values are supplied, the values + * 0...N are used where N+1 is the size of itemNames + * + * @param itemNames + */ + @Override + public void setItemNames(List itemNames) { + super.setItemNames(itemNames); + ArrayList vals = new ArrayList<>(); + for (int i = 0; i < itemNames.size(); i++ ) + vals.add(i); + + setItemValues(vals); + } } diff --git a/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationString.java b/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationString.java index 8030d5637..005c360cf 100644 --- a/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationString.java +++ b/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationString.java @@ -22,6 +22,8 @@ */ import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * String-based enumeration type. @@ -39,4 +41,15 @@ public BmmEnumerationString() { super(); } + /** + * Sets the list of names of the enumeration. If no values are supplied, the string values + * mimicking the literals are assumed + * + * @param itemNames + */ + @Override + public void setItemNames(List itemNames) { + super.setItemNames(itemNames); + setItemValues(new ArrayList<>(itemNames)); + } }