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

com.truelayer.java.http.entities.ApiResponse Maven / Gradle / Ivy

There is a newer version: 16.0.0
Show newest version
package com.truelayer.java.http.entities;

import static org.apache.commons.lang3.ObjectUtils.isNotEmpty;

import lombok.*;

/**
 * Model for API responses object. Instances of this class can contain either a data or an error object.
 * Comes with a isError() utility method to easily understand whether the object holds a successful or an error response.
 */
@Builder
@Getter
@ToString
@EqualsAndHashCode
public class ApiResponse {
    private final T data;
    private final ProblemDetails error;

    /**
     * Utility method to easily understand whether the object holds a successful or an error response.
     * @return true if the response contains an error.
     */
    public boolean isError() {
        return isNotEmpty(error);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy