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

org.zalando.problem.spring.common.ResponseStatusAdapter Maven / Gradle / Ivy

package org.zalando.problem.spring.common;

import org.springframework.web.bind.annotation.ResponseStatus;
import org.zalando.problem.StatusType;

/**
 * An implementation of {@link StatusType} to map {@link ResponseStatus}.
 */
final class ResponseStatusAdapter implements StatusType {

    private final ResponseStatus status;

    ResponseStatusAdapter(final ResponseStatus status) {
        this.status = status;
    }

    @Override
    public int getStatusCode() {
        return status.code().value();
    }

    @Override
    public String getReasonPhrase() {
        return status.reason().isEmpty() ? status.value().getReasonPhrase() : status.reason();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy