Repository navigation
Expand file tree
/
Copy pathResize.java
More file actions
62 lines (49 loc) · 1.36 KB
/
Copy pathResize.java
File metadata and controls
62 lines (49 loc) · 1.36 KB
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
package io.getstream.core.options;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import io.getstream.core.http.Request;
public final class Resize implements RequestOption {
public enum Type {
CLIP("clip"),
CROP("crop"),
SCALE("scale"),
FILL("fill");
private final String type;
Type(String type) {
this.type = type;
}
@Override
public String toString() {
return type;
}
}
private final Type type;
private final int width;
private final int height;
public Resize(int width, int height, Type type) {
checkNotNull(type, "Missing resize type");
checkArgument(width > 0, "Width should be a positive number");
checkArgument(height > 0, "Height should be a positive number");
this.type = type;
this.width = width;
this.height = height;
}
public Resize(int width, int height) {
this(width, height, Type.CLIP);
}
public Type getType() {
return type;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
@Override
public void apply(Request.Builder builder) {
builder.addQueryParameter("resize", type.toString());
builder.addQueryParameter("w", Integer.toString(width));
builder.addQueryParameter("h", Integer.toString(height));
}
}