<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_handler_name(route: Route, logic: Callable) -> str: """Gets the handler name. :param route: A Route instance. :param logic: The logic function. :returns: A handler class name. """

    if route.handler_name is not None:
        return route.handler_name
    if any(m for m in route.methods if m.method.lower() == 'post'):
        # A list endpoint
        if route.heading != 'API':
            return '{}ListHandler'.format(get_valid_class_name(route.heading))
        return '{}ListHandler'.format(get_valid_class_name(logic.__name__))
    if route.heading != 'API':
        return '{}Handler'.format(get_valid_class_name(route.heading))
    return '{}Handler'.format(get_valid_class_name(logic.__name__))