22
22
import java .util .*;
23
23
24
24
import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
25
+ import org .apache .commons .lang3 .builder .ToStringBuilder ;
25
26
26
27
@ JsonIgnoreProperties ({"parentModel" , "interfaceModels" })
27
28
public class CodegenModel {
28
29
public String parent , parentSchema ;
29
30
public List <String > interfaces ;
31
+ public List <String > allParents ;
30
32
31
33
// References to parent and interface CodegenModels. Only set when code generator supports inheritance.
32
34
public CodegenModel parentModel ;
@@ -46,18 +48,18 @@ public class CodegenModel {
46
48
public String arrayModelType ;
47
49
public boolean isAlias ; // Is this effectively an alias of another simple type
48
50
public boolean isString , isInteger ;
49
- public List <CodegenProperty > vars = new ArrayList <CodegenProperty >();
51
+ public List <CodegenProperty > vars = new ArrayList <CodegenProperty >(); // all properties (without parent's properties)
52
+ public List <CodegenProperty > allVars = new ArrayList <CodegenProperty >(); // all properties (with parent's properties)
50
53
public List <CodegenProperty > requiredVars = new ArrayList <CodegenProperty >(); // a list of required properties
51
54
public List <CodegenProperty > optionalVars = new ArrayList <CodegenProperty >(); // a list of optional properties
52
55
public List <CodegenProperty > readOnlyVars = new ArrayList <CodegenProperty >(); // a list of read-only properties
53
56
public List <CodegenProperty > readWriteVars = new ArrayList <CodegenProperty >(); // a list of properties for read, write
54
- public List <CodegenProperty > allVars = new ArrayList <CodegenProperty >();
55
57
public List <CodegenProperty > parentVars = new ArrayList <CodegenProperty >();
56
58
public Map <String , Object > allowableValues ;
57
59
58
60
// Sorted sets of required parameters.
59
- public Set <String > mandatory = new TreeSet <String >();
60
- public Set <String > allMandatory ;
61
+ public Set <String > mandatory = new TreeSet <String >(); // without parent's required properties
62
+ public Set <String > allMandatory = new TreeSet < String >(); // with parent's required properties
61
63
62
64
public Set <String > imports = new TreeSet <String >();
63
65
public boolean hasVars , emptyVars , hasMoreModels , hasEnums , isEnum , hasRequired , hasOptional , isArrayModel , hasChildren , isMapModel ;
@@ -69,16 +71,59 @@ public class CodegenModel {
69
71
//The type of the value from additional properties. Used in map like objects.
70
72
public String additionalPropertiesType ;
71
73
72
- {
73
- // By default these are the same collections. Where the code generator supports inheritance, composed models
74
- // store the complete closure of owned and inherited properties in allVars and allMandatory.
75
- allVars = vars ;
76
- allMandatory = mandatory ;
77
- }
78
-
79
74
@ Override
80
75
public String toString () {
81
- return String .format (Locale .ROOT , "%s(%s)" , name , classname );
76
+ return new ToStringBuilder (this )
77
+ .append ("parent" , parent )
78
+ .append ("parentSchema" , parentSchema )
79
+ .append ("interfaces" , interfaces )
80
+ .append ("parentModel" , parentModel )
81
+ .append ("interfaceModels" , interfaceModels )
82
+ .append ("children" , children )
83
+ .append ("name" , name )
84
+ .append ("classname" , classname )
85
+ .append ("title" , title )
86
+ .append ("description" , description )
87
+ .append ("classVarName" , classVarName )
88
+ .append ("modelJson" , modelJson )
89
+ .append ("dataType" , dataType )
90
+ .append ("xmlPrefix" , xmlPrefix )
91
+ .append ("xmlNamespace" , xmlNamespace )
92
+ .append ("xmlName" , xmlName )
93
+ .append ("classFilename" , classFilename )
94
+ .append ("unescapedDescription" , unescapedDescription )
95
+ .append ("discriminator" , discriminator )
96
+ .append ("defaultValue" , defaultValue )
97
+ .append ("arrayModelType" , arrayModelType )
98
+ .append ("isAlias" , isAlias )
99
+ .append ("isString" , isString )
100
+ .append ("isInteger" , isInteger )
101
+ .append ("vars" , vars )
102
+ .append ("requiredVars" , requiredVars )
103
+ .append ("optionalVars" , optionalVars )
104
+ .append ("readOnlyVars" , readOnlyVars )
105
+ .append ("readWriteVars" , readWriteVars )
106
+ .append ("allVars" , allVars )
107
+ .append ("parentVars" , parentVars )
108
+ .append ("allowableValues" , allowableValues )
109
+ .append ("mandatory" , mandatory )
110
+ .append ("allMandatory" , allMandatory )
111
+ .append ("imports" , imports )
112
+ .append ("hasVars" , hasVars )
113
+ .append ("emptyVars" , emptyVars )
114
+ .append ("hasMoreModels" , hasMoreModels )
115
+ .append ("hasEnums" , hasEnums )
116
+ .append ("isEnum" , isEnum )
117
+ .append ("hasRequired" , hasRequired )
118
+ .append ("hasOptional" , hasOptional )
119
+ .append ("isArrayModel" , isArrayModel )
120
+ .append ("hasChildren" , hasChildren )
121
+ .append ("isMapModel" , isMapModel )
122
+ .append ("hasOnlyReadOnly" , hasOnlyReadOnly )
123
+ .append ("externalDocumentation" , externalDocumentation )
124
+ .append ("vendorExtensions" , vendorExtensions )
125
+ .append ("additionalPropertiesType" , additionalPropertiesType )
126
+ .toString ();
82
127
}
83
128
84
129
@ Override
@@ -94,6 +139,8 @@ public boolean equals(Object o) {
94
139
return false ;
95
140
if (interfaces != null ? !interfaces .equals (that .interfaces ) : that .interfaces != null )
96
141
return false ;
142
+ if (allParents != null ? !allParents .equals (that .allParents ) : that .allParents != null )
143
+ return false ;
97
144
if (parentModel != null ? !parentModel .equals (that .parentModel ) : that .parentModel != null )
98
145
return false ;
99
146
if (interfaceModels != null ? !interfaceModels .equals (that .interfaceModels ) : that .interfaceModels != null )
@@ -169,6 +216,7 @@ public int hashCode() {
169
216
int result = parent != null ? parent .hashCode () : 0 ;
170
217
result = 31 * result + (parentSchema != null ? parentSchema .hashCode () : 0 );
171
218
result = 31 * result + (interfaces != null ? interfaces .hashCode () : 0 );
219
+ result = 31 * result + (allParents != null ? allParents .hashCode () : 0 );
172
220
result = 31 * result + (parentModel != null ? parentModel .hashCode () : 0 );
173
221
result = 31 * result + (interfaceModels != null ? interfaceModels .hashCode () : 0 );
174
222
result = 31 * result + (name != null ? name .hashCode () : 0 );
@@ -226,10 +274,18 @@ public List<String> getInterfaces() {
226
274
return interfaces ;
227
275
}
228
276
277
+ public List <String > getAllParents () {
278
+ return allParents ;
279
+ }
280
+
229
281
public void setInterfaces (List <String > interfaces ) {
230
282
this .interfaces = interfaces ;
231
283
}
232
284
285
+ public void setAllParents (List <String > allParents ) {
286
+ this .allParents = allParents ;
287
+ }
288
+
233
289
public CodegenModel getParentModel () {
234
290
return parentModel ;
235
291
}
0 commit comments