org.isda.cdm.NumberRepresentations Maven / Gradle / Ivy
package org.isda.cdm;
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 java.util.Objects;
import org.isda.cdm.NumberRepresentations;
import org.isda.cdm.NumberRepresentations.NumberRepresentationsBuilder;
import org.isda.cdm.NumberRepresentations.NumberRepresentationsBuilderImpl;
import org.isda.cdm.NumberRepresentations.NumberRepresentationsImpl;
import org.isda.cdm.StringRep;
import org.isda.cdm.StringRep.StringRepBuilder;
import org.isda.cdm.meta.NumberRepresentationsMeta;
import static java.util.Optional.ofNullable;
/**
* shouldValidateRootObject
* @version test
*/
@RosettaDataType(value="NumberRepresentations", builder=NumberRepresentations.NumberRepresentationsBuilderImpl.class, version="test")
public interface NumberRepresentations extends RosettaModelObject {
NumberRepresentationsMeta metaData = new NumberRepresentationsMeta();
/*********************** Getter Methods ***********************/
Integer getInteger();
StringRep getString();
/*********************** Build Methods ***********************/
NumberRepresentations build();
NumberRepresentations.NumberRepresentationsBuilder toBuilder();
static NumberRepresentations.NumberRepresentationsBuilder builder() {
return new NumberRepresentations.NumberRepresentationsBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends NumberRepresentations> metaData() {
return metaData;
}
@Override
default Class extends NumberRepresentations> getType() {
return NumberRepresentations.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("integer"), Integer.class, getInteger(), this);
processRosetta(path.newSubPath("string"), processor, StringRep.class, getString());
}
/*********************** Builder Interface ***********************/
interface NumberRepresentationsBuilder extends NumberRepresentations, RosettaModelObjectBuilder {
StringRep.StringRepBuilder getOrCreateString();
@Override
StringRep.StringRepBuilder getString();
NumberRepresentations.NumberRepresentationsBuilder setInteger(Integer integer);
NumberRepresentations.NumberRepresentationsBuilder setString(StringRep string);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("integer"), Integer.class, getInteger(), this);
processRosetta(path.newSubPath("string"), processor, StringRep.StringRepBuilder.class, getString());
}
NumberRepresentations.NumberRepresentationsBuilder prune();
}
/*********************** Immutable Implementation of NumberRepresentations ***********************/
class NumberRepresentationsImpl implements NumberRepresentations {
private final Integer integer;
private final StringRep string;
protected NumberRepresentationsImpl(NumberRepresentations.NumberRepresentationsBuilder builder) {
this.integer = builder.getInteger();
this.string = ofNullable(builder.getString()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("integer")
public Integer getInteger() {
return integer;
}
@Override
@RosettaAttribute("string")
public StringRep getString() {
return string;
}
@Override
public NumberRepresentations build() {
return this;
}
@Override
public NumberRepresentations.NumberRepresentationsBuilder toBuilder() {
NumberRepresentations.NumberRepresentationsBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(NumberRepresentations.NumberRepresentationsBuilder builder) {
ofNullable(getInteger()).ifPresent(builder::setInteger);
ofNullable(getString()).ifPresent(builder::setString);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
NumberRepresentations _that = getType().cast(o);
if (!Objects.equals(integer, _that.getInteger())) return false;
if (!Objects.equals(string, _that.getString())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (integer != null ? integer.hashCode() : 0);
_result = 31 * _result + (string != null ? string.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "NumberRepresentations {" +
"integer=" + this.integer + ", " +
"string=" + this.string +
'}';
}
}
/*********************** Builder Implementation of NumberRepresentations ***********************/
class NumberRepresentationsBuilderImpl implements NumberRepresentations.NumberRepresentationsBuilder {
protected Integer integer;
protected StringRep.StringRepBuilder string;
@Override
@RosettaAttribute("integer")
public Integer getInteger() {
return integer;
}
@Override
@RosettaAttribute("string")
public StringRep.StringRepBuilder getString() {
return string;
}
@Override
public StringRep.StringRepBuilder getOrCreateString() {
StringRep.StringRepBuilder result;
if (string!=null) {
result = string;
}
else {
result = string = StringRep.builder();
}
return result;
}
@Override
@RosettaAttribute("integer")
public NumberRepresentations.NumberRepresentationsBuilder setInteger(Integer _integer) {
this.integer = _integer == null ? null : _integer;
return this;
}
@Override
@RosettaAttribute("string")
public NumberRepresentations.NumberRepresentationsBuilder setString(StringRep _string) {
this.string = _string == null ? null : _string.toBuilder();
return this;
}
@Override
public NumberRepresentations build() {
return new NumberRepresentations.NumberRepresentationsImpl(this);
}
@Override
public NumberRepresentations.NumberRepresentationsBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public NumberRepresentations.NumberRepresentationsBuilder prune() {
if (string!=null && !string.prune().hasData()) string = null;
return this;
}
@Override
public boolean hasData() {
if (getInteger()!=null) return true;
if (getString()!=null && getString().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public NumberRepresentations.NumberRepresentationsBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
NumberRepresentations.NumberRepresentationsBuilder o = (NumberRepresentations.NumberRepresentationsBuilder) other;
merger.mergeRosetta(getString(), o.getString(), this::setString);
merger.mergeBasic(getInteger(), o.getInteger(), this::setInteger);
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;
NumberRepresentations _that = getType().cast(o);
if (!Objects.equals(integer, _that.getInteger())) return false;
if (!Objects.equals(string, _that.getString())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (integer != null ? integer.hashCode() : 0);
_result = 31 * _result + (string != null ? string.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "NumberRepresentationsBuilder {" +
"integer=" + this.integer + ", " +
"string=" + this.string +
'}';
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy