com.rosetta.jsonparsingtests.model.Parties Maven / Gradle / Ivy
package com.rosetta.jsonparsingtests.model;
import com.rosetta.jsonparsingtests.model.Parties;
import com.rosetta.jsonparsingtests.model.Parties.PartiesBuilder;
import com.rosetta.jsonparsingtests.model.Parties.PartiesBuilderImpl;
import com.rosetta.jsonparsingtests.model.Parties.PartiesImpl;
import com.rosetta.jsonparsingtests.model.meta.PartiesMeta;
import com.rosetta.model.lib.RosettaModelObject;
import com.rosetta.model.lib.RosettaModelObjectBuilder;
import com.rosetta.model.lib.annotations.RosettaAttribute;
import com.rosetta.model.lib.annotations.RosettaDataType;
import com.rosetta.model.lib.meta.RosettaMetaData;
import com.rosetta.model.lib.path.RosettaPath;
import com.rosetta.model.lib.process.BuilderMerger;
import com.rosetta.model.lib.process.BuilderProcessor;
import com.rosetta.model.lib.process.Processor;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Parties", builder=Parties.PartiesBuilderImpl.class, version="test")
public interface Parties extends RosettaModelObject {
PartiesMeta metaData = new PartiesMeta();
/*********************** Getter Methods ***********************/
String getAName();
String getBName();
/*********************** Build Methods ***********************/
Parties build();
Parties.PartiesBuilder toBuilder();
static Parties.PartiesBuilder builder() {
return new Parties.PartiesBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Parties> metaData() {
return metaData;
}
@Override
default Class extends Parties> getType() {
return Parties.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("aName"), String.class, getAName(), this);
processor.processBasic(path.newSubPath("bName"), String.class, getBName(), this);
}
/*********************** Builder Interface ***********************/
interface PartiesBuilder extends Parties, RosettaModelObjectBuilder {
Parties.PartiesBuilder setAName(String aName);
Parties.PartiesBuilder setBName(String bName);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("aName"), String.class, getAName(), this);
processor.processBasic(path.newSubPath("bName"), String.class, getBName(), this);
}
Parties.PartiesBuilder prune();
}
/*********************** Immutable Implementation of Parties ***********************/
class PartiesImpl implements Parties {
private final String aName;
private final String bName;
protected PartiesImpl(Parties.PartiesBuilder builder) {
this.aName = builder.getAName();
this.bName = builder.getBName();
}
@Override
@RosettaAttribute("aName")
public String getAName() {
return aName;
}
@Override
@RosettaAttribute("bName")
public String getBName() {
return bName;
}
@Override
public Parties build() {
return this;
}
@Override
public Parties.PartiesBuilder toBuilder() {
Parties.PartiesBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Parties.PartiesBuilder builder) {
ofNullable(getAName()).ifPresent(builder::setAName);
ofNullable(getBName()).ifPresent(builder::setBName);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Parties _that = getType().cast(o);
if (!Objects.equals(aName, _that.getAName())) return false;
if (!Objects.equals(bName, _that.getBName())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (aName != null ? aName.hashCode() : 0);
_result = 31 * _result + (bName != null ? bName.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Parties {" +
"aName=" + this.aName + ", " +
"bName=" + this.bName +
'}';
}
}
/*********************** Builder Implementation of Parties ***********************/
class PartiesBuilderImpl implements Parties.PartiesBuilder {
protected String aName;
protected String bName;
public PartiesBuilderImpl() {
}
@Override
@RosettaAttribute("aName")
public String getAName() {
return aName;
}
@Override
@RosettaAttribute("bName")
public String getBName() {
return bName;
}
@Override
@RosettaAttribute("aName")
public Parties.PartiesBuilder setAName(String aName) {
this.aName = aName==null?null:aName;
return this;
}
@Override
@RosettaAttribute("bName")
public Parties.PartiesBuilder setBName(String bName) {
this.bName = bName==null?null:bName;
return this;
}
@Override
public Parties build() {
return new Parties.PartiesImpl(this);
}
@Override
public Parties.PartiesBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Parties.PartiesBuilder prune() {
return this;
}
@Override
public boolean hasData() {
if (getAName()!=null) return true;
if (getBName()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Parties.PartiesBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Parties.PartiesBuilder o = (Parties.PartiesBuilder) other;
merger.mergeBasic(getAName(), o.getAName(), this::setAName);
merger.mergeBasic(getBName(), o.getBName(), this::setBName);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Parties _that = getType().cast(o);
if (!Objects.equals(aName, _that.getAName())) return false;
if (!Objects.equals(bName, _that.getBName())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (aName != null ? aName.hashCode() : 0);
_result = 31 * _result + (bName != null ? bName.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PartiesBuilder {" +
"aName=" + this.aName + ", " +
"bName=" + this.bName +
'}';
}
}
}