Small udpate: casting would likely have to take place at the factory level, since the parameter that is received is of UrlConnection type, which is the type returned when URL instance attempts to open a connection. I think having it in the factory makes better sense since we're likely to want to work with HttpURLConnection instances anyway.