Add eq override

This commit is contained in:
2026-01-06 09:55:27 +01:00
parent 3c8d85ebc2
commit e2d3b0975c

View File

@@ -1,3 +1,44 @@
package dev.kruhlmann.imgfloat.service.media; package dev.kruhlmann.imgfloat.service.media;
public record OptimizedAsset(byte[] bytes, String mediaType, int width, int height, byte[] previewBytes) {} import java.util.Arrays;
import java.util.Objects;
public record OptimizedAsset(
byte[] bytes,
String mediaType,
int width,
int height,
byte[] previewBytes
) {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OptimizedAsset that = (OptimizedAsset) o;
return width == that.width
&& height == that.height
&& Arrays.equals(bytes, that.bytes)
&& Arrays.equals(previewBytes, that.previewBytes)
&& Objects.equals(mediaType, that.mediaType);
}
@Override
public int hashCode() {
int result = Objects.hash(mediaType, width, height);
result = 31 * result + Arrays.hashCode(bytes);
result = 31 * result + Arrays.hashCode(previewBytes);
return result;
}
@Override
public String toString() {
return "OptimizedAsset{" +
"bytes=" + Arrays.toString(bytes) +
", mediaType='" + mediaType + '\'' +
", width=" + width +
", height=" + height +
", previewBytes=" + Arrays.toString(previewBytes) +
'}';
}
}