if (part instanceof FieldTemplatePart) {
QName fieldName = ((FieldTemplatePart) part).getFieldType().getName();
if (ctx.record.hasField(fieldName)) {
return ctx.record.getField(fieldName);
} else {
throw new NameTemplateEvaluationException(
"Error evaluating name template: Record does not have field " + fieldName);
}
} else if (part instanceof VariantPropertyTemplatePart) {
VariantPropertyTemplatePart vpPart = (VariantPropertyTemplatePart) part;
return contexts.peek().contextRecord.getId().getVariantProperties().get(vpPart.getName());
} else if (part instanceof LiteralTemplatePart) {
return ((LiteralTemplatePart) part).getString();
} else {
throw new NameTemplateEvaluationException("Unsupported TemplatePart type " + part.getClass().getName());
}
}