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

io.sphere.sdk.models.errors.ErrorResponse Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.models.errors;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import java.util.List;

@JsonDeserialize(as = ErrorResponseImpl.class)
public interface ErrorResponse {
    Integer getStatusCode();

    String getMessage();

    List getErrors();

    default boolean hasErrorCode(final String errorCode) {
        return getErrors().stream().anyMatch(sphereError -> sphereError.getCode().equals(errorCode));
    }

    static TypeReference typeReference() {
        return new TypeReference() {
            @Override
            public String toString() {
                return "TypeReference";
            }
        };
    }

    @JsonIgnore
    static ErrorResponse of(final Integer statusCode, final String message, final List errors) {
        return new ErrorResponseImpl(statusCode, message, errors);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy