com.rosetta.externalsynonym.model.Top7 Maven / Gradle / Ivy
package com.rosetta.externalsynonym.model;
import com.rosetta.externalsynonym.model.Contract7;
import com.rosetta.externalsynonym.model.Top7;
import com.rosetta.externalsynonym.model.Top7.Top7Builder;
import com.rosetta.externalsynonym.model.Top7.Top7BuilderImpl;
import com.rosetta.externalsynonym.model.Top7.Top7Impl;
import com.rosetta.externalsynonym.model.meta.Top7Meta;
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="Top7", builder=Top7.Top7BuilderImpl.class, version="test")
public interface Top7 extends RosettaModelObject {
Top7Meta metaData = new Top7Meta();
/*********************** Getter Methods ***********************/
Contract7 getContract();
/*********************** Build Methods ***********************/
Top7 build();
Top7.Top7Builder toBuilder();
static Top7.Top7Builder builder() {
return new Top7.Top7BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top7> metaData() {
return metaData;
}
@Override
default Class extends Top7> getType() {
return Top7.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("contract"), processor, Contract7.class, getContract());
}
/*********************** Builder Interface ***********************/
interface Top7Builder extends Top7, RosettaModelObjectBuilder {
Contract7.Contract7Builder getOrCreateContract();
Contract7.Contract7Builder getContract();
Top7.Top7Builder setContract(Contract7 contract);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("contract"), processor, Contract7.Contract7Builder.class, getContract());
}
Top7.Top7Builder prune();
}
/*********************** Immutable Implementation of Top7 ***********************/
class Top7Impl implements Top7 {
private final Contract7 contract;
protected Top7Impl(Top7.Top7Builder builder) {
this.contract = ofNullable(builder.getContract()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("contract")
public Contract7 getContract() {
return contract;
}
@Override
public Top7 build() {
return this;
}
@Override
public Top7.Top7Builder toBuilder() {
Top7.Top7Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top7.Top7Builder builder) {
ofNullable(getContract()).ifPresent(builder::setContract);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Top7 _that = getType().cast(o);
if (!Objects.equals(contract, _that.getContract())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (contract != null ? contract.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top7 {" +
"contract=" + this.contract +
'}';
}
}
/*********************** Builder Implementation of Top7 ***********************/
class Top7BuilderImpl implements Top7.Top7Builder {
protected Contract7.Contract7Builder contract;
public Top7BuilderImpl() {
}
@Override
@RosettaAttribute("contract")
public Contract7.Contract7Builder getContract() {
return contract;
}
@Override
public Contract7.Contract7Builder getOrCreateContract() {
Contract7.Contract7Builder result;
if (contract!=null) {
result = contract;
}
else {
result = contract = Contract7.builder();
}
return result;
}
@Override
@RosettaAttribute("contract")
public Top7.Top7Builder setContract(Contract7 contract) {
this.contract = contract==null?null:contract.toBuilder();
return this;
}
@Override
public Top7 build() {
return new Top7.Top7Impl(this);
}
@Override
public Top7.Top7Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top7.Top7Builder prune() {
if (contract!=null && !contract.prune().hasData()) contract = null;
return this;
}
@Override
public boolean hasData() {
if (getContract()!=null && getContract().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Top7.Top7Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top7.Top7Builder o = (Top7.Top7Builder) other;
merger.mergeRosetta(getContract(), o.getContract(), this::setContract);
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;
Top7 _that = getType().cast(o);
if (!Objects.equals(contract, _that.getContract())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (contract != null ? contract.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top7Builder {" +
"contract=" + this.contract +
'}';
}
}
}