All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javastrava.api.v3.model.reference.StravaResourceState Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha
Show newest version
package javastrava.api.v3.model.reference;

import javastrava.config.Messages;
import javastrava.config.StravaConfig;
import javastrava.json.impl.gson.serializer.ResourceStateSerializer;

/**
 * 

* State of a resource returned from Strava. *

* * @author Dan Shannon * */ public enum StravaResourceState { /** * Resource is currently being updated */ UPDATING(StravaConfig.integer("StravaResourceState.updating"), Messages.string("StravaResourceState.updating.description")), //$NON-NLS-1$ //$NON-NLS-2$ /** * This is a representation of the resource which contains the id ONLY (other than the resource state) */ META(StravaConfig.integer("StravaResourceState.meta"), Messages.string("StravaResourceState.meta.description")), //$NON-NLS-1$ //$NON-NLS-2$ /** * This is a summary representation of the resource */ SUMMARY(StravaConfig.integer("StravaResourceState.summary"), Messages.string("StravaResourceState.summary.description")), //$NON-NLS-1$ //$NON-NLS-2$ /** * This is a detailed representation of the resource */ DETAILED(StravaConfig.integer("StravaResourceState.detailed"), Messages.string("StravaResourceState.detailed.description")), //$NON-NLS-1$ //$NON-NLS-2$ /** *

* Indicates that the resource is flagged as PRIVATE and as a result is not accessible. *

*

* Will be returned as an empty object with only the id and resourceState set. *

*/ PRIVATE(StravaConfig.integer("StravaResourceState.private"), Messages.string("StravaResourceState.private.description")), //$NON-NLS-1$ //$NON-NLS-2$ /** *

* Should never occur but may if Strava API behaviour has changed *

*/ UNKNOWN(StravaConfig.integer("Common.unknown.integer"), Messages.string("Common.unknown.description")); //$NON-NLS-1$ //$NON-NLS-2$ /** * Identifier */ private Integer id; /** * Description */ private String description; /** * Used by JSON serialisation * @return The integer representation of this {@link StravaResourceState} to be used with the Strava API * @see ResourceStateSerializer#serialize(StravaResourceState, java.lang.reflect.Type, com.google.gson.JsonSerializationContext) */ public Integer getValue() { return this.id; } /** * Private constructor used by declarations * @param id Identifier - also used when serialising/deserialising to JSON * @param description Description */ private StravaResourceState(final Integer id, final String description) { this.id = id; this.description = description; } /** * Used by JSON deserialisation * @param id The integer representation of this {@link StravaResourceState} as returned by the Strava API * @return The matching {@link StravaResourceState}, or {@link StravaResourceState#UNKNOWN} if there is no match */ public static StravaResourceState create(final Integer id) { StravaResourceState[] states = StravaResourceState.values(); for (StravaResourceState state : states) { if (state.getValue() != null && state.getValue().equals(id)) { return state; } } return StravaResourceState.UNKNOWN; } /** * @return the id */ public Integer getId() { return this.id; } /** * @return the description */ public String getDescription() { return this.description; } /** * @see java.lang.Enum#toString() */ @Override public String toString() { return this.id.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy