com.rosetta.metatest.model.ResolvableAsset12 Maven / Gradle / Ivy
package com.rosetta.metatest.model;
import com.rosetta.metatest.model.Asset12;
import com.rosetta.metatest.model.ResolvableAsset12;
import com.rosetta.metatest.model.ResolvableAsset12.ResolvableAsset12Builder;
import com.rosetta.metatest.model.ResolvableAsset12.ResolvableAsset12BuilderImpl;
import com.rosetta.metatest.model.ResolvableAsset12.ResolvableAsset12Impl;
import com.rosetta.metatest.model.meta.ResolvableAsset12Meta;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaAsset12;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaAsset12.ReferenceWithMetaAsset12Builder;
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="ResolvableAsset12", builder=ResolvableAsset12.ResolvableAsset12BuilderImpl.class, version="test")
public interface ResolvableAsset12 extends RosettaModelObject {
ResolvableAsset12Meta metaData = new ResolvableAsset12Meta();
/*********************** Getter Methods ***********************/
ReferenceWithMetaAsset12 getResolvedAsset();
/*********************** Build Methods ***********************/
ResolvableAsset12 build();
ResolvableAsset12.ResolvableAsset12Builder toBuilder();
static ResolvableAsset12.ResolvableAsset12Builder builder() {
return new ResolvableAsset12.ResolvableAsset12BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends ResolvableAsset12> metaData() {
return metaData;
}
@Override
default Class extends ResolvableAsset12> getType() {
return ResolvableAsset12.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("resolvedAsset"), processor, ReferenceWithMetaAsset12.class, getResolvedAsset());
}
/*********************** Builder Interface ***********************/
interface ResolvableAsset12Builder extends ResolvableAsset12, RosettaModelObjectBuilder {
ReferenceWithMetaAsset12.ReferenceWithMetaAsset12Builder getOrCreateResolvedAsset();
ReferenceWithMetaAsset12.ReferenceWithMetaAsset12Builder getResolvedAsset();
ResolvableAsset12.ResolvableAsset12Builder setResolvedAsset(ReferenceWithMetaAsset12 resolvedAsset0);
ResolvableAsset12.ResolvableAsset12Builder setResolvedAssetValue(Asset12 resolvedAsset1);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("resolvedAsset"), processor, ReferenceWithMetaAsset12.ReferenceWithMetaAsset12Builder.class, getResolvedAsset());
}
ResolvableAsset12.ResolvableAsset12Builder prune();
}
/*********************** Immutable Implementation of ResolvableAsset12 ***********************/
class ResolvableAsset12Impl implements ResolvableAsset12 {
private final ReferenceWithMetaAsset12 resolvedAsset;
protected ResolvableAsset12Impl(ResolvableAsset12.ResolvableAsset12Builder builder) {
this.resolvedAsset = ofNullable(builder.getResolvedAsset()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("resolvedAsset")
public ReferenceWithMetaAsset12 getResolvedAsset() {
return resolvedAsset;
}
@Override
public ResolvableAsset12 build() {
return this;
}
@Override
public ResolvableAsset12.ResolvableAsset12Builder toBuilder() {
ResolvableAsset12.ResolvableAsset12Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(ResolvableAsset12.ResolvableAsset12Builder 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;
ResolvableAsset12 _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 "ResolvableAsset12 {" +
"resolvedAsset=" + this.resolvedAsset +
'}';
}
}
/*********************** Builder Implementation of ResolvableAsset12 ***********************/
class ResolvableAsset12BuilderImpl implements ResolvableAsset12.ResolvableAsset12Builder {
protected ReferenceWithMetaAsset12.ReferenceWithMetaAsset12Builder resolvedAsset;
public ResolvableAsset12BuilderImpl() {
}
@Override
@RosettaAttribute("resolvedAsset")
public ReferenceWithMetaAsset12.ReferenceWithMetaAsset12Builder getResolvedAsset() {
return resolvedAsset;
}
@Override
public ReferenceWithMetaAsset12.ReferenceWithMetaAsset12Builder getOrCreateResolvedAsset() {
ReferenceWithMetaAsset12.ReferenceWithMetaAsset12Builder result;
if (resolvedAsset!=null) {
result = resolvedAsset;
}
else {
result = resolvedAsset = ReferenceWithMetaAsset12.builder();
}
return result;
}
@Override
@RosettaAttribute("resolvedAsset")
public ResolvableAsset12.ResolvableAsset12Builder setResolvedAsset(ReferenceWithMetaAsset12 resolvedAsset) {
this.resolvedAsset = resolvedAsset==null?null:resolvedAsset.toBuilder();
return this;
}
@Override
public ResolvableAsset12.ResolvableAsset12Builder setResolvedAssetValue(Asset12 resolvedAsset) {
this.getOrCreateResolvedAsset().setValue(resolvedAsset);
return this;
}
@Override
public ResolvableAsset12 build() {
return new ResolvableAsset12.ResolvableAsset12Impl(this);
}
@Override
public ResolvableAsset12.ResolvableAsset12Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public ResolvableAsset12.ResolvableAsset12Builder 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 ResolvableAsset12.ResolvableAsset12Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
ResolvableAsset12.ResolvableAsset12Builder o = (ResolvableAsset12.ResolvableAsset12Builder) 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;
ResolvableAsset12 _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 "ResolvableAsset12Builder {" +
"resolvedAsset=" + this.resolvedAsset +
'}';
}
}
}