{{>frag/propertyDocumentation}}
{{>frag/propertyStatusAnnotations}}
public {{{chainClassName}}} {{identifier name}}({{{nativeType}}} {{identifier name}}) {
	{{#if nullable}}
	set{{capitalize (identifier name)}}({{identifier name}} != null ? java.util.Optional.of({{identifier name}}) : java.util.Optional.empty());
	{{else}}
	set{{capitalize (identifier name)}}({{identifier name}});
	{{/if}}
	return this;
}

{{#or (isObject) (isMap) (isArray)}}
/**
 * Returns the {{identifier name}}, or if it's {@code null} it first creates a new object,
 * sets the property to the new object, and then returns it.
 */
{{>frag/propertyStatusAnnotations}}
public {{{nativeType}}} {{identifier name}}() {
	{{#if nullable}}
	if (this.{{identifier name}} == null || !this.{{identifier name}}.isPresent()) {
		this.{{identifier name}} = java.util.Optional.of(new {{{nativeType.concreteType}}}());
	}
	return this.{{identifier name}}.get();
	{{else}}
	if (this.{{identifier name}} == null) {
		this.{{identifier name}} = new {{{nativeType.concreteType}}}();
	}
	return this.{{identifier name}};
	{{/if}}
}

{{/or}}
{{#unless @root.useLombok}}
public {{>frag/pojoPropertyType}} {{getter .}}() {
	return this.{{identifier name}};
}

{{>frag/propertyStatusAnnotations}}
public void {{setter .}}({{>frag/pojoPropertyType}} {{identifier name}}) {
	this.{{identifier name}} = {{identifier name}};
}

{{/unless}}
{{#if (isArray)}}
{{>frag/propertyStatusAnnotations}}
public {{{chainClassName}}} add{{capitalize (singular (identifier name))}}({{{schema.component.nativeType}}} {{identifier (singular name)}}) {
	{{#if nullable}}
	if (this.{{identifier name}} == null || !this.{{identifier name}}.isPresent()) {
		this.{{identifier name}} = java.util.Optional.of(new {{{nativeType.concreteType}}}());
	}
	this.{{identifier name}}.get().add({{identifier (singular name)}});
	{{else}}
	if (this.{{identifier name}} == null) {
		this.{{identifier name}} = new {{{nativeType.concreteType}}}();
	}
	this.{{identifier name}}.add({{identifier (singular name)}});
	{{/if}}
	return this;
}

{{#if (isObject schema.component)}}
{{>frag/propertyStatusAnnotations}}
public {{{schema.component.nativeType}}} add{{capitalize (singular (identifier name))}}() {
	{{{schema.component.nativeType}}} {{identifier (singular name)}} = new {{{schema.component.nativeType.concreteType}}}();
	add{{capitalize (singular (identifier name))}}({{identifier (singular name)}});
	return {{identifier (singular name)}};
}

{{/if}}
{{/if}}
