Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.rosetta.jptlegalagreement.model.LegalAgreementBase Maven / Gradle / Ivy
package com.rosetta.jptlegalagreement.model;
import com.google.common.collect.ImmutableList;
import com.rosetta.jptlegalagreement.model.Identifier;
import com.rosetta.jptlegalagreement.model.LegalAgreementBase;
import com.rosetta.jptlegalagreement.model.LegalAgreementBase.LegalAgreementBaseBuilder;
import com.rosetta.jptlegalagreement.model.LegalAgreementBase.LegalAgreementBaseBuilderImpl;
import com.rosetta.jptlegalagreement.model.LegalAgreementBase.LegalAgreementBaseImpl;
import com.rosetta.jptlegalagreement.model.LegalAgreementType;
import com.rosetta.jptlegalagreement.model.meta.LegalAgreementBaseMeta;
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.model.lib.records.Date;
import com.rosetta.util.ListEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="LegalAgreementBase", builder=LegalAgreementBase.LegalAgreementBaseBuilderImpl.class, version="test")
public interface LegalAgreementBase extends RosettaModelObject {
LegalAgreementBaseMeta metaData = new LegalAgreementBaseMeta();
/*********************** Getter Methods ***********************/
Date getAgreementDate();
Date getEffectiveDate();
List extends Identifier> getIdentifier();
LegalAgreementType getAgreementType();
/*********************** Build Methods ***********************/
LegalAgreementBase build();
LegalAgreementBase.LegalAgreementBaseBuilder toBuilder();
static LegalAgreementBase.LegalAgreementBaseBuilder builder() {
return new LegalAgreementBase.LegalAgreementBaseBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends LegalAgreementBase> metaData() {
return metaData;
}
@Override
default Class extends LegalAgreementBase> getType() {
return LegalAgreementBase.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("agreementDate"), Date.class, getAgreementDate(), this);
processor.processBasic(path.newSubPath("effectiveDate"), Date.class, getEffectiveDate(), this);
processRosetta(path.newSubPath("identifier"), processor, Identifier.class, getIdentifier());
processRosetta(path.newSubPath("agreementType"), processor, LegalAgreementType.class, getAgreementType());
}
/*********************** Builder Interface ***********************/
interface LegalAgreementBaseBuilder extends LegalAgreementBase, RosettaModelObjectBuilder {
Identifier.IdentifierBuilder getOrCreateIdentifier(int _index);
List extends Identifier.IdentifierBuilder> getIdentifier();
LegalAgreementType.LegalAgreementTypeBuilder getOrCreateAgreementType();
LegalAgreementType.LegalAgreementTypeBuilder getAgreementType();
LegalAgreementBase.LegalAgreementBaseBuilder setAgreementDate(Date agreementDate);
LegalAgreementBase.LegalAgreementBaseBuilder setEffectiveDate(Date effectiveDate);
LegalAgreementBase.LegalAgreementBaseBuilder addIdentifier(Identifier identifier0);
LegalAgreementBase.LegalAgreementBaseBuilder addIdentifier(Identifier identifier1, int _idx);
LegalAgreementBase.LegalAgreementBaseBuilder addIdentifier(List extends Identifier> identifier2);
LegalAgreementBase.LegalAgreementBaseBuilder setIdentifier(List extends Identifier> identifier3);
LegalAgreementBase.LegalAgreementBaseBuilder setAgreementType(LegalAgreementType agreementType);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("agreementDate"), Date.class, getAgreementDate(), this);
processor.processBasic(path.newSubPath("effectiveDate"), Date.class, getEffectiveDate(), this);
processRosetta(path.newSubPath("identifier"), processor, Identifier.IdentifierBuilder.class, getIdentifier());
processRosetta(path.newSubPath("agreementType"), processor, LegalAgreementType.LegalAgreementTypeBuilder.class, getAgreementType());
}
LegalAgreementBase.LegalAgreementBaseBuilder prune();
}
/*********************** Immutable Implementation of LegalAgreementBase ***********************/
class LegalAgreementBaseImpl implements LegalAgreementBase {
private final Date agreementDate;
private final Date effectiveDate;
private final List extends Identifier> identifier;
private final LegalAgreementType agreementType;
protected LegalAgreementBaseImpl(LegalAgreementBase.LegalAgreementBaseBuilder builder) {
this.agreementDate = builder.getAgreementDate();
this.effectiveDate = builder.getEffectiveDate();
this.identifier = ofNullable(builder.getIdentifier()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
this.agreementType = ofNullable(builder.getAgreementType()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("agreementDate")
public Date getAgreementDate() {
return agreementDate;
}
@Override
@RosettaAttribute("effectiveDate")
public Date getEffectiveDate() {
return effectiveDate;
}
@Override
@RosettaAttribute("identifier")
public List extends Identifier> getIdentifier() {
return identifier;
}
@Override
@RosettaAttribute("agreementType")
public LegalAgreementType getAgreementType() {
return agreementType;
}
@Override
public LegalAgreementBase build() {
return this;
}
@Override
public LegalAgreementBase.LegalAgreementBaseBuilder toBuilder() {
LegalAgreementBase.LegalAgreementBaseBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(LegalAgreementBase.LegalAgreementBaseBuilder builder) {
ofNullable(getAgreementDate()).ifPresent(builder::setAgreementDate);
ofNullable(getEffectiveDate()).ifPresent(builder::setEffectiveDate);
ofNullable(getIdentifier()).ifPresent(builder::setIdentifier);
ofNullable(getAgreementType()).ifPresent(builder::setAgreementType);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
LegalAgreementBase _that = getType().cast(o);
if (!Objects.equals(agreementDate, _that.getAgreementDate())) return false;
if (!Objects.equals(effectiveDate, _that.getEffectiveDate())) return false;
if (!ListEquals.listEquals(identifier, _that.getIdentifier())) return false;
if (!Objects.equals(agreementType, _that.getAgreementType())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (agreementDate != null ? agreementDate.hashCode() : 0);
_result = 31 * _result + (effectiveDate != null ? effectiveDate.hashCode() : 0);
_result = 31 * _result + (identifier != null ? identifier.hashCode() : 0);
_result = 31 * _result + (agreementType != null ? agreementType.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "LegalAgreementBase {" +
"agreementDate=" + this.agreementDate + ", " +
"effectiveDate=" + this.effectiveDate + ", " +
"identifier=" + this.identifier + ", " +
"agreementType=" + this.agreementType +
'}';
}
}
/*********************** Builder Implementation of LegalAgreementBase ***********************/
class LegalAgreementBaseBuilderImpl implements LegalAgreementBase.LegalAgreementBaseBuilder {
protected Date agreementDate;
protected Date effectiveDate;
protected List identifier = new ArrayList<>();
protected LegalAgreementType.LegalAgreementTypeBuilder agreementType;
public LegalAgreementBaseBuilderImpl() {
}
@Override
@RosettaAttribute("agreementDate")
public Date getAgreementDate() {
return agreementDate;
}
@Override
@RosettaAttribute("effectiveDate")
public Date getEffectiveDate() {
return effectiveDate;
}
@Override
@RosettaAttribute("identifier")
public List extends Identifier.IdentifierBuilder> getIdentifier() {
return identifier;
}
public Identifier.IdentifierBuilder getOrCreateIdentifier(int _index) {
if (identifier==null) {
this.identifier = new ArrayList<>();
}
Identifier.IdentifierBuilder result;
return getIndex(identifier, _index, () -> {
Identifier.IdentifierBuilder newIdentifier = Identifier.builder();
return newIdentifier;
});
}
@Override
@RosettaAttribute("agreementType")
public LegalAgreementType.LegalAgreementTypeBuilder getAgreementType() {
return agreementType;
}
@Override
public LegalAgreementType.LegalAgreementTypeBuilder getOrCreateAgreementType() {
LegalAgreementType.LegalAgreementTypeBuilder result;
if (agreementType!=null) {
result = agreementType;
}
else {
result = agreementType = LegalAgreementType.builder();
}
return result;
}
@Override
@RosettaAttribute("agreementDate")
public LegalAgreementBase.LegalAgreementBaseBuilder setAgreementDate(Date agreementDate) {
this.agreementDate = agreementDate==null?null:agreementDate;
return this;
}
@Override
@RosettaAttribute("effectiveDate")
public LegalAgreementBase.LegalAgreementBaseBuilder setEffectiveDate(Date effectiveDate) {
this.effectiveDate = effectiveDate==null?null:effectiveDate;
return this;
}
@Override
public LegalAgreementBase.LegalAgreementBaseBuilder addIdentifier(Identifier identifier) {
if (identifier!=null) this.identifier.add(identifier.toBuilder());
return this;
}
@Override
public LegalAgreementBase.LegalAgreementBaseBuilder addIdentifier(Identifier identifier, int _idx) {
getIndex(this.identifier, _idx, () -> identifier.toBuilder());
return this;
}
@Override
public LegalAgreementBase.LegalAgreementBaseBuilder addIdentifier(List extends Identifier> identifiers) {
if (identifiers != null) {
for (Identifier toAdd : identifiers) {
this.identifier.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("identifier")
public LegalAgreementBase.LegalAgreementBaseBuilder setIdentifier(List extends Identifier> identifiers) {
if (identifiers == null) {
this.identifier = new ArrayList<>();
}
else {
this.identifier = identifiers.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
@RosettaAttribute("agreementType")
public LegalAgreementBase.LegalAgreementBaseBuilder setAgreementType(LegalAgreementType agreementType) {
this.agreementType = agreementType==null?null:agreementType.toBuilder();
return this;
}
@Override
public LegalAgreementBase build() {
return new LegalAgreementBase.LegalAgreementBaseImpl(this);
}
@Override
public LegalAgreementBase.LegalAgreementBaseBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public LegalAgreementBase.LegalAgreementBaseBuilder prune() {
identifier = identifier.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
if (agreementType!=null && !agreementType.prune().hasData()) agreementType = null;
return this;
}
@Override
public boolean hasData() {
if (getAgreementDate()!=null) return true;
if (getEffectiveDate()!=null) return true;
if (getIdentifier()!=null && getIdentifier().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
if (getAgreementType()!=null && getAgreementType().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public LegalAgreementBase.LegalAgreementBaseBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
LegalAgreementBase.LegalAgreementBaseBuilder o = (LegalAgreementBase.LegalAgreementBaseBuilder) other;
merger.mergeRosetta(getIdentifier(), o.getIdentifier(), this::getOrCreateIdentifier);
merger.mergeRosetta(getAgreementType(), o.getAgreementType(), this::setAgreementType);
merger.mergeBasic(getAgreementDate(), o.getAgreementDate(), this::setAgreementDate);
merger.mergeBasic(getEffectiveDate(), o.getEffectiveDate(), this::setEffectiveDate);
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;
LegalAgreementBase _that = getType().cast(o);
if (!Objects.equals(agreementDate, _that.getAgreementDate())) return false;
if (!Objects.equals(effectiveDate, _that.getEffectiveDate())) return false;
if (!ListEquals.listEquals(identifier, _that.getIdentifier())) return false;
if (!Objects.equals(agreementType, _that.getAgreementType())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (agreementDate != null ? agreementDate.hashCode() : 0);
_result = 31 * _result + (effectiveDate != null ? effectiveDate.hashCode() : 0);
_result = 31 * _result + (identifier != null ? identifier.hashCode() : 0);
_result = 31 * _result + (agreementType != null ? agreementType.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "LegalAgreementBaseBuilder {" +
"agreementDate=" + this.agreementDate + ", " +
"effectiveDate=" + this.effectiveDate + ", " +
"identifier=" + this.identifier + ", " +
"agreementType=" + this.agreementType +
'}';
}
}
}