com.rosetta.roota.model.TopOverride Maven / Gradle / Ivy
package com.rosetta.roota.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.roota.model.A1;
import com.rosetta.roota.model.TopOverride;
import com.rosetta.roota.model.TopOverride.TopOverrideBuilder;
import com.rosetta.roota.model.TopOverride.TopOverrideBuilderImpl;
import com.rosetta.roota.model.TopOverride.TopOverrideImpl;
import com.rosetta.roota.model.meta.TopOverrideMeta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="TopOverride", builder=TopOverride.TopOverrideBuilderImpl.class, version="test")
public interface TopOverride extends RosettaModelObject {
TopOverrideMeta metaData = new TopOverrideMeta();
/*********************** Getter Methods ***********************/
A1 getAField();
/*********************** Build Methods ***********************/
TopOverride build();
TopOverride.TopOverrideBuilder toBuilder();
static TopOverride.TopOverrideBuilder builder() {
return new TopOverride.TopOverrideBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends TopOverride> metaData() {
return metaData;
}
@Override
default Class extends TopOverride> getType() {
return TopOverride.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("aField"), processor, A1.class, getAField());
}
/*********************** Builder Interface ***********************/
interface TopOverrideBuilder extends TopOverride, RosettaModelObjectBuilder {
A1.A1Builder getOrCreateAField();
A1.A1Builder getAField();
TopOverride.TopOverrideBuilder setAField(A1 aField);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("aField"), processor, A1.A1Builder.class, getAField());
}
TopOverride.TopOverrideBuilder prune();
}
/*********************** Immutable Implementation of TopOverride ***********************/
class TopOverrideImpl implements TopOverride {
private final A1 aField;
protected TopOverrideImpl(TopOverride.TopOverrideBuilder builder) {
this.aField = ofNullable(builder.getAField()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("aField")
public A1 getAField() {
return aField;
}
@Override
public TopOverride build() {
return this;
}
@Override
public TopOverride.TopOverrideBuilder toBuilder() {
TopOverride.TopOverrideBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(TopOverride.TopOverrideBuilder 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;
TopOverride _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 "TopOverride {" +
"aField=" + this.aField +
'}';
}
}
/*********************** Builder Implementation of TopOverride ***********************/
class TopOverrideBuilderImpl implements TopOverride.TopOverrideBuilder {
protected A1.A1Builder aField;
public TopOverrideBuilderImpl() {
}
@Override
@RosettaAttribute("aField")
public A1.A1Builder getAField() {
return aField;
}
@Override
public A1.A1Builder getOrCreateAField() {
A1.A1Builder result;
if (aField!=null) {
result = aField;
}
else {
result = aField = A1.builder();
}
return result;
}
@Override
@RosettaAttribute("aField")
public TopOverride.TopOverrideBuilder setAField(A1 aField) {
this.aField = aField==null?null:aField.toBuilder();
return this;
}
@Override
public TopOverride build() {
return new TopOverride.TopOverrideImpl(this);
}
@Override
public TopOverride.TopOverrideBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public TopOverride.TopOverrideBuilder 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 TopOverride.TopOverrideBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
TopOverride.TopOverrideBuilder o = (TopOverride.TopOverrideBuilder) 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;
TopOverride _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 "TopOverrideBuilder {" +
"aField=" + this.aField +
'}';
}
}
}