- Changed enum class name format
- CodegenProperty parent and parentClass replaced by Booolen flag isInherited
This commit is contained in:
Jakub Malek 2016-06-02 08:14:49 +02:00 committed by Jakub Malek
parent dbc6c2f163
commit 1cfb3d1c9c
6 changed files with 11 additions and 18 deletions

View File

@ -44,8 +44,7 @@ public class CodegenProperty implements Cloneable {
public CodegenProperty items;
public Map<String, Object> vendorExtensions;
public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
public String parent;
public String parentClass;
public Boolean isInherited;
@Override
public String toString() {
@ -108,8 +107,7 @@ public class CodegenProperty implements Cloneable {
result = prime * result + ((isDateTime == null) ? 0 : isDateTime.hashCode());
result = prime * result + ((isMapContainer == null) ? 0 : isMapContainer.hashCode());
result = prime * result + ((isListContainer == null) ? 0 : isListContainer.hashCode());
result = prime * result + Objects.hashCode(parent);
result = prime * result + Objects.hashCode(parentClass);
result = prime * result + Objects.hashCode(isInherited);
return result;
}
@ -261,10 +259,7 @@ public class CodegenProperty implements Cloneable {
if (this.isMapContainer != other.isMapContainer && (this.isMapContainer == null || !this.isMapContainer.equals(other.isMapContainer))) {
return false;
}
if (!Objects.equals(this.parent, other.parent)) {
return false;
}
if (!Objects.equals(this.parentClass, other.parentClass)) {
if (!Objects.equals(this.isInherited, other.isInherited)) {
return false;
}
return true;

View File

@ -264,9 +264,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
if (duplicatedByParent != null) {
log.info(String.format("Property: '%s' in '%s' model is inherited from '%s'" ,
property.name, child.classname, parent.classname));
duplicatedByParent.parent = parent.name;
duplicatedByParent.parentClass = parent.classname;
duplicatedByParent.isInherited = true;
final CodegenProperty parentVar = duplicatedByParent.clone();
parentVar.hasMore = false;
child.parentVars.add(parentVar);
@ -354,7 +352,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
@Override
public String toEnumName(final CodegenProperty property) {
return sanitizeName(camelize(property.name));
return sanitizeName(camelize(property.name)) + "Enum";
}
@Override

View File

@ -1 +1 @@
public enum {{#parentClass}}{{parentClass}}{{/parentClass}}{{^parentClass}}{{classname}}{{/parentClass}}{{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { {{#allowableValues}}{{#enumVars}}{{{name}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} };
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { {{#allowableValues}}{{#enumVars}}{{{name}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} };

View File

@ -18,12 +18,12 @@ namespace {{packageName}}.{{packageContext}}.Models
/// {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
/// </summary>
public {{^hasChildrens}}sealed {{/hasChildrens}}class {{classname}}: {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}>
{ {{#vars}}{{^parent}}
{ {{#vars}}{{^isInherited}}
/// <summary>
/// {{^description}}{{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
/// </summary>
public {{>nullableDataType}} {{name}} { get; private set; }
{{/parent}}{{/vars}}
{{/isInherited}}{{/vars}}
/// <summary>
/// Empty constructor required by some serializers.

View File

@ -18,12 +18,12 @@ namespace {{packageName}}.{{packageContext}}.Models
/// {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
/// </summary>
public {{^hasChildrens}}sealed {{/hasChildrens}}class {{classname}}: {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}>
{ {{#vars}}
{ {{#vars}}{{^isInherited}}
/// <summary>
/// {{^description}}{{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
/// </summary>
public {{>nullableDataType}} {{name}} { get; set; }
{{/vars}}
{{/isInherited}}{{/vars}}
public override string ToString()
{

View File

@ -1 +1 @@
{{#isEnum}}{{#parentClass}}{{parentClass}}{{/parentClass}}{{^parentClass}}{{classname}}{{/parentClass}}{{/isEnum}}{{&datatypeWithEnum}}{{#isEnum}}?{{/isEnum}}
{{&datatypeWithEnum}}{{#isEnum}}?{{/isEnum}}