org.isda.cdm.AttributeWithGlobalKey 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.ARosettaObject;
import org.isda.cdm.AttributeWithGlobalKey;
import org.isda.cdm.AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder;
import org.isda.cdm.AttributeWithGlobalKey.AttributeWithGlobalKeyBuilderImpl;
import org.isda.cdm.AttributeWithGlobalKey.AttributeWithGlobalKeyImpl;
import org.isda.cdm.meta.AttributeWithGlobalKeyMeta;
import org.isda.cdm.metafields.ReferenceWithMetaARosettaObject;
import org.isda.cdm.metafields.ReferenceWithMetaARosettaObject.ReferenceWithMetaARosettaObjectBuilder;
import static java.util.Optional.ofNullable;
/**
* shouldCreateAttributeReference
* @version test
*/
@RosettaDataType(value="AttributeWithGlobalKey", builder=AttributeWithGlobalKey.AttributeWithGlobalKeyBuilderImpl.class, version="test")
public interface AttributeWithGlobalKey extends RosettaModelObject {
AttributeWithGlobalKeyMeta metaData = new AttributeWithGlobalKeyMeta();
/*********************** Getter Methods ***********************/
ReferenceWithMetaARosettaObject getWithGlobalKey();
/*********************** Build Methods ***********************/
AttributeWithGlobalKey build();
AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder toBuilder();
static AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder builder() {
return new AttributeWithGlobalKey.AttributeWithGlobalKeyBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends AttributeWithGlobalKey> metaData() {
return metaData;
}
@Override
default Class extends AttributeWithGlobalKey> getType() {
return AttributeWithGlobalKey.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("withGlobalKey"), processor, ReferenceWithMetaARosettaObject.class, getWithGlobalKey());
}
/*********************** Builder Interface ***********************/
interface AttributeWithGlobalKeyBuilder extends AttributeWithGlobalKey, RosettaModelObjectBuilder {
ReferenceWithMetaARosettaObject.ReferenceWithMetaARosettaObjectBuilder getOrCreateWithGlobalKey();
ReferenceWithMetaARosettaObject.ReferenceWithMetaARosettaObjectBuilder getWithGlobalKey();
AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder setWithGlobalKey(ReferenceWithMetaARosettaObject withGlobalKey0);
AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder setWithGlobalKeyValue(ARosettaObject withGlobalKey1);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("withGlobalKey"), processor, ReferenceWithMetaARosettaObject.ReferenceWithMetaARosettaObjectBuilder.class, getWithGlobalKey());
}
AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder prune();
}
/*********************** Immutable Implementation of AttributeWithGlobalKey ***********************/
class AttributeWithGlobalKeyImpl implements AttributeWithGlobalKey {
private final ReferenceWithMetaARosettaObject withGlobalKey;
protected AttributeWithGlobalKeyImpl(AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder builder) {
this.withGlobalKey = ofNullable(builder.getWithGlobalKey()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("withGlobalKey")
public ReferenceWithMetaARosettaObject getWithGlobalKey() {
return withGlobalKey;
}
@Override
public AttributeWithGlobalKey build() {
return this;
}
@Override
public AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder toBuilder() {
AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder builder) {
ofNullable(getWithGlobalKey()).ifPresent(builder::setWithGlobalKey);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
AttributeWithGlobalKey _that = getType().cast(o);
if (!Objects.equals(withGlobalKey, _that.getWithGlobalKey())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (withGlobalKey != null ? withGlobalKey.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "AttributeWithGlobalKey {" +
"withGlobalKey=" + this.withGlobalKey +
'}';
}
}
/*********************** Builder Implementation of AttributeWithGlobalKey ***********************/
class AttributeWithGlobalKeyBuilderImpl implements AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder {
protected ReferenceWithMetaARosettaObject.ReferenceWithMetaARosettaObjectBuilder withGlobalKey;
public AttributeWithGlobalKeyBuilderImpl() {
}
@Override
@RosettaAttribute("withGlobalKey")
public ReferenceWithMetaARosettaObject.ReferenceWithMetaARosettaObjectBuilder getWithGlobalKey() {
return withGlobalKey;
}
@Override
public ReferenceWithMetaARosettaObject.ReferenceWithMetaARosettaObjectBuilder getOrCreateWithGlobalKey() {
ReferenceWithMetaARosettaObject.ReferenceWithMetaARosettaObjectBuilder result;
if (withGlobalKey!=null) {
result = withGlobalKey;
}
else {
result = withGlobalKey = ReferenceWithMetaARosettaObject.builder();
}
return result;
}
@Override
@RosettaAttribute("withGlobalKey")
public AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder setWithGlobalKey(ReferenceWithMetaARosettaObject withGlobalKey) {
this.withGlobalKey = withGlobalKey==null?null:withGlobalKey.toBuilder();
return this;
}
@Override
public AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder setWithGlobalKeyValue(ARosettaObject withGlobalKey) {
this.getOrCreateWithGlobalKey().setValue(withGlobalKey);
return this;
}
@Override
public AttributeWithGlobalKey build() {
return new AttributeWithGlobalKey.AttributeWithGlobalKeyImpl(this);
}
@Override
public AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder prune() {
if (withGlobalKey!=null && !withGlobalKey.prune().hasData()) withGlobalKey = null;
return this;
}
@Override
public boolean hasData() {
if (getWithGlobalKey()!=null && getWithGlobalKey().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder o = (AttributeWithGlobalKey.AttributeWithGlobalKeyBuilder) other;
merger.mergeRosetta(getWithGlobalKey(), o.getWithGlobalKey(), this::setWithGlobalKey);
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;
AttributeWithGlobalKey _that = getType().cast(o);
if (!Objects.equals(withGlobalKey, _that.getWithGlobalKey())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (withGlobalKey != null ? withGlobalKey.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "AttributeWithGlobalKeyBuilder {" +
"withGlobalKey=" + this.withGlobalKey +
'}';
}
}
}