com.rosetta.testother.model.Payout Maven / Gradle / Ivy
package com.rosetta.testother.model;
import com.google.common.collect.ImmutableList;
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.testother.model.Payout;
import com.rosetta.testother.model.Payout.PayoutBuilder;
import com.rosetta.testother.model.Payout.PayoutBuilderImpl;
import com.rosetta.testother.model.Payout.PayoutImpl;
import com.rosetta.testother.model.meta.PayoutMeta;
import com.rosetta.util.ListEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Payout", builder=Payout.PayoutBuilderImpl.class, version="test")
public interface Payout extends RosettaModelObject {
PayoutMeta metaData = new PayoutMeta();
/*********************** Getter Methods ***********************/
List getIrp();
/*********************** Build Methods ***********************/
Payout build();
Payout.PayoutBuilder toBuilder();
static Payout.PayoutBuilder builder() {
return new Payout.PayoutBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Payout> metaData() {
return metaData;
}
@Override
default Class extends Payout> getType() {
return Payout.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("irp"), String.class, getIrp(), this);
}
/*********************** Builder Interface ***********************/
interface PayoutBuilder extends Payout, RosettaModelObjectBuilder {
Payout.PayoutBuilder addIrp(String irp0);
Payout.PayoutBuilder addIrp(String irp1, int _idx);
Payout.PayoutBuilder addIrp(List irp2);
Payout.PayoutBuilder setIrp(List irp3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("irp"), String.class, getIrp(), this);
}
Payout.PayoutBuilder prune();
}
/*********************** Immutable Implementation of Payout ***********************/
class PayoutImpl implements Payout {
private final List irp;
protected PayoutImpl(Payout.PayoutBuilder builder) {
this.irp = ofNullable(builder.getIrp()).filter(_l->!_l.isEmpty()).map(ImmutableList::copyOf).orElse(null);
}
@Override
@RosettaAttribute("irp")
public List getIrp() {
return irp;
}
@Override
public Payout build() {
return this;
}
@Override
public Payout.PayoutBuilder toBuilder() {
Payout.PayoutBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Payout.PayoutBuilder builder) {
ofNullable(getIrp()).ifPresent(builder::setIrp);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Payout _that = getType().cast(o);
if (!ListEquals.listEquals(irp, _that.getIrp())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (irp != null ? irp.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Payout {" +
"irp=" + this.irp +
'}';
}
}
/*********************** Builder Implementation of Payout ***********************/
class PayoutBuilderImpl implements Payout.PayoutBuilder {
protected List irp = new ArrayList<>();
public PayoutBuilderImpl() {
}
@Override
@RosettaAttribute("irp")
public List getIrp() {
return irp;
}
@Override
public Payout.PayoutBuilder addIrp(String irp) {
if (irp!=null) this.irp.add(irp);
return this;
}
@Override
public Payout.PayoutBuilder addIrp(String irp, int _idx) {
getIndex(this.irp, _idx, () -> irp);
return this;
}
@Override
public Payout.PayoutBuilder addIrp(List irps) {
if (irps != null) {
for (String toAdd : irps) {
this.irp.add(toAdd);
}
}
return this;
}
@Override
@RosettaAttribute("irp")
public Payout.PayoutBuilder setIrp(List irps) {
if (irps == null) {
this.irp = new ArrayList<>();
}
else {
this.irp = irps.stream()
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public Payout build() {
return new Payout.PayoutImpl(this);
}
@Override
public Payout.PayoutBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Payout.PayoutBuilder prune() {
return this;
}
@Override
public boolean hasData() {
if (getIrp()!=null && !getIrp().isEmpty()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Payout.PayoutBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Payout.PayoutBuilder o = (Payout.PayoutBuilder) other;
merger.mergeBasic(getIrp(), o.getIrp(), (Consumer) this::addIrp);
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;
Payout _that = getType().cast(o);
if (!ListEquals.listEquals(irp, _that.getIrp())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (irp != null ? irp.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PayoutBuilder {" +
"irp=" + this.irp +
'}';
}
}
}