// Path: src/main/java/org/dmfs/oauth2/client/OAuth2Scope.java
// public interface OAuth2Scope
// {
//     /**
//      * Returns whether this scope is empty.
//      *
//      * @return <code>true</code> if this scope is empty, <code>false</code> otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this scope contains the given scope token or not.
//      *
//      * @param token
//      *         The scope token to check for.
//      *
//      * @return <code>true</code> if the scope token is contained in this scope, <code>false</code> otherwise.
//      */
//     boolean hasToken(String token);
// 
//     /**
//      * Returns the number of tokens in this {@link OAuth2Scope}.
//      *
//      * @return The number of tokens in this {@link OAuth2Scope}.
//      */
//     int tokenCount();
// 
//     /**
//      * Returns a string version of this scope as described in <a href="https://tools.ietf.org/html/rfc6749#section-3.3">RFC 6749, section 3.3</a>, i.e. a list
//      * of scope tokens separated by spaces.
//      *
//      * @return A String containing a list scope tokens, separated by spaces, or an empty String if {@link #isEmpty()} returns <code>true</code>.
//      */
//     String toString();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/GrantTypeParam.java
// public final class GrantTypeParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public GrantTypeParam(CharSequence grantType)
//     {
//         super("grant_type", grantType);
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/OptionalScopeParam.java
// public final class OptionalScopeParam extends DelegatingOptional<Pair<CharSequence, CharSequence>>
// {
//     public OptionalScopeParam(OAuth2Scope scope)
//     {
//         super(new Mapped<>(
//                 s -> new ValuePair<>("scope", s.toString()),
//                 new Conditional<>(s -> !s.isEmpty(), scope)));
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/scope/EmptyScope.java
// public final class EmptyScope implements OAuth2Scope
// {
//     public final static EmptyScope INSTANCE = new EmptyScope();
// 
// 
//     @Override
//     public boolean isEmpty()
//     {
//         return true;
//     }
// 
// 
//     @Override
//     public boolean hasToken(String token)
//     {
//         // no tokens in here
//         return false;
//     }
// 
// 
//     @Override
//     public int tokenCount()
//     {
//         return 0;
//     }
// 
// 
//     @Override
//     public String toString()
//     {
//         return "";
//     }
// 
// 
//     @Override
//     public boolean equals(Object obj)
//     {
//         if (!(obj instanceof OAuth2Scope))
//         {
//             return false;
//         }
// 
//         return ((OAuth2Scope) obj).isEmpty();
//     }
// }


import org.dmfs.httpessentials.client.HttpRequest;
import org.dmfs.httpessentials.entities.XWwwFormUrlEncodedEntity;
import org.dmfs.iterables.SingletonIterable;
import org.dmfs.iterables.elementary.PresentValues;
import org.dmfs.jems.iterable.composite.Joined;
import org.dmfs.oauth2.client.OAuth2Scope;
import org.dmfs.oauth2.client.http.requests.parameters.GrantTypeParam;
import org.dmfs.oauth2.client.http.requests.parameters.OptionalScopeParam;
import org.dmfs.oauth2.client.scope.EmptyScope;
/*
 * Copyright 2016 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.oauth2.client.http.requests;



/**
 * {@link HttpRequest} to retrieve an access token in an OAuth2 Client Credentials Grant.
 * <p>
 * Note that this request must be authenticated using the client credentials.
 *
 * @author Marten Gajda
 */
public final class ClientCredentialsTokenRequest extends AbstractAccessTokenRequest
{
    /**
     * Creates a {@link ClientCredentialsTokenRequest} without a specific scope.
     */
    public ClientCredentialsTokenRequest()
    {
// Path: src/main/java/org/dmfs/oauth2/client/OAuth2Scope.java
// public interface OAuth2Scope
// {
//     /**
//      * Returns whether this scope is empty.
//      *
//      * @return <code>true</code> if this scope is empty, <code>false</code> otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this scope contains the given scope token or not.
//      *
//      * @param token
//      *         The scope token to check for.
//      *
//      * @return <code>true</code> if the scope token is contained in this scope, <code>false</code> otherwise.
//      */
//     boolean hasToken(String token);
// 
//     /**
//      * Returns the number of tokens in this {@link OAuth2Scope}.
//      *
//      * @return The number of tokens in this {@link OAuth2Scope}.
//      */
//     int tokenCount();
// 
//     /**
//      * Returns a string version of this scope as described in <a href="https://tools.ietf.org/html/rfc6749#section-3.3">RFC 6749, section 3.3</a>, i.e. a list
//      * of scope tokens separated by spaces.
//      *
//      * @return A String containing a list scope tokens, separated by spaces, or an empty String if {@link #isEmpty()} returns <code>true</code>.
//      */
//     String toString();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/GrantTypeParam.java
// public final class GrantTypeParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public GrantTypeParam(CharSequence grantType)
//     {
//         super("grant_type", grantType);
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/OptionalScopeParam.java
// public final class OptionalScopeParam extends DelegatingOptional<Pair<CharSequence, CharSequence>>
// {
//     public OptionalScopeParam(OAuth2Scope scope)
//     {
//         super(new Mapped<>(
//                 s -> new ValuePair<>("scope", s.toString()),
//                 new Conditional<>(s -> !s.isEmpty(), scope)));
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/scope/EmptyScope.java
// public final class EmptyScope implements OAuth2Scope
// {
//     public final static EmptyScope INSTANCE = new EmptyScope();
// 
// 
//     @Override
//     public boolean isEmpty()
//     {
//         return true;
//     }
// 
// 
//     @Override
//     public boolean hasToken(String token)
//     {
//         // no tokens in here
//         return false;
//     }
// 
// 
//     @Override
//     public int tokenCount()
//     {
//         return 0;
//     }
// 
// 
//     @Override
//     public String toString()
//     {
//         return "";
//     }
// 
// 
//     @Override
//     public boolean equals(Object obj)
//     {
//         if (!(obj instanceof OAuth2Scope))
//         {
//             return false;
//         }
// 
//         return ((OAuth2Scope) obj).isEmpty();
//     }
// }


// Path: src/main/java/org/dmfs/oauth2/client/http/requests/ClientCredentialsTokenRequest.java
import org.dmfs.httpessentials.client.HttpRequest;
import org.dmfs.httpessentials.entities.XWwwFormUrlEncodedEntity;
import org.dmfs.iterables.SingletonIterable;
import org.dmfs.iterables.elementary.PresentValues;
import org.dmfs.jems.iterable.composite.Joined;
import org.dmfs.oauth2.client.OAuth2Scope;
import org.dmfs.oauth2.client.http.requests.parameters.GrantTypeParam;
import org.dmfs.oauth2.client.http.requests.parameters.OptionalScopeParam;
import org.dmfs.oauth2.client.scope.EmptyScope;

/*
 * Copyright 2016 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.oauth2.client.http.requests;



/**
 * {@link HttpRequest} to retrieve an access token in an OAuth2 Client Credentials Grant.
 * <p>
 * Note that this request must be authenticated using the client credentials.
 *
 * @author Marten Gajda
 */
public final class ClientCredentialsTokenRequest extends AbstractAccessTokenRequest
{
    /**
     * Creates a {@link ClientCredentialsTokenRequest} without a specific scope.
     */
    public ClientCredentialsTokenRequest()
    {
        this(EmptyScope.INSTANCE);