DataWrapper.java

package se.jobtechdev.personaldatagateway.api.util;

import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;

import java.util.Arrays;
import java.util.Objects;

public record DataWrapper(byte[] body, MediaType contentType, HttpStatus status) {
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    DataWrapper that = (DataWrapper) o;
    return Arrays.equals(body, that.body) &&
        Objects.equals(contentType, that.contentType) &&
        Objects.equals(status, that.status);
  }

  @Override
  public int hashCode() {
    int result = Objects.hash(contentType, status);
    result = 31 * result + Arrays.hashCode(body);
    return result;
  }

  @Override
  public String toString() {
    return "DataWrapper{" +
        "body=" + Arrays.toString(body) +
        ", contentType=" + contentType +
        ", status=" + status +
        '}';
  }
}