List<OperatorPortDeclaration> inputPorts,
List<OperatorPortDeclaration> parameters) {
assert output != null;
assert inputPorts != null;
assert parameters != null;
Types types = environment.getTypeUtils();
TypeMirror outputType = output.getType().getRepresentation();
for (OperatorPortDeclaration input : inputPorts) {
if (types.isSameType(outputType, input.getType().getRepresentation())) {
return new OperatorPortDeclaration(
output.getKind(),
output.getDocumentation(),
output.getName(),
PortTypeDescription.reference(outputType, input.getName()),
output.getParameterPosition(),
null);
}
}
DeclaredType classType = environment.getDeclaredType(Class.class);
for (OperatorPortDeclaration param : parameters) {
// check is form of M<T>
TypeMirror paramType = param.getType().getRepresentation();
if (paramType.getKind() != TypeKind.DECLARED) {
continue;
}
DeclaredType declParamType = (DeclaredType) paramType;
if (declParamType.getTypeArguments().size() != 1) {
continue;
}
// check is <: Class<?>
if (types.isSameType(environment.getErasure(paramType), classType) == false) {
continue;
}
if (types.isSameType(declParamType.getTypeArguments().get(0), outputType)) {
return new OperatorPortDeclaration(
output.getKind(),
output.getDocumentation(),
output.getName(),
PortTypeDescription.reference(outputType, param.getName()),