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 String defaultValue;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>(); public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
public Set<String> imports = new HashSet<String>(); public Set<String> imports = new HashSet<String>();
public Boolean hasVars, emptyVars;
} }

View File

@ -353,7 +353,8 @@ public class DefaultCodegen {
m.imports.add(containerType); 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()) { for(String key: impl.getProperties().keySet()) {
Property prop = impl.getProperties().get(key); Property prop = impl.getProperties().get(key);
@ -396,6 +397,9 @@ public class DefaultCodegen {
} }
} }
} }
else {
m.emptyVars = true;
}
} }
return m; return m;
} }

View File

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

View File

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