use of com.facebook.presto.operator.scalar.ScalarHeader in project presto by prestodb.
the class ScalarImplementationHeader method fromAnnotatedElement.
public static List<ScalarImplementationHeader> fromAnnotatedElement(AnnotatedElement annotated) {
ScalarFunction scalarFunction = annotated.getAnnotation(ScalarFunction.class);
ScalarOperator scalarOperator = annotated.getAnnotation(ScalarOperator.class);
Optional<String> description = parseDescription(annotated);
ImmutableList.Builder<ScalarImplementationHeader> builder = ImmutableList.builder();
if (scalarFunction != null) {
String baseName = scalarFunction.value().isEmpty() ? camelToSnake(annotatedName(annotated)) : scalarFunction.value();
builder.add(new ScalarImplementationHeader(baseName, new ScalarHeader(description, scalarFunction.visibility(), scalarFunction.deterministic(), scalarFunction.calledOnNullInput())));
for (String alias : scalarFunction.alias()) {
builder.add(new ScalarImplementationHeader(alias, new ScalarHeader(description, scalarFunction.visibility(), scalarFunction.deterministic(), scalarFunction.calledOnNullInput())));
}
}
if (scalarOperator != null) {
builder.add(new ScalarImplementationHeader(scalarOperator.value(), new ScalarHeader(description, HIDDEN, true, scalarOperator.value().isCalledOnNullInput())));
}
List<ScalarImplementationHeader> result = builder.build();
checkArgument(!result.isEmpty());
return result;
}
Aggregations