if(!ValueHolder.class.isAssignableFrom(field.getType())){
return failure(String.format("The field doesn't holds value of type %s which does not implement the ValueHolder interface. All fields of type @Param or @Output must extend this interface..", field.getType()), clazz, field);
}
// get the type field from the value holder.
MajorType type = null;
try{
type = 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());
}
ValueReference p = new ValueReference(type, field.getName());
if(param != null){
if (param.constant()) {
p.setConstant(true);
}
params.add(p);
}else{
if(outputField != null){
return failure("You've declared more than one @Output field. You must declare one and only @Output field per Function class.", clazz, field);
}else{
outputField = p;
}
}
}else{
// 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());
}