// workspace work.
boolean isInject = inject != null;
if (isInject && !field.getType().equals(DrillBuf.class)) {
return failure(String.format("Only DrillBuf is allowed to be injected. You attempted to inject %s.", field.getType()), clazz, field);
}
WorkspaceReference wsReference = new WorkspaceReference(field.getType(), field.getName(), isInject);
if (!isInject && template.scope() == FunctionScope.POINT_AGGREGATE && !ValueHolder.class.isAssignableFrom(field.getType()) ) {
return failure(String.format("Aggregate function '%s' workspace variable '%s' is of type '%s'. Please change it to Holder type.", template.name(), field.getName(), field.getType()), clazz, field);
}
//If the workspace var is of Holder type, get its MajorType and assign to WorkspaceReference.
if (ValueHolder.class.isAssignableFrom(field.getType())) {
MajorType majorType = null;
try {
majorType = getStaticFieldValue("TYPE", field.getType(), MajorType.class);
} catch (Exception e) {
return failure("Failure while trying to access the ValueHolder's TYPE static variable. All ValueHolders must contain a static TYPE variable that defines their MajorType.", e, clazz, field.getName());
}
wsReference.setMajorType(majorType);
}
workspaceFields.add(wsReference);
}
}