added empty var check

This commit is contained in:
Tony Tam 2014-09-27 16:50:36 -07:00
parent 530ebe1f7d
commit 9e5576d3fe
4 changed files with 11 additions and 4 deletions

View File

@ -11,4 +11,5 @@ public class CodegenModel {
public String defaultValue;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
public Set<String> imports = new HashSet<String>();
public Boolean hasVars, emptyVars;
}

View File

@ -353,7 +353,8 @@ public class DefaultCodegen {
m.imports.add(containerType);
}
}
if(impl.getProperties() != null) {
if(impl.getProperties() != null && impl.getProperties().size() > 0) {
m.hasVars = true;
for(String key: impl.getProperties().keySet()) {
Property prop = impl.getProperties().get(key);
@ -396,6 +397,9 @@ public class DefaultCodegen {
}
}
}
else {
m.emptyVars = true;
}
}
return m;
}

View File

@ -3,15 +3,16 @@
#import "SWGDate.h"
#import "{{classname}}.h"
@implementation {{classname}}
@implementation {{classname}}{{#parent}}: {{parent}}{{/parent}}
{{#hasVars}}
-(id){{#vars}}{{name}}: ({{datatype}}) {{name}}{{^hasMore}} { {{/hasMore}}
{{/vars}}
{{#vars}}_{{name}} = {{name}};
{{/vars}}
return self;
}
{{/hasVars}}
-(id) initWithValues:(NSDictionary*)dict
{
self = [super init];

View File

@ -11,10 +11,11 @@
{{#vars}}
@property(nonatomic) {{datatype}} {{name}}; {{#description}}/* {{{description}}} {{#isNotRequired}}[optional]{{/isNotRequired}} */{{/description}}{{newline}}
{{/vars}}
{{#hasVars}}
- (id) {{#vars}}{{name}}: ({{datatype}}) {{name}}{{#hasMore}}
{{/hasMore}}{{^hasMore}};{{/hasMore}}
{{/vars}}
{{newline}}
{{/hasVars}}
- (id) initWithValues: (NSDictionary*)dict;
- (NSDictionary*) asDictionary;
{{newline}}