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.mappingprocessortest.model.A4 Maven / Gradle / Ivy
package com.rosetta.mappingprocessortest.model;
import com.google.common.collect.ImmutableList;
import com.rosetta.mappingprocessortest.model.A4;
import com.rosetta.mappingprocessortest.model.A4.A4Builder;
import com.rosetta.mappingprocessortest.model.A4.A4BuilderImpl;
import com.rosetta.mappingprocessortest.model.A4.A4Impl;
import com.rosetta.mappingprocessortest.model.PeriodEnum;
import com.rosetta.mappingprocessortest.model.meta.A4Meta;
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.function.Consumer;
import java.util.stream.Collectors;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="A4", builder=A4.A4BuilderImpl.class, version="test")
public interface A4 extends RosettaModelObject {
A4Meta metaData = new A4Meta();
/*********************** Getter Methods ***********************/
Date getStartDate();
Integer getPeriodMultiplier();
PeriodEnum getPeriod();
List getB();
/*********************** Build Methods ***********************/
A4 build();
A4.A4Builder toBuilder();
static A4.A4Builder builder() {
return new A4.A4BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends A4> metaData() {
return metaData;
}
@Override
default Class extends A4> getType() {
return A4.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("startDate"), Date.class, getStartDate(), this);
processor.processBasic(path.newSubPath("periodMultiplier"), Integer.class, getPeriodMultiplier(), this);
processor.processBasic(path.newSubPath("period"), PeriodEnum.class, getPeriod(), this);
processor.processBasic(path.newSubPath("b"), String.class, getB(), this);
}
/*********************** Builder Interface ***********************/
interface A4Builder extends A4, RosettaModelObjectBuilder {
A4.A4Builder setStartDate(Date startDate);
A4.A4Builder setPeriodMultiplier(Integer periodMultiplier);
A4.A4Builder setPeriod(PeriodEnum period);
A4.A4Builder addB(String b0);
A4.A4Builder addB(String b1, int _idx);
A4.A4Builder addB(List b2);
A4.A4Builder setB(List b3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("startDate"), Date.class, getStartDate(), this);
processor.processBasic(path.newSubPath("periodMultiplier"), Integer.class, getPeriodMultiplier(), this);
processor.processBasic(path.newSubPath("period"), PeriodEnum.class, getPeriod(), this);
processor.processBasic(path.newSubPath("b"), String.class, getB(), this);
}
A4.A4Builder prune();
}
/*********************** Immutable Implementation of A4 ***********************/
class A4Impl implements A4 {
private final Date startDate;
private final Integer periodMultiplier;
private final PeriodEnum period;
private final List b;
protected A4Impl(A4.A4Builder builder) {
this.startDate = builder.getStartDate();
this.periodMultiplier = builder.getPeriodMultiplier();
this.period = builder.getPeriod();
this.b = ofNullable(builder.getB()).filter(_l->!_l.isEmpty()).map(ImmutableList::copyOf).orElse(null);
}
@Override
@RosettaAttribute("startDate")
public Date getStartDate() {
return startDate;
}
@Override
@RosettaAttribute("periodMultiplier")
public Integer getPeriodMultiplier() {
return periodMultiplier;
}
@Override
@RosettaAttribute("period")
public PeriodEnum getPeriod() {
return period;
}
@Override
@RosettaAttribute("b")
public List getB() {
return b;
}
@Override
public A4 build() {
return this;
}
@Override
public A4.A4Builder toBuilder() {
A4.A4Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(A4.A4Builder builder) {
ofNullable(getStartDate()).ifPresent(builder::setStartDate);
ofNullable(getPeriodMultiplier()).ifPresent(builder::setPeriodMultiplier);
ofNullable(getPeriod()).ifPresent(builder::setPeriod);
ofNullable(getB()).ifPresent(builder::setB);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
A4 _that = getType().cast(o);
if (!Objects.equals(startDate, _that.getStartDate())) return false;
if (!Objects.equals(periodMultiplier, _that.getPeriodMultiplier())) return false;
if (!Objects.equals(period, _that.getPeriod())) return false;
if (!ListEquals.listEquals(b, _that.getB())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (startDate != null ? startDate.hashCode() : 0);
_result = 31 * _result + (periodMultiplier != null ? periodMultiplier.hashCode() : 0);
_result = 31 * _result + (period != null ? period.getClass().getName().hashCode() : 0);
_result = 31 * _result + (b != null ? b.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "A4 {" +
"startDate=" + this.startDate + ", " +
"periodMultiplier=" + this.periodMultiplier + ", " +
"period=" + this.period + ", " +
"b=" + this.b +
'}';
}
}
/*********************** Builder Implementation of A4 ***********************/
class A4BuilderImpl implements A4.A4Builder {
protected Date startDate;
protected Integer periodMultiplier;
protected PeriodEnum period;
protected List b = new ArrayList<>();
public A4BuilderImpl() {
}
@Override
@RosettaAttribute("startDate")
public Date getStartDate() {
return startDate;
}
@Override
@RosettaAttribute("periodMultiplier")
public Integer getPeriodMultiplier() {
return periodMultiplier;
}
@Override
@RosettaAttribute("period")
public PeriodEnum getPeriod() {
return period;
}
@Override
@RosettaAttribute("b")
public List getB() {
return b;
}
@Override
@RosettaAttribute("startDate")
public A4.A4Builder setStartDate(Date startDate) {
this.startDate = startDate==null?null:startDate;
return this;
}
@Override
@RosettaAttribute("periodMultiplier")
public A4.A4Builder setPeriodMultiplier(Integer periodMultiplier) {
this.periodMultiplier = periodMultiplier==null?null:periodMultiplier;
return this;
}
@Override
@RosettaAttribute("period")
public A4.A4Builder setPeriod(PeriodEnum period) {
this.period = period==null?null:period;
return this;
}
@Override
public A4.A4Builder addB(String b) {
if (b!=null) this.b.add(b);
return this;
}
@Override
public A4.A4Builder addB(String b, int _idx) {
getIndex(this.b, _idx, () -> b);
return this;
}
@Override
public A4.A4Builder addB(List bs) {
if (bs != null) {
for (String toAdd : bs) {
this.b.add(toAdd);
}
}
return this;
}
@Override
@RosettaAttribute("b")
public A4.A4Builder setB(List bs) {
if (bs == null) {
this.b = new ArrayList<>();
}
else {
this.b = bs.stream()
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public A4 build() {
return new A4.A4Impl(this);
}
@Override
public A4.A4Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public A4.A4Builder prune() {
return this;
}
@Override
public boolean hasData() {
if (getStartDate()!=null) return true;
if (getPeriodMultiplier()!=null) return true;
if (getPeriod()!=null) return true;
if (getB()!=null && !getB().isEmpty()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public A4.A4Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
A4.A4Builder o = (A4.A4Builder) other;
merger.mergeBasic(getStartDate(), o.getStartDate(), this::setStartDate);
merger.mergeBasic(getPeriodMultiplier(), o.getPeriodMultiplier(), this::setPeriodMultiplier);
merger.mergeBasic(getPeriod(), o.getPeriod(), this::setPeriod);
merger.mergeBasic(getB(), o.getB(), (Consumer) this::addB);
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;
A4 _that = getType().cast(o);
if (!Objects.equals(startDate, _that.getStartDate())) return false;
if (!Objects.equals(periodMultiplier, _that.getPeriodMultiplier())) return false;
if (!Objects.equals(period, _that.getPeriod())) return false;
if (!ListEquals.listEquals(b, _that.getB())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (startDate != null ? startDate.hashCode() : 0);
_result = 31 * _result + (periodMultiplier != null ? periodMultiplier.hashCode() : 0);
_result = 31 * _result + (period != null ? period.getClass().getName().hashCode() : 0);
_result = 31 * _result + (b != null ? b.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "A4Builder {" +
"startDate=" + this.startDate + ", " +
"periodMultiplier=" + this.periodMultiplier + ", " +
"period=" + this.period + ", " +
"b=" + this.b +
'}';
}
}
}