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.Method Maven / Gradle / Ivy
package com.rosetta.jptlegalagreement.model;
import com.google.common.collect.ImmutableList;
import com.rosetta.jptlegalagreement.model.Method;
import com.rosetta.jptlegalagreement.model.Method.MethodBuilder;
import com.rosetta.jptlegalagreement.model.Method.MethodBuilderImpl;
import com.rosetta.jptlegalagreement.model.Method.MethodImpl;
import com.rosetta.jptlegalagreement.model.SimmCalculationCurrency;
import com.rosetta.jptlegalagreement.model.SimmVersion;
import com.rosetta.jptlegalagreement.model.meta.MethodMeta;
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="Method", builder=Method.MethodBuilderImpl.class, version="test")
public interface Method extends RosettaModelObject {
MethodMeta metaData = new MethodMeta();
/*********************** Getter Methods ***********************/
SimmVersion getVersion();
List extends SimmCalculationCurrency> getCalculationCurrency();
/*********************** Build Methods ***********************/
Method build();
Method.MethodBuilder toBuilder();
static Method.MethodBuilder builder() {
return new Method.MethodBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Method> metaData() {
return metaData;
}
@Override
default Class extends Method> getType() {
return Method.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("version"), processor, SimmVersion.class, getVersion());
processRosetta(path.newSubPath("calculationCurrency"), processor, SimmCalculationCurrency.class, getCalculationCurrency());
}
/*********************** Builder Interface ***********************/
interface MethodBuilder extends Method, RosettaModelObjectBuilder {
SimmVersion.SimmVersionBuilder getOrCreateVersion();
SimmVersion.SimmVersionBuilder getVersion();
SimmCalculationCurrency.SimmCalculationCurrencyBuilder getOrCreateCalculationCurrency(int _index);
List extends SimmCalculationCurrency.SimmCalculationCurrencyBuilder> getCalculationCurrency();
Method.MethodBuilder setVersion(SimmVersion version);
Method.MethodBuilder addCalculationCurrency(SimmCalculationCurrency calculationCurrency0);
Method.MethodBuilder addCalculationCurrency(SimmCalculationCurrency calculationCurrency1, int _idx);
Method.MethodBuilder addCalculationCurrency(List extends SimmCalculationCurrency> calculationCurrency2);
Method.MethodBuilder setCalculationCurrency(List extends SimmCalculationCurrency> calculationCurrency3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("version"), processor, SimmVersion.SimmVersionBuilder.class, getVersion());
processRosetta(path.newSubPath("calculationCurrency"), processor, SimmCalculationCurrency.SimmCalculationCurrencyBuilder.class, getCalculationCurrency());
}
Method.MethodBuilder prune();
}
/*********************** Immutable Implementation of Method ***********************/
class MethodImpl implements Method {
private final SimmVersion version;
private final List extends SimmCalculationCurrency> calculationCurrency;
protected MethodImpl(Method.MethodBuilder builder) {
this.version = ofNullable(builder.getVersion()).map(f->f.build()).orElse(null);
this.calculationCurrency = ofNullable(builder.getCalculationCurrency()).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("version")
public SimmVersion getVersion() {
return version;
}
@Override
@RosettaAttribute("calculationCurrency")
public List extends SimmCalculationCurrency> getCalculationCurrency() {
return calculationCurrency;
}
@Override
public Method build() {
return this;
}
@Override
public Method.MethodBuilder toBuilder() {
Method.MethodBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Method.MethodBuilder builder) {
ofNullable(getVersion()).ifPresent(builder::setVersion);
ofNullable(getCalculationCurrency()).ifPresent(builder::setCalculationCurrency);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Method _that = getType().cast(o);
if (!Objects.equals(version, _that.getVersion())) return false;
if (!ListEquals.listEquals(calculationCurrency, _that.getCalculationCurrency())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (version != null ? version.hashCode() : 0);
_result = 31 * _result + (calculationCurrency != null ? calculationCurrency.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Method {" +
"version=" + this.version + ", " +
"calculationCurrency=" + this.calculationCurrency +
'}';
}
}
/*********************** Builder Implementation of Method ***********************/
class MethodBuilderImpl implements Method.MethodBuilder {
protected SimmVersion.SimmVersionBuilder version;
protected List calculationCurrency = new ArrayList<>();
public MethodBuilderImpl() {
}
@Override
@RosettaAttribute("version")
public SimmVersion.SimmVersionBuilder getVersion() {
return version;
}
@Override
public SimmVersion.SimmVersionBuilder getOrCreateVersion() {
SimmVersion.SimmVersionBuilder result;
if (version!=null) {
result = version;
}
else {
result = version = SimmVersion.builder();
}
return result;
}
@Override
@RosettaAttribute("calculationCurrency")
public List extends SimmCalculationCurrency.SimmCalculationCurrencyBuilder> getCalculationCurrency() {
return calculationCurrency;
}
public SimmCalculationCurrency.SimmCalculationCurrencyBuilder getOrCreateCalculationCurrency(int _index) {
if (calculationCurrency==null) {
this.calculationCurrency = new ArrayList<>();
}
SimmCalculationCurrency.SimmCalculationCurrencyBuilder result;
return getIndex(calculationCurrency, _index, () -> {
SimmCalculationCurrency.SimmCalculationCurrencyBuilder newCalculationCurrency = SimmCalculationCurrency.builder();
return newCalculationCurrency;
});
}
@Override
@RosettaAttribute("version")
public Method.MethodBuilder setVersion(SimmVersion version) {
this.version = version==null?null:version.toBuilder();
return this;
}
@Override
public Method.MethodBuilder addCalculationCurrency(SimmCalculationCurrency calculationCurrency) {
if (calculationCurrency!=null) this.calculationCurrency.add(calculationCurrency.toBuilder());
return this;
}
@Override
public Method.MethodBuilder addCalculationCurrency(SimmCalculationCurrency calculationCurrency, int _idx) {
getIndex(this.calculationCurrency, _idx, () -> calculationCurrency.toBuilder());
return this;
}
@Override
public Method.MethodBuilder addCalculationCurrency(List extends SimmCalculationCurrency> calculationCurrencys) {
if (calculationCurrencys != null) {
for (SimmCalculationCurrency toAdd : calculationCurrencys) {
this.calculationCurrency.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("calculationCurrency")
public Method.MethodBuilder setCalculationCurrency(List extends SimmCalculationCurrency> calculationCurrencys) {
if (calculationCurrencys == null) {
this.calculationCurrency = new ArrayList<>();
}
else {
this.calculationCurrency = calculationCurrencys.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public Method build() {
return new Method.MethodImpl(this);
}
@Override
public Method.MethodBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Method.MethodBuilder prune() {
if (version!=null && !version.prune().hasData()) version = null;
calculationCurrency = calculationCurrency.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getVersion()!=null && getVersion().hasData()) return true;
if (getCalculationCurrency()!=null && getCalculationCurrency().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Method.MethodBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Method.MethodBuilder o = (Method.MethodBuilder) other;
merger.mergeRosetta(getVersion(), o.getVersion(), this::setVersion);
merger.mergeRosetta(getCalculationCurrency(), o.getCalculationCurrency(), this::getOrCreateCalculationCurrency);
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;
Method _that = getType().cast(o);
if (!Objects.equals(version, _that.getVersion())) return false;
if (!ListEquals.listEquals(calculationCurrency, _that.getCalculationCurrency())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (version != null ? version.hashCode() : 0);
_result = 31 * _result + (calculationCurrency != null ? calculationCurrency.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "MethodBuilder {" +
"version=" + this.version + ", " +
"calculationCurrency=" + this.calculationCurrency +
'}';
}
}
}