11package cn .vika .client .api .model .builder ;
22
33import cn .vika .client .api .model .CreateFieldRequest ;
4- import cn .vika .client .api .model .field .FieldType ;
4+ import cn .vika .client .api .model .field .FieldTypeEnum ;
55import cn .vika .client .api .model .field .property .BaseFieldProperty ;
66import cn .vika .client .api .model .field .property .EmptyProperty ;
77
88/**
9+ * step builder
10+ *
911 * @author tao
1012 */
11- public class CreateFieldRequestBuilder {
13+ public class CreateFieldRequestBuilder implements IFieldTypeOfCreateField , INameOfCreateField , IPropertyOfCreateField {
1214
13- public static IFieldTypeOfCreateField create () {
14- return new FieldTypeOfCreateField (new ContextOfCreateField ());
15- }
16-
17- }
18-
19- class ContextOfCreateField {
20- private FieldType fieldType ;
21- private String name ;
22- private BaseFieldProperty property ;
23-
24- public FieldType getFieldType () {
25- return fieldType ;
26- }
27-
28- public void setFieldType (FieldType fieldType ) {
29- this .fieldType = fieldType ;
30- }
31-
32- public String getName () {
33- return name ;
34- }
35-
36- public void setName (String name ) {
37- this .name = name ;
38- }
15+ private final ContextOfCreateField context ;
3916
40- public BaseFieldProperty getProperty () {
41- return property ;
17+ public static IFieldTypeOfCreateField create () {
18+ return new CreateFieldRequestBuilder () ;
4219 }
4320
44- public void setProperty (BaseFieldProperty property ) {
45- this .property = property ;
46- }
47- }
48-
49- class FieldTypeOfCreateField implements IFieldTypeOfCreateField {
50-
51- private final ContextOfCreateField context ;
52-
53- FieldTypeOfCreateField (ContextOfCreateField context ) {
54- this .context = context ;
21+ public CreateFieldRequestBuilder () {
22+ context = new ContextOfCreateField ();
5523 }
5624
5725 @ Override
58- public INameOfCreateField ofType (FieldType fieldType ) {
26+ public INameOfCreateField ofType (FieldTypeEnum fieldType ) {
5927 context .setFieldType (fieldType );
60- return new NameOfCreateField (context );
61- }
62-
63- }
64-
65- class NameOfCreateField implements INameOfCreateField {
66-
67- private final ContextOfCreateField context ;
68-
69- NameOfCreateField (ContextOfCreateField context ) {
70- this .context = context ;
28+ return this ;
7129 }
7230
7331 @ Override
7432 public IPropertyOfCreateField withName (String name ) {
7533 context .setName (name );
76- return new PropertyOfCreateField (context );
77- }
78-
79- }
80-
81- class PropertyOfCreateField implements IPropertyOfCreateField {
82-
83- private final ContextOfCreateField context ;
84-
85- PropertyOfCreateField (ContextOfCreateField context ) {
86- this .context = context ;
34+ return this ;
8735 }
8836
8937 @ Override
9038 public <T extends BaseFieldProperty > IBuildCreateField <T > withProperty (T property ) {
91-
9239 context .setProperty (property );
9340 return new BuildCreateField <>(context );
9441 }
9542
9643 @ Override
9744 public IBuildCreateField <EmptyProperty > withoutProperty () {
98- context .setProperty (new EmptyProperty ());
9945 return new BuildCreateField <>(context );
10046 }
47+
10148}
10249
103- class BuildCreateField <T extends BaseFieldProperty > implements IBuildCreateField <T > {
50+ class BuildCreateField <T extends BaseFieldProperty > implements IBuildCreateField <T > {
10451
10552 private final ContextOfCreateField context ;
10653
@@ -120,3 +67,37 @@ public CreateFieldRequest<T> build() {
12067}
12168
12269
70+ class ContextOfCreateField {
71+
72+ private FieldTypeEnum fieldType ;
73+
74+ private String name ;
75+
76+ private BaseFieldProperty property ;
77+
78+ public FieldTypeEnum getFieldType () {
79+ return fieldType ;
80+ }
81+
82+ public void setFieldType (FieldTypeEnum fieldType ) {
83+ this .fieldType = fieldType ;
84+ }
85+
86+ public String getName () {
87+ return name ;
88+ }
89+
90+ public void setName (String name ) {
91+ this .name = name ;
92+ }
93+
94+ public BaseFieldProperty getProperty () {
95+ return property ;
96+ }
97+
98+ public void setProperty (BaseFieldProperty property ) {
99+ this .property = property ;
100+ }
101+ }
102+
103+
0 commit comments