-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageInfo.java
101 lines (79 loc) · 1.96 KB
/
ImageInfo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package qiwi.util.image;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
public class ImageInfo {
private final long id;
private final String suffix;
private final String mimeType;
private final byte[] data;
protected ImageInfo(Builder builder) {
this.suffix = builder.suffix;
this.id = builder.id;
this.mimeType = builder.mimeType;
this.data = builder.data;
}
public String getSuffix() {
return suffix;
}
public long getId() {
return id;
}
public String getMimeType() {
return mimeType;
}
@NotNull
public byte[] getData() {
return data;
}
public boolean hasData() {
return data.length > 0;
}
public static Builder builder() {
return new Builder();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ImageInfo)) return false;
final ImageInfo imageInfo = (ImageInfo) o;
return id == imageInfo.id
&& Arrays.equals(data, imageInfo.data)
&& !(mimeType != null ? !mimeType.equals(imageInfo.mimeType) : imageInfo.mimeType != null)
&& !(suffix != null ? !suffix.equals(imageInfo.suffix) : imageInfo.suffix != null);
}
@Override
public int hashCode() {
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (suffix != null ? suffix.hashCode() : 0);
result = 31 * result + (mimeType != null ? mimeType.hashCode() : 0);
result = 31 * result + (data != null ? Arrays.hashCode(data) : 0);
return result;
}
public static class Builder {
private String suffix;
private long id;
private String mimeType;
private byte[] data;
protected Builder() {
}
public Builder suffix(String suffix) {
this.suffix = suffix;
return this;
}
public Builder id(long id) {
this.id = id;
return this;
}
public Builder mimeType(String mimeType) {
this.mimeType = mimeType;
return this;
}
public Builder data(byte[] data) {
this.data = data;
return this;
}
public ImageInfo build() {
return new ImageInfo(this);
}
}
}