mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 08:21:23 +00:00
Make HttpConnector a functional interface
This commit is contained in:
@@ -12,6 +12,7 @@ import java.net.URL;
|
||||
* <p>
|
||||
* For example, you can implement this to st custom timeouts.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface HttpConnector {
|
||||
/**
|
||||
* Opens a connection to the given URL.
|
||||
@@ -27,18 +28,12 @@ public interface HttpConnector {
|
||||
/**
|
||||
* Default implementation that uses {@link URL#openConnection()}.
|
||||
*/
|
||||
HttpConnector DEFAULT = new ImpatientHttpConnector(new HttpConnector() {
|
||||
public HttpURLConnection connect(URL url) throws IOException {
|
||||
return (HttpURLConnection) url.openConnection();
|
||||
}
|
||||
});
|
||||
HttpConnector DEFAULT = new ImpatientHttpConnector(url -> (HttpURLConnection) url.openConnection());
|
||||
|
||||
/**
|
||||
* Stub implementation that is always off-line.
|
||||
*/
|
||||
HttpConnector OFFLINE = new HttpConnector() {
|
||||
public HttpURLConnection connect(URL url) throws IOException {
|
||||
throw new IOException("Offline");
|
||||
}
|
||||
HttpConnector OFFLINE = url -> {
|
||||
throw new IOException("Offline");
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user