
org.johnnei.enjin.internal.ResponseWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of enjin-api-impl Show documentation
Show all versions of enjin-api-impl Show documentation
The specification of the Enjin API
The newest version!
package org.johnnei.enjin.internal;
import java.util.Optional;
public class ResponseWrapper extends EnjinWrapper {
private Optional result;
private ResponseError error;
ResponseWrapper() {
// Used by GSON
}
public ResponseWrapper(T result, ResponseError error) {
this.result = Optional.ofNullable(result);
this.error = error;
}
public boolean isInErrorState() {
return error != null;
}
public EnjinError getError() {
if (error == null) {
throw new IllegalStateException("Response is not in error state.");
}
return error.getError();
}
public T getResponse() {
return result.orElseThrow(() -> new IllegalStateException("Response is in error state."));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy