org.isda.cdm.StringRep 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.StringRep;
import org.isda.cdm.StringRep.StringRepBuilder;
import org.isda.cdm.StringRep.StringRepBuilderImpl;
import org.isda.cdm.StringRep.StringRepImpl;
import org.isda.cdm.meta.StringRepMeta;
import static java.util.Optional.ofNullable;
/**
* shouldValidateRootObject
* @version test
*/
@RosettaDataType(value="StringRep", builder=StringRep.StringRepBuilderImpl.class, version="test")
public interface StringRep extends RosettaModelObject {
StringRepMeta metaData = new StringRepMeta();
/*********************** Getter Methods ***********************/
String getVal();
/*********************** Build Methods ***********************/
StringRep build();
StringRep.StringRepBuilder toBuilder();
static StringRep.StringRepBuilder builder() {
return new StringRep.StringRepBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends StringRep> metaData() {
return metaData;
}
@Override
default Class extends StringRep> getType() {
return StringRep.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("val"), String.class, getVal(), this);
}
/*********************** Builder Interface ***********************/
interface StringRepBuilder extends StringRep, RosettaModelObjectBuilder {
StringRep.StringRepBuilder setVal(String val);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("val"), String.class, getVal(), this);
}
StringRep.StringRepBuilder prune();
}
/*********************** Immutable Implementation of StringRep ***********************/
class StringRepImpl implements StringRep {
private final String val;
protected StringRepImpl(StringRep.StringRepBuilder builder) {
this.val = builder.getVal();
}
@Override
@RosettaAttribute("val")
public String getVal() {
return val;
}
@Override
public StringRep build() {
return this;
}
@Override
public StringRep.StringRepBuilder toBuilder() {
StringRep.StringRepBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(StringRep.StringRepBuilder builder) {
ofNullable(getVal()).ifPresent(builder::setVal);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
StringRep _that = getType().cast(o);
if (!Objects.equals(val, _that.getVal())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (val != null ? val.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "StringRep {" +
"val=" + this.val +
'}';
}
}
/*********************** Builder Implementation of StringRep ***********************/
class StringRepBuilderImpl implements StringRep.StringRepBuilder {
protected String val;
public StringRepBuilderImpl() {
}
@Override
@RosettaAttribute("val")
public String getVal() {
return val;
}
@Override
@RosettaAttribute("val")
public StringRep.StringRepBuilder setVal(String val) {
this.val = val==null?null:val;
return this;
}
@Override
public StringRep build() {
return new StringRep.StringRepImpl(this);
}
@Override
public StringRep.StringRepBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public StringRep.StringRepBuilder prune() {
return this;
}
@Override
public boolean hasData() {
if (getVal()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public StringRep.StringRepBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
StringRep.StringRepBuilder o = (StringRep.StringRepBuilder) other;
merger.mergeBasic(getVal(), o.getVal(), this::setVal);
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;
StringRep _that = getType().cast(o);
if (!Objects.equals(val, _that.getVal())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (val != null ? val.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "StringRepBuilder {" +
"val=" + this.val +
'}';
}
}
}