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.M3 Maven / Gradle / Ivy
package com.rosetta.mappingprocessortest.model;
import com.google.common.collect.ImmutableList;
import com.rosetta.mappingprocessortest.model.M3;
import com.rosetta.mappingprocessortest.model.M3.M3Builder;
import com.rosetta.mappingprocessortest.model.M3.M3BuilderImpl;
import com.rosetta.mappingprocessortest.model.M3.M3Impl;
import com.rosetta.mappingprocessortest.model.meta.M3Meta;
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.function.Consumer;
import java.util.stream.Collectors;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="M3", builder=M3.M3BuilderImpl.class, version="test")
public interface M3 extends RosettaModelObject {
M3Meta metaData = new M3Meta();
/*********************** Getter Methods ***********************/
String getNField();
List getOField();
String getPField();
String getSField();
/*********************** Build Methods ***********************/
M3 build();
M3.M3Builder toBuilder();
static M3.M3Builder builder() {
return new M3.M3BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends M3> metaData() {
return metaData;
}
@Override
default Class extends M3> getType() {
return M3.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("nField"), String.class, getNField(), this);
processor.processBasic(path.newSubPath("oField"), String.class, getOField(), this);
processor.processBasic(path.newSubPath("pField"), String.class, getPField(), this);
processor.processBasic(path.newSubPath("sField"), String.class, getSField(), this);
}
/*********************** Builder Interface ***********************/
interface M3Builder extends M3, RosettaModelObjectBuilder {
M3.M3Builder setNField(String nField);
M3.M3Builder addOField(String oField0);
M3.M3Builder addOField(String oField1, int _idx);
M3.M3Builder addOField(List oField2);
M3.M3Builder setOField(List oField3);
M3.M3Builder setPField(String pField);
M3.M3Builder setSField(String sField);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("nField"), String.class, getNField(), this);
processor.processBasic(path.newSubPath("oField"), String.class, getOField(), this);
processor.processBasic(path.newSubPath("pField"), String.class, getPField(), this);
processor.processBasic(path.newSubPath("sField"), String.class, getSField(), this);
}
M3.M3Builder prune();
}
/*********************** Immutable Implementation of M3 ***********************/
class M3Impl implements M3 {
private final String nField;
private final List oField;
private final String pField;
private final String sField;
protected M3Impl(M3.M3Builder builder) {
this.nField = builder.getNField();
this.oField = ofNullable(builder.getOField()).filter(_l->!_l.isEmpty()).map(ImmutableList::copyOf).orElse(null);
this.pField = builder.getPField();
this.sField = builder.getSField();
}
@Override
@RosettaAttribute("nField")
public String getNField() {
return nField;
}
@Override
@RosettaAttribute("oField")
public List getOField() {
return oField;
}
@Override
@RosettaAttribute("pField")
public String getPField() {
return pField;
}
@Override
@RosettaAttribute("sField")
public String getSField() {
return sField;
}
@Override
public M3 build() {
return this;
}
@Override
public M3.M3Builder toBuilder() {
M3.M3Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(M3.M3Builder builder) {
ofNullable(getNField()).ifPresent(builder::setNField);
ofNullable(getOField()).ifPresent(builder::setOField);
ofNullable(getPField()).ifPresent(builder::setPField);
ofNullable(getSField()).ifPresent(builder::setSField);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
M3 _that = getType().cast(o);
if (!Objects.equals(nField, _that.getNField())) return false;
if (!ListEquals.listEquals(oField, _that.getOField())) return false;
if (!Objects.equals(pField, _that.getPField())) return false;
if (!Objects.equals(sField, _that.getSField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (nField != null ? nField.hashCode() : 0);
_result = 31 * _result + (oField != null ? oField.hashCode() : 0);
_result = 31 * _result + (pField != null ? pField.hashCode() : 0);
_result = 31 * _result + (sField != null ? sField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "M3 {" +
"nField=" + this.nField + ", " +
"oField=" + this.oField + ", " +
"pField=" + this.pField + ", " +
"sField=" + this.sField +
'}';
}
}
/*********************** Builder Implementation of M3 ***********************/
class M3BuilderImpl implements M3.M3Builder {
protected String nField;
protected List oField = new ArrayList<>();
protected String pField;
protected String sField;
public M3BuilderImpl() {
}
@Override
@RosettaAttribute("nField")
public String getNField() {
return nField;
}
@Override
@RosettaAttribute("oField")
public List getOField() {
return oField;
}
@Override
@RosettaAttribute("pField")
public String getPField() {
return pField;
}
@Override
@RosettaAttribute("sField")
public String getSField() {
return sField;
}
@Override
@RosettaAttribute("nField")
public M3.M3Builder setNField(String nField) {
this.nField = nField==null?null:nField;
return this;
}
@Override
public M3.M3Builder addOField(String oField) {
if (oField!=null) this.oField.add(oField);
return this;
}
@Override
public M3.M3Builder addOField(String oField, int _idx) {
getIndex(this.oField, _idx, () -> oField);
return this;
}
@Override
public M3.M3Builder addOField(List oFields) {
if (oFields != null) {
for (String toAdd : oFields) {
this.oField.add(toAdd);
}
}
return this;
}
@Override
@RosettaAttribute("oField")
public M3.M3Builder setOField(List oFields) {
if (oFields == null) {
this.oField = new ArrayList<>();
}
else {
this.oField = oFields.stream()
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
@RosettaAttribute("pField")
public M3.M3Builder setPField(String pField) {
this.pField = pField==null?null:pField;
return this;
}
@Override
@RosettaAttribute("sField")
public M3.M3Builder setSField(String sField) {
this.sField = sField==null?null:sField;
return this;
}
@Override
public M3 build() {
return new M3.M3Impl(this);
}
@Override
public M3.M3Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public M3.M3Builder prune() {
return this;
}
@Override
public boolean hasData() {
if (getNField()!=null) return true;
if (getOField()!=null && !getOField().isEmpty()) return true;
if (getPField()!=null) return true;
if (getSField()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public M3.M3Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
M3.M3Builder o = (M3.M3Builder) other;
merger.mergeBasic(getNField(), o.getNField(), this::setNField);
merger.mergeBasic(getOField(), o.getOField(), (Consumer) this::addOField);
merger.mergeBasic(getPField(), o.getPField(), this::setPField);
merger.mergeBasic(getSField(), o.getSField(), this::setSField);
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;
M3 _that = getType().cast(o);
if (!Objects.equals(nField, _that.getNField())) return false;
if (!ListEquals.listEquals(oField, _that.getOField())) return false;
if (!Objects.equals(pField, _that.getPField())) return false;
if (!Objects.equals(sField, _that.getSField())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (nField != null ? nField.hashCode() : 0);
_result = 31 * _result + (oField != null ? oField.hashCode() : 0);
_result = 31 * _result + (pField != null ? pField.hashCode() : 0);
_result = 31 * _result + (sField != null ? sField.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "M3Builder {" +
"nField=" + this.nField + ", " +
"oField=" + this.oField + ", " +
"pField=" + this.pField + ", " +
"sField=" + this.sField +
'}';
}
}
}