diff options
author | Maxim Epishchev <epishev@garant.ru> | 2016-02-04 11:54:42 +0300 |
---|---|---|
committer | Maxim Epishchev <epishev@garant.ru> | 2016-02-04 11:54:42 +0300 |
commit | 85a09f7392c50531365e89e94766a9caf3cac0f1 (patch) | |
tree | cc44795d13511885860b4372e255e758984f48ea /src/main/java | |
parent | 56a5bbf2bad838cb1cc7b39021d865f6a97d8745 (diff) | |
download | bbprb-85a09f7392c50531365e89e94766a9caf3cac0f1.tar.gz |
Remove overqualified using of Class<T> as HttpClient interceptor
Constructor of ApiClient now using just <T extends HttpClientFactory> T type to make possible using of HttpClient interceptor in tests.
Diffstat (limited to 'src/main/java')
2 files changed, 5 insertions, 14 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java index 3bc3928..9b92775 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java @@ -54,7 +54,7 @@ public class BitbucketRepository { this.init(null, null); } - public <T extends ApiClient.HttpClientFactory> void init(Class<T> httpFactory) { + public <T extends ApiClient.HttpClientFactory> void init(T httpFactory) { this.init(null, httpFactory); } @@ -62,7 +62,7 @@ public class BitbucketRepository { this.init(client, null); } - public <T extends ApiClient.HttpClientFactory> void init(ApiClient client, Class<T> httpFactory) { + public <T extends ApiClient.HttpClientFactory> void init(ApiClient client, T httpFactory) { this.trigger = this.builder.getTrigger(); if (client == null) { diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java index 047bf5a..19bff34 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java @@ -71,23 +71,14 @@ public class ApiClient { String username, String password, String owner, String repositoryName, String key, String name, - Class<T> httpFactory + T httpFactory ) { this.credentials = new UsernamePasswordCredentials(username, password); this.owner = owner; this.repositoryName = repositoryName; this.key = key; - this.name = name; - - try { - this.factory = (httpFactory != null) ? httpFactory.newInstance() : HttpClientFactory.INSTANCE; - } catch(InstantiationException e) { - logger.log(Level.WARNING, "failed new instance of {0}: {1} ", new Object[] { httpFactory.getName(), e }); - e.printStackTrace(); - } catch (IllegalAccessException e) { - logger.log(Level.WARNING, "failed new instance of {0}: {1} ", new Object[] { httpFactory.getName(), e }); - e.printStackTrace(); - } + this.name = name; + this.factory = httpFactory != null ? httpFactory : HttpClientFactory.INSTANCE; } public List<Pullrequest> getPullRequests() { |