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