com.rosetta.jptlegalagreement.model.ConditionsPrecedent Maven / Gradle / Ivy
The newest version!
package com.rosetta.jptlegalagreement.model;
import com.rosetta.jptlegalagreement.model.Conditions;
import com.rosetta.jptlegalagreement.model.Conditions.ConditionsBuilder;
import com.rosetta.jptlegalagreement.model.ConditionsPrecedent;
import com.rosetta.jptlegalagreement.model.ConditionsPrecedent.ConditionsPrecedentBuilder;
import com.rosetta.jptlegalagreement.model.ConditionsPrecedent.ConditionsPrecedentBuilderImpl;
import com.rosetta.jptlegalagreement.model.ConditionsPrecedent.ConditionsPrecedentImpl;
import com.rosetta.jptlegalagreement.model.meta.ConditionsPrecedentMeta;
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="ConditionsPrecedent", builder=ConditionsPrecedent.ConditionsPrecedentBuilderImpl.class, version="test")
public interface ConditionsPrecedent extends RosettaModelObject {
ConditionsPrecedentMeta metaData = new ConditionsPrecedentMeta();
/*********************** Getter Methods ***********************/
String getCustomProvisions();
Conditions getConditions();
/*********************** Build Methods ***********************/
ConditionsPrecedent build();
ConditionsPrecedent.ConditionsPrecedentBuilder toBuilder();
static ConditionsPrecedent.ConditionsPrecedentBuilder builder() {
return new ConditionsPrecedent.ConditionsPrecedentBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends ConditionsPrecedent> metaData() {
return metaData;
}
@Override
default Class extends ConditionsPrecedent> getType() {
return ConditionsPrecedent.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("customProvisions"), String.class, getCustomProvisions(), this);
processRosetta(path.newSubPath("conditions"), processor, Conditions.class, getConditions());
}
/*********************** Builder Interface ***********************/
interface ConditionsPrecedentBuilder extends ConditionsPrecedent, RosettaModelObjectBuilder {
Conditions.ConditionsBuilder getOrCreateConditions();
@Override
Conditions.ConditionsBuilder getConditions();
ConditionsPrecedent.ConditionsPrecedentBuilder setCustomProvisions(String customProvisions);
ConditionsPrecedent.ConditionsPrecedentBuilder setConditions(Conditions conditions);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("customProvisions"), String.class, getCustomProvisions(), this);
processRosetta(path.newSubPath("conditions"), processor, Conditions.ConditionsBuilder.class, getConditions());
}
ConditionsPrecedent.ConditionsPrecedentBuilder prune();
}
/*********************** Immutable Implementation of ConditionsPrecedent ***********************/
class ConditionsPrecedentImpl implements ConditionsPrecedent {
private final String customProvisions;
private final Conditions conditions;
protected ConditionsPrecedentImpl(ConditionsPrecedent.ConditionsPrecedentBuilder builder) {
this.customProvisions = builder.getCustomProvisions();
this.conditions = ofNullable(builder.getConditions()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("customProvisions")
public String getCustomProvisions() {
return customProvisions;
}
@Override
@RosettaAttribute("conditions")
public Conditions getConditions() {
return conditions;
}
@Override
public ConditionsPrecedent build() {
return this;
}
@Override
public ConditionsPrecedent.ConditionsPrecedentBuilder toBuilder() {
ConditionsPrecedent.ConditionsPrecedentBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(ConditionsPrecedent.ConditionsPrecedentBuilder builder) {
ofNullable(getCustomProvisions()).ifPresent(builder::setCustomProvisions);
ofNullable(getConditions()).ifPresent(builder::setConditions);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
ConditionsPrecedent _that = getType().cast(o);
if (!Objects.equals(customProvisions, _that.getCustomProvisions())) return false;
if (!Objects.equals(conditions, _that.getConditions())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (customProvisions != null ? customProvisions.hashCode() : 0);
_result = 31 * _result + (conditions != null ? conditions.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ConditionsPrecedent {" +
"customProvisions=" + this.customProvisions + ", " +
"conditions=" + this.conditions +
'}';
}
}
/*********************** Builder Implementation of ConditionsPrecedent ***********************/
class ConditionsPrecedentBuilderImpl implements ConditionsPrecedent.ConditionsPrecedentBuilder {
protected String customProvisions;
protected Conditions.ConditionsBuilder conditions;
@Override
@RosettaAttribute("customProvisions")
public String getCustomProvisions() {
return customProvisions;
}
@Override
@RosettaAttribute("conditions")
public Conditions.ConditionsBuilder getConditions() {
return conditions;
}
@Override
public Conditions.ConditionsBuilder getOrCreateConditions() {
Conditions.ConditionsBuilder result;
if (conditions!=null) {
result = conditions;
}
else {
result = conditions = Conditions.builder();
}
return result;
}
@Override
@RosettaAttribute("customProvisions")
public ConditionsPrecedent.ConditionsPrecedentBuilder setCustomProvisions(String _customProvisions) {
this.customProvisions = _customProvisions == null ? null : _customProvisions;
return this;
}
@Override
@RosettaAttribute("conditions")
public ConditionsPrecedent.ConditionsPrecedentBuilder setConditions(Conditions _conditions) {
this.conditions = _conditions == null ? null : _conditions.toBuilder();
return this;
}
@Override
public ConditionsPrecedent build() {
return new ConditionsPrecedent.ConditionsPrecedentImpl(this);
}
@Override
public ConditionsPrecedent.ConditionsPrecedentBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public ConditionsPrecedent.ConditionsPrecedentBuilder prune() {
if (conditions!=null && !conditions.prune().hasData()) conditions = null;
return this;
}
@Override
public boolean hasData() {
if (getCustomProvisions()!=null) return true;
if (getConditions()!=null && getConditions().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public ConditionsPrecedent.ConditionsPrecedentBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
ConditionsPrecedent.ConditionsPrecedentBuilder o = (ConditionsPrecedent.ConditionsPrecedentBuilder) other;
merger.mergeRosetta(getConditions(), o.getConditions(), this::setConditions);
merger.mergeBasic(getCustomProvisions(), o.getCustomProvisions(), this::setCustomProvisions);
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;
ConditionsPrecedent _that = getType().cast(o);
if (!Objects.equals(customProvisions, _that.getCustomProvisions())) return false;
if (!Objects.equals(conditions, _that.getConditions())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (customProvisions != null ? customProvisions.hashCode() : 0);
_result = 31 * _result + (conditions != null ? conditions.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ConditionsPrecedentBuilder {" +
"customProvisions=" + this.customProvisions + ", " +
"conditions=" + this.conditions +
'}';
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy