Class GGResponse<T extends GGResponseObject>
- java.lang.Object
- 
- com.github.gpluscb.ggjava.entity.object.response.GGResponse<T>
 
- 
- Type Parameters:
- T- The type of the data. Typically either- QueryResponseor- MutationResponse
 
 public class GGResponse<T extends GGResponseObject> extends java.lang.ObjectRepresents a response from the smash.gg api.
- 
- 
Constructor SummaryConstructors Constructor Description GGResponse(com.google.gson.JsonObject responseRoot, java.lang.Class<T> toClass)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.gson.JsonArraygetActionRecords()The unprocessed actionRecords field of the response.TgetData()The deserialized data.java.util.List<GGError>getErrors()The errors field.DeserializationExceptiongetException()The Exception that occurred during deserialization.com.google.gson.JsonObjectgetExtensions()The unprocessed extensions field of the response.com.google.gson.JsonObjectgetResponseRoot()The unprocessed JsonObject of the response.<U> Umap(java.util.function.Function<GGResponse<T>,U> onError, java.util.function.Function<T,U> onSuccess)Applies either itself to onError, if either the errors field is present or deserialization failed, or the deserialized data to onSuccess if that is not the case, and returns the result.GGResponse<T>onError(java.util.function.Consumer<GGResponse<T>> consumer)The consumer is executed only if the errors field is present or deserialization failed.GGResponse<T>onSuccess(java.util.function.Consumer<T> consumer)The consumer is executed only if the errors field is not present and deserialization was successful.
 
- 
- 
- 
Constructor Detail- 
GGResponsepublic GGResponse(@Nonnull com.google.gson.JsonObject responseRoot, @Nonnull java.lang.Class<T> toClass)- Throws:
- java.lang.IllegalArgumentException- if responseRoot or toClass are null
 
 
- 
 - 
Method Detail- 
mappublic <U> U map(@Nonnull java.util.function.Function<GGResponse<T>,U> onError, @Nonnull java.util.function.Function<T,U> onSuccess)Applies either itself to onError, if either the errors field is present or deserialization failed, or the deserialized data to onSuccess if that is not the case, and returns the result.- Type Parameters:
- U- the return type
- Parameters:
- onError- the function to apply if the errors field is present or deserialization failed
- onSuccess- the function to apply if the errors field is not present and deserialization succeeded
- Returns:
- the result of the applied function
- Throws:
- java.lang.IllegalStateException- if onError or onSuccess are null
 
 - 
onErrorpublic GGResponse<T> onError(@Nonnull java.util.function.Consumer<GGResponse<T>> consumer) The consumer is executed only if the errors field is present or deserialization failed.- Parameters:
- consumer- the consumer to execute
- Returns:
- itself for chaining
- Throws:
- java.lang.IllegalStateException- if consumer is null
 
 - 
onSuccesspublic GGResponse<T> onSuccess(@Nonnull java.util.function.Consumer<T> consumer) The consumer is executed only if the errors field is not present and deserialization was successful.- Parameters:
- consumer- the consumer to execute
- Returns:
- itself for chaining
- Throws:
- java.lang.IllegalStateException- if consumer is null
 
 - 
getResponseRoot@Nonnull public com.google.gson.JsonObject getResponseRoot() The unprocessed JsonObject of the response.- Returns:
- the response root
 
 - 
getData@Nullable public T getData() The deserialized data.- Returns:
- the deserialized data or null if deserialization failed
 
 - 
getException@Nullable public DeserializationException getException() The Exception that occurred during deserialization.- Returns:
- The DeserializationException or null if it deserialization was successful
 
 - 
getErrors@Nullable public java.util.List<GGError> getErrors() The errors field.- Returns:
- The errors field as a List<GGError>
 
 - 
getExtensions@Nullable public com.google.gson.JsonObject getExtensions() The unprocessed extensions field of the response.- Returns:
- the extensions field
 
 - 
getActionRecords@Nullable public com.google.gson.JsonArray getActionRecords() The unprocessed actionRecords field of the response.- Returns:
- the actionRecords field
 
 
- 
 
-