use of eu.esdihumboldt.hale.common.schema.model.constraint.property.CodeListAssociation in project hale by halestudio.
the class CodeListAssocationFactory method restore.
@Override
public CodeListAssociation restore(Value value, Definition<?> definition, TypeResolver typeIndex, ClassResolver resolver) throws Exception {
// is it a simple value? (single String code list reference)
String single = value.as(String.class);
if (single != null) {
return new CodeListAssociation(Collections.singleton(single));
}
// is it a value list? (multiple String code list references)
ValueList list = value.as(ValueList.class);
if (list != null) {
List<String> refList = list.stream().map(val -> val.as(String.class)).filter(val -> val != null).collect(Collectors.toList());
return new CodeListAssociation(refList);
}
// fall-back
return new CodeListAssociation();
}
Aggregations