1 | |
package org.jtheque.core.utils.ui.constraints; |
2 | |
|
3 | |
import org.jtheque.core.managers.Managers; |
4 | |
import org.jtheque.core.managers.error.InternationalizedError; |
5 | |
import org.jtheque.core.managers.error.JThequeError; |
6 | |
import org.jtheque.core.managers.language.ILanguageManager; |
7 | |
|
8 | |
import java.util.Collection; |
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public final class NotNullConstraint implements Constraint { |
32 | |
private final String fieldName; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public NotNullConstraint(String fieldName) { |
40 | 0 | super(); |
41 | |
|
42 | 0 | this.fieldName = fieldName; |
43 | 0 | } |
44 | |
|
45 | |
@Override |
46 | |
public int maxLength() { |
47 | 0 | return -1; |
48 | |
} |
49 | |
|
50 | |
@Override |
51 | |
public boolean mustBeNumerical() { |
52 | 0 | return false; |
53 | |
} |
54 | |
|
55 | |
@Override |
56 | |
public boolean canBeNullOrEmpty() { |
57 | 0 | return false; |
58 | |
} |
59 | |
|
60 | |
@Override |
61 | |
public boolean mustControlLength() { |
62 | 0 | return false; |
63 | |
} |
64 | |
|
65 | |
@Override |
66 | |
public void validate(Object field, Collection<JThequeError> errors) { |
67 | 0 | if (field == null) { |
68 | 0 | errors.add(new InternationalizedError("error.validation.field.empty", new Object[]{Managers.getManager(ILanguageManager.class).getMessage(fieldName)})); |
69 | |
} |
70 | 0 | } |
71 | |
} |