com.regnosys.ingest.test.framework.util.TestObject Maven / Gradle / Ivy
package com.regnosys.granite.util;
import com.regnosys.granite.util.TestObject;
import com.regnosys.granite.util.TestObject.TestObjectBuilder;
import com.regnosys.granite.util.TestObject.TestObjectBuilderImpl;
import com.regnosys.granite.util.TestObject.TestObjectImpl;
import com.regnosys.granite.util.meta.TestObjectMeta;
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 static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="TestObject", builder=TestObject.TestObjectBuilderImpl.class, version="test")
public interface TestObject extends RosettaModelObject {
TestObjectMeta metaData = new TestObjectMeta();
/*********************** Getter Methods ***********************/
String getManySynonymSources();
/*********************** Build Methods ***********************/
TestObject build();
TestObject.TestObjectBuilder toBuilder();
static TestObject.TestObjectBuilder builder() {
return new TestObject.TestObjectBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends TestObject> metaData() {
return metaData;
}
@Override
default Class extends TestObject> getType() {
return TestObject.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("manySynonymSources"), String.class, getManySynonymSources(), this);
}
/*********************** Builder Interface ***********************/
interface TestObjectBuilder extends TestObject, RosettaModelObjectBuilder {
TestObject.TestObjectBuilder setManySynonymSources(String manySynonymSources);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("manySynonymSources"), String.class, getManySynonymSources(), this);
}
TestObject.TestObjectBuilder prune();
}
/*********************** Immutable Implementation of TestObject ***********************/
class TestObjectImpl implements TestObject {
private final String manySynonymSources;
protected TestObjectImpl(TestObject.TestObjectBuilder builder) {
this.manySynonymSources = builder.getManySynonymSources();
}
@Override
@RosettaAttribute("manySynonymSources")
public String getManySynonymSources() {
return manySynonymSources;
}
@Override
public TestObject build() {
return this;
}
@Override
public TestObject.TestObjectBuilder toBuilder() {
TestObject.TestObjectBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(TestObject.TestObjectBuilder builder) {
ofNullable(getManySynonymSources()).ifPresent(builder::setManySynonymSources);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
TestObject _that = getType().cast(o);
if (!Objects.equals(manySynonymSources, _that.getManySynonymSources())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (manySynonymSources != null ? manySynonymSources.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TestObject {" +
"manySynonymSources=" + this.manySynonymSources +
'}';
}
}
/*********************** Builder Implementation of TestObject ***********************/
class TestObjectBuilderImpl implements TestObject.TestObjectBuilder {
protected String manySynonymSources;
public TestObjectBuilderImpl() {
}
@Override
@RosettaAttribute("manySynonymSources")
public String getManySynonymSources() {
return manySynonymSources;
}
@Override
@RosettaAttribute("manySynonymSources")
public TestObject.TestObjectBuilder setManySynonymSources(String manySynonymSources) {
this.manySynonymSources = manySynonymSources==null?null:manySynonymSources;
return this;
}
@Override
public TestObject build() {
return new TestObject.TestObjectImpl(this);
}
@Override
public TestObject.TestObjectBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public TestObject.TestObjectBuilder prune() {
return this;
}
@Override
public boolean hasData() {
if (getManySynonymSources()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public TestObject.TestObjectBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
TestObject.TestObjectBuilder o = (TestObject.TestObjectBuilder) other;
merger.mergeBasic(getManySynonymSources(), o.getManySynonymSources(), this::setManySynonymSources);
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;
TestObject _that = getType().cast(o);
if (!Objects.equals(manySynonymSources, _that.getManySynonymSources())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (manySynonymSources != null ? manySynonymSources.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TestObjectBuilder {" +
"manySynonymSources=" + this.manySynonymSources +
'}';
}
}
}