javastrava.auth.ref.AuthorisationResponseType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javastrava-api Show documentation
Show all versions of javastrava-api Show documentation
Java implementation of the Strava API
The newest version!
package javastrava.auth.ref;
import javastrava.config.StravaConfig;
/**
*
* Valid authorisation response types
*
*
*
* As of Strava API v3.0, this value must be set to {@link #CODE}
*
*
* @author Dan Shannon
*
*/
public enum AuthorisationResponseType {
/**
*
* Currently Strava requires the use of this value when exchanging authorisation via OAuth. This is the only valid value.
*
*/
CODE(StravaConfig.string("AuthorisationResponseType.code")), //$NON-NLS-1$
/**
*
* Should never occur but may if Strava API behaviour has changed
*
*/
UNKNOWN(StravaConfig.string("Common.unknown")); //$NON-NLS-1$
/**
* Required by GSON serialiser
*
* @param id
* The String value of the id
* @return An instance of {@link AuthorisationResponseType} corresponding to the id, or {@link #UNKNOWN} if no such instance is available.
*/
public static AuthorisationResponseType create(final String id) {
for (final AuthorisationResponseType type : AuthorisationResponseType.values()) {
if (type.getId().equals(id)) {
return type;
}
}
return AuthorisationResponseType.UNKNOWN;
}
/**
*
* Identifier
*
*/
private final String id;
/**
*
* Private constructor - this is an enum, so we can't be running round having public constructors, can we
*
* @param id The identifier of the response type
*/
private AuthorisationResponseType(final String id) {
this.id = id;
}
/**
* @return the id
*/
public String getId() {
return this.id;
}
/**
* @see java.lang.Enum#toString()
*/
@Override
public String toString() {
return this.id;
}
}