com.rosetta.jptlegalagreement.model.SimmVersion Maven / Gradle / Ivy
package com.rosetta.jptlegalagreement.model;
import com.rosetta.jptlegalagreement.model.SimmVersion;
import com.rosetta.jptlegalagreement.model.SimmVersion.SimmVersionBuilder;
import com.rosetta.jptlegalagreement.model.SimmVersion.SimmVersionBuilderImpl;
import com.rosetta.jptlegalagreement.model.SimmVersion.SimmVersionImpl;
import com.rosetta.jptlegalagreement.model.SpecifiedSimmVersion;
import com.rosetta.jptlegalagreement.model.meta.SimmVersionMeta;
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="SimmVersion", builder=SimmVersion.SimmVersionBuilderImpl.class, version="test")
public interface SimmVersion extends RosettaModelObject {
SimmVersionMeta metaData = new SimmVersionMeta();
/*********************** Getter Methods ***********************/
Boolean getIsSpecified();
SpecifiedSimmVersion getVersion();
/*********************** Build Methods ***********************/
SimmVersion build();
SimmVersion.SimmVersionBuilder toBuilder();
static SimmVersion.SimmVersionBuilder builder() {
return new SimmVersion.SimmVersionBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends SimmVersion> metaData() {
return metaData;
}
@Override
default Class extends SimmVersion> getType() {
return SimmVersion.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("isSpecified"), Boolean.class, getIsSpecified(), this);
processRosetta(path.newSubPath("version"), processor, SpecifiedSimmVersion.class, getVersion());
}
/*********************** Builder Interface ***********************/
interface SimmVersionBuilder extends SimmVersion, RosettaModelObjectBuilder {
SpecifiedSimmVersion.SpecifiedSimmVersionBuilder getOrCreateVersion();
SpecifiedSimmVersion.SpecifiedSimmVersionBuilder getVersion();
SimmVersion.SimmVersionBuilder setIsSpecified(Boolean isSpecified);
SimmVersion.SimmVersionBuilder setVersion(SpecifiedSimmVersion version);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("isSpecified"), Boolean.class, getIsSpecified(), this);
processRosetta(path.newSubPath("version"), processor, SpecifiedSimmVersion.SpecifiedSimmVersionBuilder.class, getVersion());
}
SimmVersion.SimmVersionBuilder prune();
}
/*********************** Immutable Implementation of SimmVersion ***********************/
class SimmVersionImpl implements SimmVersion {
private final Boolean isSpecified;
private final SpecifiedSimmVersion version;
protected SimmVersionImpl(SimmVersion.SimmVersionBuilder builder) {
this.isSpecified = builder.getIsSpecified();
this.version = ofNullable(builder.getVersion()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("isSpecified")
public Boolean getIsSpecified() {
return isSpecified;
}
@Override
@RosettaAttribute("version")
public SpecifiedSimmVersion getVersion() {
return version;
}
@Override
public SimmVersion build() {
return this;
}
@Override
public SimmVersion.SimmVersionBuilder toBuilder() {
SimmVersion.SimmVersionBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(SimmVersion.SimmVersionBuilder builder) {
ofNullable(getIsSpecified()).ifPresent(builder::setIsSpecified);
ofNullable(getVersion()).ifPresent(builder::setVersion);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
SimmVersion _that = getType().cast(o);
if (!Objects.equals(isSpecified, _that.getIsSpecified())) return false;
if (!Objects.equals(version, _that.getVersion())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (isSpecified != null ? isSpecified.hashCode() : 0);
_result = 31 * _result + (version != null ? version.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "SimmVersion {" +
"isSpecified=" + this.isSpecified + ", " +
"version=" + this.version +
'}';
}
}
/*********************** Builder Implementation of SimmVersion ***********************/
class SimmVersionBuilderImpl implements SimmVersion.SimmVersionBuilder {
protected Boolean isSpecified;
protected SpecifiedSimmVersion.SpecifiedSimmVersionBuilder version;
public SimmVersionBuilderImpl() {
}
@Override
@RosettaAttribute("isSpecified")
public Boolean getIsSpecified() {
return isSpecified;
}
@Override
@RosettaAttribute("version")
public SpecifiedSimmVersion.SpecifiedSimmVersionBuilder getVersion() {
return version;
}
@Override
public SpecifiedSimmVersion.SpecifiedSimmVersionBuilder getOrCreateVersion() {
SpecifiedSimmVersion.SpecifiedSimmVersionBuilder result;
if (version!=null) {
result = version;
}
else {
result = version = SpecifiedSimmVersion.builder();
}
return result;
}
@Override
@RosettaAttribute("isSpecified")
public SimmVersion.SimmVersionBuilder setIsSpecified(Boolean isSpecified) {
this.isSpecified = isSpecified==null?null:isSpecified;
return this;
}
@Override
@RosettaAttribute("version")
public SimmVersion.SimmVersionBuilder setVersion(SpecifiedSimmVersion version) {
this.version = version==null?null:version.toBuilder();
return this;
}
@Override
public SimmVersion build() {
return new SimmVersion.SimmVersionImpl(this);
}
@Override
public SimmVersion.SimmVersionBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public SimmVersion.SimmVersionBuilder prune() {
if (version!=null && !version.prune().hasData()) version = null;
return this;
}
@Override
public boolean hasData() {
if (getIsSpecified()!=null) return true;
if (getVersion()!=null && getVersion().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public SimmVersion.SimmVersionBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
SimmVersion.SimmVersionBuilder o = (SimmVersion.SimmVersionBuilder) other;
merger.mergeRosetta(getVersion(), o.getVersion(), this::setVersion);
merger.mergeBasic(getIsSpecified(), o.getIsSpecified(), this::setIsSpecified);
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;
SimmVersion _that = getType().cast(o);
if (!Objects.equals(isSpecified, _that.getIsSpecified())) return false;
if (!Objects.equals(version, _that.getVersion())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (isSpecified != null ? isSpecified.hashCode() : 0);
_result = 31 * _result + (version != null ? version.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "SimmVersionBuilder {" +
"isSpecified=" + this.isSpecified + ", " +
"version=" + this.version +
'}';
}
}
}