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