ActionBuilder.java
2.59 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
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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.reef.siren.builder;
import com.adobe.reef.siren.Action;
import com.adobe.reef.siren.Field;
import com.adobe.reef.siren.builder.Builder;
import com.adobe.reef.siren.builder.BuilderException;
import com.adobe.reef.siren.builder.BuilderValidationException;
import java.util.LinkedList;
import java.util.List;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class ActionBuilder
extends Builder<Action> {
private String name;
private String[] clazz;
private Action.Method method;
private String href;
private String title;
private String type;
private List<Field> fields = new LinkedList<Field>();
public ActionBuilder setName(String name) {
this.name = name;
return this;
}
public ActionBuilder setClass(String[] clazz) {
this.clazz = clazz;
return this;
}
public ActionBuilder setMethod(Action.Method method) {
this.method = method;
return this;
}
public ActionBuilder setHref(String href) {
this.href = href;
return this;
}
public ActionBuilder setTitle(String title) {
this.title = title;
return this;
}
public ActionBuilder setType(String type) {
this.type = type;
return this;
}
public ActionBuilder setFields(List<Field> fields) {
this.fields = fields;
return this;
}
public ActionBuilder addField(Field field) {
this.fields.add(field);
return this;
}
public ActionBuilder clear() {
this.clazz = null;
this.method = null;
this.type = null;
this.title = null;
this.fields.clear();
return this;
}
@Override
protected Action doBuild() throws BuilderException {
try {
Action action = new Action(this.name, this.href);
action.setClazz(this.clazz);
action.setMethod(this.method);
action.setType(this.type);
action.setTitle(this.title);
action.setFields(this.fields);
return action;
}
catch (IllegalArgumentException e) {
throw new BuilderException(e.getMessage(), e);
}
}
@Override
protected void validate(Action action) throws BuilderValidationException {
if (action.getName() == null || action.getName().isEmpty() || action.getHref() == null || action.getHref().isEmpty()) {
throw new BuilderValidationException("name and href attribute cannot be null or empty.");
}
}
}