// Path: src/main/java/org/dmfs/oauth2/client/pkce/PkceCodeChallenge.java
// public interface PkceCodeChallenge
// {
//     /**
//      * Returns a {@link Token} that identifies the method this code challenge uses.
//      *
//      * @return A {@link Token} containing the method name.
//      */
//     Token method();
// 
//     /**
//      * Returns the value of the code challenge.
//      *
//      * @return
//      */
//     CharSequence challenge();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> CLIENT_ID = new BasicParameterType<>("client_id", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> CODE_CHALLENGE = new BasicParameterType<>("code_challenge", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> CODE_CHALLENGE_METHOD = new BasicParameterType<>("code_challenge_method", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<Uri> REDIRECT_URI = new BasicParameterType<>("redirect_uri", new UriValueType());
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> RESPONSE_TYPE = new BasicParameterType<>("response_type", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<OAuth2Scope> SCOPE = new BasicParameterType<OAuth2Scope>("scope", new OAuth2ScopeValueType());
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> STATE = new BasicParameterType<>("state", TextValueType.INSTANCE);


import static org.dmfs.oauth2.client.utils.Parameters.CODE_CHALLENGE_METHOD;
import static org.dmfs.oauth2.client.utils.Parameters.REDIRECT_URI;
import static org.dmfs.oauth2.client.utils.Parameters.RESPONSE_TYPE;
import static org.dmfs.oauth2.client.utils.Parameters.SCOPE;
import static org.dmfs.oauth2.client.utils.Parameters.STATE;
import org.dmfs.oauth2.client.pkce.PkceCodeChallenge;
import org.dmfs.rfc3986.Uri;
import org.dmfs.rfc3986.encoding.XWwwFormUrlEncoded;
import org.dmfs.rfc3986.parameters.FluentParameterList;
import org.dmfs.rfc3986.parameters.ParameterList;
import org.dmfs.rfc3986.parameters.parametersets.BasicParameterList;
import org.dmfs.rfc3986.parameters.parametersets.Fluent;
import org.dmfs.rfc3986.parameters.parametersets.Replacing;
import java.net.URI;
import java.net.URISyntaxException;
import static org.dmfs.oauth2.client.utils.Parameters.CLIENT_ID;
import static org.dmfs.oauth2.client.utils.Parameters.CODE_CHALLENGE;
    {
        this(new Fluent(new Replacing(customParameters, RESPONSE_TYPE.parameter(responseType), SCOPE.parameter(scope), STATE.parameter(state))));
    }


    private BasicOAuth2AuthorizationRequest(FluentParameterList parameters)
    {
        mParameters = parameters;
    }


    @Override
    public OAuth2AuthorizationRequest withClientId(String clientId)
    {
        return new BasicOAuth2AuthorizationRequest(mParameters.ratherWith(CLIENT_ID.parameter(clientId)));
    }


    @Override
    public OAuth2AuthorizationRequest withRedirectUri(Uri redirectUri)
    {
        return new BasicOAuth2AuthorizationRequest(mParameters.ratherWith(REDIRECT_URI.parameter(redirectUri)));
    }


    @Override
    public OAuth2AuthorizationRequest withCodeChallenge(PkceCodeChallenge codeChallenge)
    {
        return new BasicOAuth2AuthorizationRequest(mParameters.ratherWith(
                CODE_CHALLENGE_METHOD.parameter(codeChallenge.method()),
// Path: src/main/java/org/dmfs/oauth2/client/pkce/PkceCodeChallenge.java
// public interface PkceCodeChallenge
// {
//     /**
//      * Returns a {@link Token} that identifies the method this code challenge uses.
//      *
//      * @return A {@link Token} containing the method name.
//      */
//     Token method();
// 
//     /**
//      * Returns the value of the code challenge.
//      *
//      * @return
//      */
//     CharSequence challenge();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> CLIENT_ID = new BasicParameterType<>("client_id", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> CODE_CHALLENGE = new BasicParameterType<>("code_challenge", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> CODE_CHALLENGE_METHOD = new BasicParameterType<>("code_challenge_method", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<Uri> REDIRECT_URI = new BasicParameterType<>("redirect_uri", new UriValueType());
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> RESPONSE_TYPE = new BasicParameterType<>("response_type", TextValueType.INSTANCE);
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<OAuth2Scope> SCOPE = new BasicParameterType<OAuth2Scope>("scope", new OAuth2ScopeValueType());
// 
// Path: src/main/java/org/dmfs/oauth2/client/utils/Parameters.java
// public final static ParameterType<CharSequence> STATE = new BasicParameterType<>("state", TextValueType.INSTANCE);


// Path: src/main/java/org/dmfs/oauth2/client/BasicOAuth2AuthorizationRequest.java
import static org.dmfs.oauth2.client.utils.Parameters.CODE_CHALLENGE_METHOD;
import static org.dmfs.oauth2.client.utils.Parameters.REDIRECT_URI;
import static org.dmfs.oauth2.client.utils.Parameters.RESPONSE_TYPE;
import static org.dmfs.oauth2.client.utils.Parameters.SCOPE;
import static org.dmfs.oauth2.client.utils.Parameters.STATE;
import org.dmfs.oauth2.client.pkce.PkceCodeChallenge;
import org.dmfs.rfc3986.Uri;
import org.dmfs.rfc3986.encoding.XWwwFormUrlEncoded;
import org.dmfs.rfc3986.parameters.FluentParameterList;
import org.dmfs.rfc3986.parameters.ParameterList;
import org.dmfs.rfc3986.parameters.parametersets.BasicParameterList;
import org.dmfs.rfc3986.parameters.parametersets.Fluent;
import org.dmfs.rfc3986.parameters.parametersets.Replacing;
import java.net.URI;
import java.net.URISyntaxException;
import static org.dmfs.oauth2.client.utils.Parameters.CLIENT_ID;
import static org.dmfs.oauth2.client.utils.Parameters.CODE_CHALLENGE;

    {
        this(new Fluent(new Replacing(customParameters, RESPONSE_TYPE.parameter(responseType), SCOPE.parameter(scope), STATE.parameter(state))));
    }


    private BasicOAuth2AuthorizationRequest(FluentParameterList parameters)
    {
        mParameters = parameters;
    }


    @Override
    public OAuth2AuthorizationRequest withClientId(String clientId)
    {
        return new BasicOAuth2AuthorizationRequest(mParameters.ratherWith(CLIENT_ID.parameter(clientId)));
    }


    @Override
    public OAuth2AuthorizationRequest withRedirectUri(Uri redirectUri)
    {
        return new BasicOAuth2AuthorizationRequest(mParameters.ratherWith(REDIRECT_URI.parameter(redirectUri)));
    }


    @Override
    public OAuth2AuthorizationRequest withCodeChallenge(PkceCodeChallenge codeChallenge)
    {
        return new BasicOAuth2AuthorizationRequest(mParameters.ratherWith(
                CODE_CHALLENGE_METHOD.parameter(codeChallenge.method()),
                CODE_CHALLENGE.parameter(codeChallenge.challenge())));