code: private ServiceRegistration.EndpointHealthCheck endpointHealthCheck(String portName) {
      if (healthCheck() instanceof HttpHealthCheck) {
        final HttpHealthCheck httpHealthCheck = (HttpHealthCheck) healthCheck();
        if (portName.equals(httpHealthCheck.getPort())) {
          return ServiceRegistration.EndpointHealthCheck.newHttpCheck(httpHealthCheck.getPath());
        }
      } else if (healthCheck() instanceof TcpHealthCheck) {
        if (portName.equals(((TcpHealthCheck) healthCheck()).getPort())) {
          return ServiceRegistration.EndpointHealthCheck.newTcpCheck();
        }
      }
      return null;
    }
docs: Get endpoint health check for a given port.
  
  @param portName The port name
  
  @return An EndpointHealthCheck or null if no check exists