Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-worker-context
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlaCarvajal authored Dec 2, 2024
2 parents 1cabe89 + 979c869 commit ea615f4
Showing 1 changed file with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,17 @@ public LHTaskSignature(String taskDefName, Object executable, String lhTaskMetho
+ " on "
+ executable.getClass());
}
VariableType returnType = LHLibUtil.javaClassToLHVarType(taskMethod.getReturnType());
boolean maskedValue = false;
String outputSchemaVarName = "output";
if (taskMethod.isAnnotationPresent(LHType.class)) {
LHType type = taskMethod.getAnnotation(LHType.class);
maskedValue = type.masked();
if (!type.name().isEmpty() || !type.name().isBlank()) {
outputSchemaVarName = type.name();
}

Class<?> returnType = taskMethod.getReturnType();

buildInputVarsSignature();

if (!void.class.isAssignableFrom(returnType)) {
buildOutputSchemaSignature(returnType);
}
outputSchema = TaskDefOutputSchema.newBuilder()
.setValueDef(VariableDef.newBuilder()
.setType(returnType)
.setName(outputSchemaVarName)
.setMaskedValue(maskedValue)
.build())
.build();
}

private void buildInputVarsSignature() {
for (int i = 0; i < taskMethod.getParameterCount(); i++) {
Parameter param = taskMethod.getParameters()[i];
if (param.getType().equals(WorkerContext.class)) {
Expand Down Expand Up @@ -105,6 +98,26 @@ public LHTaskSignature(String taskDefName, Object executable, String lhTaskMetho
}
}

private void buildOutputSchemaSignature(Class<?> classReturnType) {
VariableType returnType = LHLibUtil.javaClassToLHVarType(classReturnType);
boolean maskedValue = false;
String outputSchemaVarName = "output";
if (taskMethod.isAnnotationPresent(LHType.class)) {
LHType type = taskMethod.getAnnotation(LHType.class);
maskedValue = type.masked();
if (!type.name().isEmpty() || !type.name().isBlank()) {
outputSchemaVarName = type.name();
}
}
outputSchema = TaskDefOutputSchema.newBuilder()
.setValueDef(VariableDef.newBuilder()
.setType(returnType)
.setName(outputSchemaVarName)
.setMaskedValue(maskedValue)
.build())
.build();
}

private String varNameFromParameterName(Parameter param) {
if (!param.isNamePresent()) {
log.warn(
Expand Down

0 comments on commit ea615f4

Please sign in to comment.