forked from loafle/openapi-generator-original
[java] Microprofile - fix optional array property's default value (#16500)
This commit is contained in:
committed by
GitHub
parent
616e8df8d0
commit
4418b59b47
@@ -126,6 +126,9 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
|
|||||||
{{#isArray}}
|
{{#isArray}}
|
||||||
|
|
||||||
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
|
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||||
|
if (this.{{name}} == null) {
|
||||||
|
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}};
|
||||||
|
}
|
||||||
this.{{name}}.add({{name}}Item);
|
this.{{name}}.add({{name}}Item);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -133,6 +136,9 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
|
|||||||
{{#isMap}}
|
{{#isMap}}
|
||||||
|
|
||||||
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
|
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||||
|
if (this.{{name}} == null) {
|
||||||
|
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}};
|
||||||
|
}
|
||||||
this.{{name}}.put(key, {{name}}Item);
|
this.{{name}}.put(key, {{name}}Item);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,6 +217,9 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||||
|
if (this.photoUrls == null) {
|
||||||
|
this.photoUrls = new ArrayList<>();
|
||||||
|
}
|
||||||
this.photoUrls.add(photoUrlsItem);
|
this.photoUrls.add(photoUrlsItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -252,6 +255,9 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pet addTagsItem(Tag tagsItem) {
|
public Pet addTagsItem(Tag tagsItem) {
|
||||||
|
if (this.tags == null) {
|
||||||
|
this.tags = new ArrayList<>();
|
||||||
|
}
|
||||||
this.tags.add(tagsItem);
|
this.tags.add(tagsItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,9 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||||
|
if (this.photoUrls == null) {
|
||||||
|
this.photoUrls = new ArrayList<>();
|
||||||
|
}
|
||||||
this.photoUrls.add(photoUrlsItem);
|
this.photoUrls.add(photoUrlsItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -224,6 +227,9 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pet addTagsItem(Tag tagsItem) {
|
public Pet addTagsItem(Tag tagsItem) {
|
||||||
|
if (this.tags == null) {
|
||||||
|
this.tags = new ArrayList<>();
|
||||||
|
}
|
||||||
this.tags.add(tagsItem);
|
this.tags.add(tagsItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,9 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||||
|
if (this.photoUrls == null) {
|
||||||
|
this.photoUrls = new ArrayList<>();
|
||||||
|
}
|
||||||
this.photoUrls.add(photoUrlsItem);
|
this.photoUrls.add(photoUrlsItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -203,6 +206,9 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pet addTagsItem(Tag tagsItem) {
|
public Pet addTagsItem(Tag tagsItem) {
|
||||||
|
if (this.tags == null) {
|
||||||
|
this.tags = new ArrayList<>();
|
||||||
|
}
|
||||||
this.tags.add(tagsItem);
|
this.tags.add(tagsItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,9 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||||
|
if (this.photoUrls == null) {
|
||||||
|
this.photoUrls = new ArrayList<>();
|
||||||
|
}
|
||||||
this.photoUrls.add(photoUrlsItem);
|
this.photoUrls.add(photoUrlsItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -203,6 +206,9 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pet addTagsItem(Tag tagsItem) {
|
public Pet addTagsItem(Tag tagsItem) {
|
||||||
|
if (this.tags == null) {
|
||||||
|
this.tags = new ArrayList<>();
|
||||||
|
}
|
||||||
this.tags.add(tagsItem);
|
this.tags.add(tagsItem);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user