public XBELInternalAnnotationDefinition convert(AnnotationDefinition t) {
if (t == null || t.getURL() != null) {
return null;
}
XBELInternalAnnotationDefinition dest =
new XBELInternalAnnotationDefinition();
String description = t.getDescription();
String id = t.getId();
String usage = t.getUsage();
// If null, set equal to an empty string so that the document can be properly converted.
if (description == null) description = "";
if (usage == null) usage = "";
dest.setDescription(description);
dest.setId(id);
dest.setUsage(usage);
AnnotationType type = t.getType();
String value = t.getValue();
switch (type) {
case ENUMERATION:
List<String> enums = t.getEnums();
XBELListAnnotation xla = new XBELListAnnotation();
List<String> xlaval = xla.getListValue();
xlaval.addAll(enums);
dest.setListAnnotation(xla);
break;
case REGULAR_EXPRESSION:
dest.setPatternAnnotation(value);
break;
default:
throw new UnsupportedOperationException("unknown type: " + type);
}