All Downloads are FREE. Search and download functionalities are using the official Maven repository.
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.CreditNotations Maven / Gradle / Ivy
package com.rosetta.jptlegalagreement.model;
import com.google.common.collect.ImmutableList;
import com.rosetta.jptlegalagreement.model.CreditNotation;
import com.rosetta.jptlegalagreement.model.CreditNotations;
import com.rosetta.jptlegalagreement.model.CreditNotations.CreditNotationsBuilder;
import com.rosetta.jptlegalagreement.model.CreditNotations.CreditNotationsBuilderImpl;
import com.rosetta.jptlegalagreement.model.CreditNotations.CreditNotationsImpl;
import com.rosetta.jptlegalagreement.model.MultipleCreditNotations;
import com.rosetta.jptlegalagreement.model.meta.CreditNotationsMeta;
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.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="CreditNotations", builder=CreditNotations.CreditNotationsBuilderImpl.class, version="test")
public interface CreditNotations extends RosettaModelObject {
CreditNotationsMeta metaData = new CreditNotationsMeta();
/*********************** Getter Methods ***********************/
CreditNotation getCreditNotation();
List extends MultipleCreditNotations> getCreditNotations();
/*********************** Build Methods ***********************/
CreditNotations build();
CreditNotations.CreditNotationsBuilder toBuilder();
static CreditNotations.CreditNotationsBuilder builder() {
return new CreditNotations.CreditNotationsBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends CreditNotations> metaData() {
return metaData;
}
@Override
default Class extends CreditNotations> getType() {
return CreditNotations.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("creditNotation"), processor, CreditNotation.class, getCreditNotation());
processRosetta(path.newSubPath("creditNotations"), processor, MultipleCreditNotations.class, getCreditNotations());
}
/*********************** Builder Interface ***********************/
interface CreditNotationsBuilder extends CreditNotations, RosettaModelObjectBuilder {
CreditNotation.CreditNotationBuilder getOrCreateCreditNotation();
CreditNotation.CreditNotationBuilder getCreditNotation();
MultipleCreditNotations.MultipleCreditNotationsBuilder getOrCreateCreditNotations(int _index);
List extends MultipleCreditNotations.MultipleCreditNotationsBuilder> getCreditNotations();
CreditNotations.CreditNotationsBuilder setCreditNotation(CreditNotation creditNotation);
CreditNotations.CreditNotationsBuilder addCreditNotations(MultipleCreditNotations creditNotations0);
CreditNotations.CreditNotationsBuilder addCreditNotations(MultipleCreditNotations creditNotations1, int _idx);
CreditNotations.CreditNotationsBuilder addCreditNotations(List extends MultipleCreditNotations> creditNotations2);
CreditNotations.CreditNotationsBuilder setCreditNotations(List extends MultipleCreditNotations> creditNotations3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("creditNotation"), processor, CreditNotation.CreditNotationBuilder.class, getCreditNotation());
processRosetta(path.newSubPath("creditNotations"), processor, MultipleCreditNotations.MultipleCreditNotationsBuilder.class, getCreditNotations());
}
CreditNotations.CreditNotationsBuilder prune();
}
/*********************** Immutable Implementation of CreditNotations ***********************/
class CreditNotationsImpl implements CreditNotations {
private final CreditNotation creditNotation;
private final List extends MultipleCreditNotations> creditNotations;
protected CreditNotationsImpl(CreditNotations.CreditNotationsBuilder builder) {
this.creditNotation = ofNullable(builder.getCreditNotation()).map(f->f.build()).orElse(null);
this.creditNotations = ofNullable(builder.getCreditNotations()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
}
@Override
@RosettaAttribute("creditNotation")
public CreditNotation getCreditNotation() {
return creditNotation;
}
@Override
@RosettaAttribute("creditNotations")
public List extends MultipleCreditNotations> getCreditNotations() {
return creditNotations;
}
@Override
public CreditNotations build() {
return this;
}
@Override
public CreditNotations.CreditNotationsBuilder toBuilder() {
CreditNotations.CreditNotationsBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(CreditNotations.CreditNotationsBuilder builder) {
ofNullable(getCreditNotation()).ifPresent(builder::setCreditNotation);
ofNullable(getCreditNotations()).ifPresent(builder::setCreditNotations);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
CreditNotations _that = getType().cast(o);
if (!Objects.equals(creditNotation, _that.getCreditNotation())) return false;
if (!ListEquals.listEquals(creditNotations, _that.getCreditNotations())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (creditNotation != null ? creditNotation.hashCode() : 0);
_result = 31 * _result + (creditNotations != null ? creditNotations.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "CreditNotations {" +
"creditNotation=" + this.creditNotation + ", " +
"creditNotations=" + this.creditNotations +
'}';
}
}
/*********************** Builder Implementation of CreditNotations ***********************/
class CreditNotationsBuilderImpl implements CreditNotations.CreditNotationsBuilder {
protected CreditNotation.CreditNotationBuilder creditNotation;
protected List creditNotations = new ArrayList<>();
public CreditNotationsBuilderImpl() {
}
@Override
@RosettaAttribute("creditNotation")
public CreditNotation.CreditNotationBuilder getCreditNotation() {
return creditNotation;
}
@Override
public CreditNotation.CreditNotationBuilder getOrCreateCreditNotation() {
CreditNotation.CreditNotationBuilder result;
if (creditNotation!=null) {
result = creditNotation;
}
else {
result = creditNotation = CreditNotation.builder();
}
return result;
}
@Override
@RosettaAttribute("creditNotations")
public List extends MultipleCreditNotations.MultipleCreditNotationsBuilder> getCreditNotations() {
return creditNotations;
}
public MultipleCreditNotations.MultipleCreditNotationsBuilder getOrCreateCreditNotations(int _index) {
if (creditNotations==null) {
this.creditNotations = new ArrayList<>();
}
MultipleCreditNotations.MultipleCreditNotationsBuilder result;
return getIndex(creditNotations, _index, () -> {
MultipleCreditNotations.MultipleCreditNotationsBuilder newCreditNotations = MultipleCreditNotations.builder();
return newCreditNotations;
});
}
@Override
@RosettaAttribute("creditNotation")
public CreditNotations.CreditNotationsBuilder setCreditNotation(CreditNotation creditNotation) {
this.creditNotation = creditNotation==null?null:creditNotation.toBuilder();
return this;
}
@Override
public CreditNotations.CreditNotationsBuilder addCreditNotations(MultipleCreditNotations creditNotations) {
if (creditNotations!=null) this.creditNotations.add(creditNotations.toBuilder());
return this;
}
@Override
public CreditNotations.CreditNotationsBuilder addCreditNotations(MultipleCreditNotations creditNotations, int _idx) {
getIndex(this.creditNotations, _idx, () -> creditNotations.toBuilder());
return this;
}
@Override
public CreditNotations.CreditNotationsBuilder addCreditNotations(List extends MultipleCreditNotations> creditNotationss) {
if (creditNotationss != null) {
for (MultipleCreditNotations toAdd : creditNotationss) {
this.creditNotations.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("creditNotations")
public CreditNotations.CreditNotationsBuilder setCreditNotations(List extends MultipleCreditNotations> creditNotationss) {
if (creditNotationss == null) {
this.creditNotations = new ArrayList<>();
}
else {
this.creditNotations = creditNotationss.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public CreditNotations build() {
return new CreditNotations.CreditNotationsImpl(this);
}
@Override
public CreditNotations.CreditNotationsBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public CreditNotations.CreditNotationsBuilder prune() {
if (creditNotation!=null && !creditNotation.prune().hasData()) creditNotation = null;
creditNotations = creditNotations.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getCreditNotation()!=null && getCreditNotation().hasData()) return true;
if (getCreditNotations()!=null && getCreditNotations().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public CreditNotations.CreditNotationsBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
CreditNotations.CreditNotationsBuilder o = (CreditNotations.CreditNotationsBuilder) other;
merger.mergeRosetta(getCreditNotation(), o.getCreditNotation(), this::setCreditNotation);
merger.mergeRosetta(getCreditNotations(), o.getCreditNotations(), this::getOrCreateCreditNotations);
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;
CreditNotations _that = getType().cast(o);
if (!Objects.equals(creditNotation, _that.getCreditNotation())) return false;
if (!ListEquals.listEquals(creditNotations, _that.getCreditNotations())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (creditNotation != null ? creditNotation.hashCode() : 0);
_result = 31 * _result + (creditNotations != null ? creditNotations.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "CreditNotationsBuilder {" +
"creditNotation=" + this.creditNotation + ", " +
"creditNotations=" + this.creditNotations +
'}';
}
}
}