com.rosetta.metatest.model.ResolvableAsset14 Maven / Gradle / Ivy
package com.rosetta.metatest.model;
import com.rosetta.metatest.model.Asset14;
import com.rosetta.metatest.model.ResolvableAsset14;
import com.rosetta.metatest.model.ResolvableAsset14.ResolvableAsset14Builder;
import com.rosetta.metatest.model.ResolvableAsset14.ResolvableAsset14BuilderImpl;
import com.rosetta.metatest.model.ResolvableAsset14.ResolvableAsset14Impl;
import com.rosetta.metatest.model.meta.ResolvableAsset14Meta;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaAsset14;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaAsset14.ReferenceWithMetaAsset14Builder;
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="ResolvableAsset14", builder=ResolvableAsset14.ResolvableAsset14BuilderImpl.class, version="test")
public interface ResolvableAsset14 extends RosettaModelObject {
ResolvableAsset14Meta metaData = new ResolvableAsset14Meta();
/*********************** Getter Methods ***********************/
ReferenceWithMetaAsset14 getResolvedAsset();
/*********************** Build Methods ***********************/
ResolvableAsset14 build();
ResolvableAsset14.ResolvableAsset14Builder toBuilder();
static ResolvableAsset14.ResolvableAsset14Builder builder() {
return new ResolvableAsset14.ResolvableAsset14BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends ResolvableAsset14> metaData() {
return metaData;
}
@Override
default Class extends ResolvableAsset14> getType() {
return ResolvableAsset14.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("resolvedAsset"), processor, ReferenceWithMetaAsset14.class, getResolvedAsset());
}
/*********************** Builder Interface ***********************/
interface ResolvableAsset14Builder extends ResolvableAsset14, RosettaModelObjectBuilder {
ReferenceWithMetaAsset14.ReferenceWithMetaAsset14Builder getOrCreateResolvedAsset();
ReferenceWithMetaAsset14.ReferenceWithMetaAsset14Builder getResolvedAsset();
ResolvableAsset14.ResolvableAsset14Builder setResolvedAsset(ReferenceWithMetaAsset14 resolvedAsset0);
ResolvableAsset14.ResolvableAsset14Builder setResolvedAssetValue(Asset14 resolvedAsset1);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("resolvedAsset"), processor, ReferenceWithMetaAsset14.ReferenceWithMetaAsset14Builder.class, getResolvedAsset());
}
ResolvableAsset14.ResolvableAsset14Builder prune();
}
/*********************** Immutable Implementation of ResolvableAsset14 ***********************/
class ResolvableAsset14Impl implements ResolvableAsset14 {
private final ReferenceWithMetaAsset14 resolvedAsset;
protected ResolvableAsset14Impl(ResolvableAsset14.ResolvableAsset14Builder builder) {
this.resolvedAsset = ofNullable(builder.getResolvedAsset()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("resolvedAsset")
public ReferenceWithMetaAsset14 getResolvedAsset() {
return resolvedAsset;
}
@Override
public ResolvableAsset14 build() {
return this;
}
@Override
public ResolvableAsset14.ResolvableAsset14Builder toBuilder() {
ResolvableAsset14.ResolvableAsset14Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(ResolvableAsset14.ResolvableAsset14Builder builder) {
ofNullable(getResolvedAsset()).ifPresent(builder::setResolvedAsset);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
ResolvableAsset14 _that = getType().cast(o);
if (!Objects.equals(resolvedAsset, _that.getResolvedAsset())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (resolvedAsset != null ? resolvedAsset.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ResolvableAsset14 {" +
"resolvedAsset=" + this.resolvedAsset +
'}';
}
}
/*********************** Builder Implementation of ResolvableAsset14 ***********************/
class ResolvableAsset14BuilderImpl implements ResolvableAsset14.ResolvableAsset14Builder {
protected ReferenceWithMetaAsset14.ReferenceWithMetaAsset14Builder resolvedAsset;
public ResolvableAsset14BuilderImpl() {
}
@Override
@RosettaAttribute("resolvedAsset")
public ReferenceWithMetaAsset14.ReferenceWithMetaAsset14Builder getResolvedAsset() {
return resolvedAsset;
}
@Override
public ReferenceWithMetaAsset14.ReferenceWithMetaAsset14Builder getOrCreateResolvedAsset() {
ReferenceWithMetaAsset14.ReferenceWithMetaAsset14Builder result;
if (resolvedAsset!=null) {
result = resolvedAsset;
}
else {
result = resolvedAsset = ReferenceWithMetaAsset14.builder();
}
return result;
}
@Override
@RosettaAttribute("resolvedAsset")
public ResolvableAsset14.ResolvableAsset14Builder setResolvedAsset(ReferenceWithMetaAsset14 resolvedAsset) {
this.resolvedAsset = resolvedAsset==null?null:resolvedAsset.toBuilder();
return this;
}
@Override
public ResolvableAsset14.ResolvableAsset14Builder setResolvedAssetValue(Asset14 resolvedAsset) {
this.getOrCreateResolvedAsset().setValue(resolvedAsset);
return this;
}
@Override
public ResolvableAsset14 build() {
return new ResolvableAsset14.ResolvableAsset14Impl(this);
}
@Override
public ResolvableAsset14.ResolvableAsset14Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public ResolvableAsset14.ResolvableAsset14Builder prune() {
if (resolvedAsset!=null && !resolvedAsset.prune().hasData()) resolvedAsset = null;
return this;
}
@Override
public boolean hasData() {
if (getResolvedAsset()!=null && getResolvedAsset().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public ResolvableAsset14.ResolvableAsset14Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
ResolvableAsset14.ResolvableAsset14Builder o = (ResolvableAsset14.ResolvableAsset14Builder) other;
merger.mergeRosetta(getResolvedAsset(), o.getResolvedAsset(), this::setResolvedAsset);
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;
ResolvableAsset14 _that = getType().cast(o);
if (!Objects.equals(resolvedAsset, _that.getResolvedAsset())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (resolvedAsset != null ? resolvedAsset.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ResolvableAsset14Builder {" +
"resolvedAsset=" + this.resolvedAsset +
'}';
}
}
}