Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.scribejava.core.builder;

import com.github.scribejava.core.builder.api.BaseApi;
import com.github.scribejava.core.builder.api.DefaultApi10a;
import com.github.scribejava.core.builder.api.DefaultApi20;
import com.github.scribejava.core.model.OAuthConfig;
Expand All @@ -8,6 +9,7 @@
import com.github.scribejava.core.model.SignatureType;
import com.github.scribejava.core.oauth.OAuth10aService;
import com.github.scribejava.core.oauth.OAuth20Service;
import com.github.scribejava.core.oauth.OAuthService;
import com.github.scribejava.core.utils.Preconditions;

abstract class AbstractServiceBuilder<T extends AbstractServiceBuilder<T>> {
Expand Down Expand Up @@ -176,22 +178,12 @@ public String getResponseType() {
protected abstract OAuthConfig createConfig();

/**
* Returns the fully configured {@link OAuth10aService}
* Returns the fully configured {@link S}
*
* @param api will build Service for this API
* @return fully configured {@link OAuth10aService}
* @return fully configured {@link S}
*/
public OAuth10aService build(DefaultApi10a api) {
return api.createService(createConfig());
}

/**
* Returns the fully configured {@link OAuth20Service}
*
* @param api will build Service for this API
* @return fully configured {@link OAuth20Service}
*/
public OAuth20Service build(DefaultApi20 api) {
public <S extends OAuthService> S build(BaseApi<S> api) {
return api.createService(createConfig());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.github.scribejava.core.builder.api;

import com.github.scribejava.core.model.OAuthConfig;
import com.github.scribejava.core.oauth.OAuthService;


public interface BaseApi<T extends OAuthService> {
T createService(OAuthConfig config);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* fine-tune the process. Please read the javadocs of the interfaces to get an idea of what to do.
*
*/
public abstract class DefaultApi10a {
public abstract class DefaultApi10a implements BaseApi<OAuth10aService> {

/**
* Returns the access token extractor.
Expand Down Expand Up @@ -126,6 +126,7 @@ public Verb getRequestTokenVerb() {
*/
public abstract String getAuthorizationUrl(OAuth1RequestToken requestToken);

@Override
public OAuth10aService createService(OAuthConfig config) {
return new OAuth10aService(this, config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* fine-tune the process. Please read the javadocs of the interfaces to get an idea of what to do.
*
*/
public abstract class DefaultApi20 {
public abstract class DefaultApi20 implements BaseApi<OAuth20Service> {

/**
* Returns the access token extractor.
Expand Down Expand Up @@ -88,6 +88,7 @@ public String getAuthorizationUrl(OAuthConfig config, Map<String, String> additi
return authUrl;
}

@Override
public OAuth20Service createService(OAuthConfig config) {
return new OAuth20Service(this, config);
}
Expand Down