Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct initialisation error for BMM enum types. Without this, BMM-ba… #624

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationInteger.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* Integer-based enumeration type.
Expand All @@ -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<String> itemNames) {
super.setItemNames(itemNames);
ArrayList<Integer> vals = new ArrayList<>();
for (int i = 0; i < itemNames.size(); i++ )
vals.add(i);

setItemValues(vals);
}

}
13 changes: 13 additions & 0 deletions bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationString.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* String-based enumeration type.
Expand All @@ -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<String> itemNames) {
super.setItemNames(itemNames);
setItemValues(new ArrayList<>(itemNames));
}
}