io.protostuff.generator.java.builder.stg Maven / Gradle / Ivy
delimiters "<", ">"
import "io/protostuff/generator/java/message-base.stg"
builder(message) ::= <<
public static final class Builder {
private Builder() {
}
public Builder mergeFrom( instance) {
return this;
}
public build() {
result = new ();
return result;
}
}
>>
builder_merge_from(field) ::= <<
this.(instance.());
this.(instance.());
if (instance.()) {
this.(instance.());
}
>>
oneof_cleaner(oneOf) ::= <<
public Builder () {
= .;
= null;
return this;
}
>>
copy_bit_field(name) ::= <<
result. = ;
>>
copy_field(field) ::= <%
result. = java.util.Collections.unmodifiableMap(this.);
result. = java.util.Collections.unmodifiableList(this.);
result. = this.;
%>
copy_oneof_field(oneOf) ::= <<
result. = this.;
result. = this.;
>>
builder_factory_method(message) ::= <<
public static Builder newBuilder() {
return new Builder();
}
>>
builder_field_accessors(field) ::= <<
public () {
if ( == .) {
return .valueOf((int) );
}
return ;
}
public Builder ( value) {
this. = value.getNumber();
this. = .;
return this;
}
public int () {
if ( == .) {
return (int) ;
}
return 0;
}
public Builder (int value) {
this. = value;
this. = .;
return this;
}
public () {
if ( == .) {
return () ;
}
return ;
}
public Builder ( value) {
this. = value;
this. = .;
return this;
}
public boolean () {
return == .;
}
public () {
return ;
}
public Builder ( key, value) {
if (key == null) {
throw new NullPointerException("Cannot set # - map key is null");
}
if (value == null) {
throw new NullPointerException("Cannot set # - map value is null");
}
this..put(key, value);
return this;
}
public Builder (java.util.Map\<, \> map) {
if (map == null) {
throw new NullPointerException("Cannot set # to null");
}
this..putAll(map);
return this;
}
public Builder () {
this. = java.util.Collections.emptyMap();
&= ~;
return this;
}
public int () {
return .size();
}
public ( key) {
return .get(key);
}
public (int index) {
return .valueOf(.get(index));
}
public () {
return new io.protostuff.ListAdapter\<>(, ::valueOf);
}
public int () {
return .size();
}
public java.util.List\ () {
return ;
}
public int (int index) {
return .get(index);
}
public Builder (int index, value) {
this..set(index, value.getNumber());
return this;
}
public Builder (int index, int value) {
this..set(index, value);
return this;
}
public Builder ( value) {
this..add(value.getNumber());
return this;
}
public Builder (int value) {
this..add(value);
return this;
}
public Builder ( values) {
if (values == null) {
throw new NullPointerException("Cannot set # to null");
}
for (final value : values) {
if (value == null) {
throw new NullPointerException("Cannot set # to null");
}
this..add(value.getNumber());
}
return this;
}
public Builder (java.lang.Iterable\ values) {
if (values == null) {
throw new NullPointerException("Cannot set # to null");
}
for (Integer value : values) {
if (value == null) {
throw new NullPointerException("Cannot set # to null");
}
this..add(value);
}
return this;
}
public Builder () {
this. = java.util.Collections.emptyList();
&= ~;
return this;
}
public () {
return ;
}
public Builder (int index, value) {
this..set(index, value);
return this;
}
public Builder ( value) {
this..add(value);
return this;
}
public Builder ( values) {
if (values == null) {
throw new NullPointerException("Cannot set # to null");
}
for (final value : values) {
if (value == null) {
throw new NullPointerException("Cannot set # to null");
}
this..add(value);
}
return this;
}
public Builder () {
this. = java.util.Collections.emptyList();
&= ~;
return this;
}
public int () {
return .size();
}
public (int index) {
return .get(index);
}
public () {
return .valueOf();
}
public int () {
return ;
}
public Builder ( value) {
this. = value.getNumber();
|= ;
return this;
}
public Builder (int value) {
this. = value;
|= ;
return this;
}
public Builder () {
this. = 0;
&= ~;
return this;
}
public boolean () {
return ( & ) == ;
}
public () {
return ;
}
public Builder