-
Notifications
You must be signed in to change notification settings - Fork 45
/
Image.java
122 lines (99 loc) · 3.41 KB
/
Image.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*******************************************************************************
* Copyright (c) 2022 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.components.forms;
import java.text.MessageFormat;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import org.eclipse.sirius.components.annotations.Immutable;
import org.eclipse.sirius.components.forms.validation.Diagnostic;
/**
* The Image widget.
*
* @author pcdavid
*/
@Immutable
public final class Image extends AbstractWidget {
private String url;
private String maxWidth;
private Image() {
// Prevent instantiation
}
public String getUrl() {
return this.url;
}
public String getMaxWidth() {
return this.maxWidth;
}
public static Builder newImage(String id) {
return new Builder(id);
}
@Override
public String toString() {
String pattern = "{0} '{'id: {1}, label: {2}, url: {3}, maxWidth: {4}'}'";
return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.getId(), this.label, this.url, this.maxWidth);
}
/**
* The builder used to create the Image.
*
* @author pcdavid
*/
@SuppressWarnings("checkstyle:HiddenField")
public static final class Builder {
private final String id;
private String label;
private String iconURL;
private String url;
private String maxWidth;
private List<Diagnostic> diagnostics;
private Supplier<String> helpTextProvider;
private Builder(String id) {
this.id = Objects.requireNonNull(id);
}
public Builder label(String label) {
this.label = Objects.requireNonNull(label);
return this;
}
public Builder iconURL(String iconURL) {
this.iconURL = Objects.requireNonNull(iconURL);
return this;
}
public Builder url(String url) {
this.url = Objects.requireNonNull(url);
return this;
}
public Builder maxWidth(String maxWidth) {
this.maxWidth = Objects.requireNonNull(maxWidth);
return this;
}
public Builder diagnostics(List<Diagnostic> diagnostics) {
this.diagnostics = Objects.requireNonNull(diagnostics);
return this;
}
public Builder helpTextProvider(Supplier<String> helpTextProvider) {
this.helpTextProvider = Objects.requireNonNull(helpTextProvider);
return this;
}
public Image build() {
Image image = new Image();
image.id = Objects.requireNonNull(this.id);
image.label = Objects.requireNonNull(this.label);
image.iconURL = this.iconURL;
image.url = Objects.requireNonNull(this.url);
image.maxWidth = this.maxWidth;
image.diagnostics = Objects.requireNonNull(this.diagnostics);
image.helpTextProvider = this.helpTextProvider;
return image;
}
}
}