private static Class<?> getObjectType(Type type) { if (type.equals(BOOLEAN)) { return boolean.class; } if (type.equals(BIGINT)) { return long.class; } if (type.equals(DOUBLE)) { return double.class; } if (type.equals(VARCHAR)) { return String.class; } if (type.getTypeSignature().getBase().equals(ARRAY)) { getObjectType(type.getTypeParameters().get(0)); return List.class; } if (type.getTypeSignature().getBase().equals(MAP)) { getObjectType(type.getTypeParameters().get(0)); getObjectType(type.getTypeParameters().get(1)); return Map.class; } throw new IllegalArgumentException("Unsupported argument type: " + type.getDisplayName()); } }
private void validateProcedure(Procedure procedure) { List<Class<?>> parameters = procedure.getMethodHandle().type().parameterList().stream() .filter(type -> !ConnectorSession.class.isAssignableFrom(type)) .collect(toList()); for (int i = 0; i < procedure.getArguments().size(); i++) { Argument argument = procedure.getArguments().get(i); Type type = typeManager.getType(argument.getType()); Class<?> argumentType = Primitives.unwrap(parameters.get(i)); Class<?> expectedType = getObjectType(type); checkArgument(expectedType.equals(argumentType), "Argument '%s' has invalid type %s (expected %s)", argument.getName(), argumentType.getName(), expectedType.getName()); } }
private static void validateProcedure(Procedure procedure) { List<Class<?>> parameters = procedure.getMethodHandle().type().parameterList().stream() .filter(type -> !ConnectorSession.class.isAssignableFrom(type)) .collect(toList()); for (int i = 0; i < procedure.getArguments().size(); i++) { Argument argument = procedure.getArguments().get(i); Class<?> argumentType = Primitives.unwrap(parameters.get(i)); Class<?> expectedType = getObjectType(argument.getType()); checkArgument(expectedType.equals(argumentType), "Argument '%s' has invalid type %s (expected %s)", argument.getName(), argumentType.getName(), expectedType.getName()); } }
private static Class<?> getObjectType(Type type) { if (type.equals(BOOLEAN)) { return boolean.class; } if (type.equals(BIGINT)) { return long.class; } if (type.equals(DOUBLE)) { return double.class; } if (type.equals(VARCHAR)) { return String.class; } if (type.getTypeSignature().getBase().equals(ARRAY)) { getObjectType(type.getTypeParameters().get(0)); return List.class; } if (type.getTypeSignature().getBase().equals(MAP)) { getObjectType(type.getTypeParameters().get(0)); getObjectType(type.getTypeParameters().get(1)); return Map.class; } throw new IllegalArgumentException("Unsupported argument type: " + type.getDisplayName()); } }