com.rosetta.testcard.model.Top4_5 Maven / Gradle / Ivy
package com.rosetta.testcard.model;
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 com.rosetta.testcard.model.A4_5;
import com.rosetta.testcard.model.Top4_5;
import com.rosetta.testcard.model.Top4_5.Top4_5Builder;
import com.rosetta.testcard.model.Top4_5.Top4_5BuilderImpl;
import com.rosetta.testcard.model.Top4_5.Top4_5Impl;
import com.rosetta.testcard.model.meta.Top4_5Meta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Top4_5", builder=Top4_5.Top4_5BuilderImpl.class, version="test")
public interface Top4_5 extends RosettaModelObject {
Top4_5Meta metaData = new Top4_5Meta();
/*********************** Getter Methods ***********************/
A4_5 getAField();
/*********************** Build Methods ***********************/
Top4_5 build();
Top4_5.Top4_5Builder toBuilder();
static Top4_5.Top4_5Builder builder() {
return new Top4_5.Top4_5BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Top4_5> metaData() {
return metaData;
}
@Override
default Class extends Top4_5> getType() {
return Top4_5.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("aField"), processor, A4_5.class, getAField());
}
/*********************** Builder Interface ***********************/
interface Top4_5Builder extends Top4_5, RosettaModelObjectBuilder {
A4_5.A4_5Builder getOrCreateAField();
A4_5.A4_5Builder getAField();
Top4_5.Top4_5Builder setAField(A4_5 aField);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("aField"), processor, A4_5.A4_5Builder.class, getAField());
}
Top4_5.Top4_5Builder prune();
}
/*********************** Immutable Implementation of Top4_5 ***********************/
class Top4_5Impl implements Top4_5 {
private final A4_5 aField;
protected Top4_5Impl(Top4_5.Top4_5Builder builder) {
this.aField = ofNullable(builder.getAField()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("aField")
public A4_5 getAField() {
return aField;
}
@Override
public Top4_5 build() {
return this;
}
@Override
public Top4_5.Top4_5Builder toBuilder() {
Top4_5.Top4_5Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Top4_5.Top4_5Builder builder) {
ofNullable(getAField()).ifPresent(builder::setAField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Top4_5 _that = getType().cast(o);
if (!Objects.equals(aField, _that.getAField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (aField != null ? aField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top4_5 {" +
"aField=" + this.aField +
'}';
}
}
/*********************** Builder Implementation of Top4_5 ***********************/
class Top4_5BuilderImpl implements Top4_5.Top4_5Builder {
protected A4_5.A4_5Builder aField;
public Top4_5BuilderImpl() {
}
@Override
@RosettaAttribute("aField")
public A4_5.A4_5Builder getAField() {
return aField;
}
@Override
public A4_5.A4_5Builder getOrCreateAField() {
A4_5.A4_5Builder result;
if (aField!=null) {
result = aField;
}
else {
result = aField = A4_5.builder();
}
return result;
}
@Override
@RosettaAttribute("aField")
public Top4_5.Top4_5Builder setAField(A4_5 aField) {
this.aField = aField==null?null:aField.toBuilder();
return this;
}
@Override
public Top4_5 build() {
return new Top4_5.Top4_5Impl(this);
}
@Override
public Top4_5.Top4_5Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Top4_5.Top4_5Builder prune() {
if (aField!=null && !aField.prune().hasData()) aField = null;
return this;
}
@Override
public boolean hasData() {
if (getAField()!=null && getAField().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Top4_5.Top4_5Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Top4_5.Top4_5Builder o = (Top4_5.Top4_5Builder) other;
merger.mergeRosetta(getAField(), o.getAField(), this::setAField);
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;
Top4_5 _that = getType().cast(o);
if (!Objects.equals(aField, _that.getAField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (aField != null ? aField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Top4_5Builder {" +
"aField=" + this.aField +
'}';
}
}
}