com.rosetta.metatest.model.ResolvableObservable11 Maven / Gradle / Ivy
package com.rosetta.metatest.model;
import com.rosetta.metatest.model.Observable11;
import com.rosetta.metatest.model.ResolvableObservable11;
import com.rosetta.metatest.model.ResolvableObservable11.ResolvableObservable11Builder;
import com.rosetta.metatest.model.ResolvableObservable11.ResolvableObservable11BuilderImpl;
import com.rosetta.metatest.model.ResolvableObservable11.ResolvableObservable11Impl;
import com.rosetta.metatest.model.meta.ResolvableObservable11Meta;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaObservable11;
import com.rosetta.metatest.model.metafields.ReferenceWithMetaObservable11.ReferenceWithMetaObservable11Builder;
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="ResolvableObservable11", builder=ResolvableObservable11.ResolvableObservable11BuilderImpl.class, version="test")
public interface ResolvableObservable11 extends RosettaModelObject {
ResolvableObservable11Meta metaData = new ResolvableObservable11Meta();
/*********************** Getter Methods ***********************/
ReferenceWithMetaObservable11 getResolvedObservable();
/*********************** Build Methods ***********************/
ResolvableObservable11 build();
ResolvableObservable11.ResolvableObservable11Builder toBuilder();
static ResolvableObservable11.ResolvableObservable11Builder builder() {
return new ResolvableObservable11.ResolvableObservable11BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends ResolvableObservable11> metaData() {
return metaData;
}
@Override
default Class extends ResolvableObservable11> getType() {
return ResolvableObservable11.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("resolvedObservable"), processor, ReferenceWithMetaObservable11.class, getResolvedObservable());
}
/*********************** Builder Interface ***********************/
interface ResolvableObservable11Builder extends ResolvableObservable11, RosettaModelObjectBuilder {
ReferenceWithMetaObservable11.ReferenceWithMetaObservable11Builder getOrCreateResolvedObservable();
ReferenceWithMetaObservable11.ReferenceWithMetaObservable11Builder getResolvedObservable();
ResolvableObservable11.ResolvableObservable11Builder setResolvedObservable(ReferenceWithMetaObservable11 resolvedObservable0);
ResolvableObservable11.ResolvableObservable11Builder setResolvedObservableValue(Observable11 resolvedObservable1);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("resolvedObservable"), processor, ReferenceWithMetaObservable11.ReferenceWithMetaObservable11Builder.class, getResolvedObservable());
}
ResolvableObservable11.ResolvableObservable11Builder prune();
}
/*********************** Immutable Implementation of ResolvableObservable11 ***********************/
class ResolvableObservable11Impl implements ResolvableObservable11 {
private final ReferenceWithMetaObservable11 resolvedObservable;
protected ResolvableObservable11Impl(ResolvableObservable11.ResolvableObservable11Builder builder) {
this.resolvedObservable = ofNullable(builder.getResolvedObservable()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("resolvedObservable")
public ReferenceWithMetaObservable11 getResolvedObservable() {
return resolvedObservable;
}
@Override
public ResolvableObservable11 build() {
return this;
}
@Override
public ResolvableObservable11.ResolvableObservable11Builder toBuilder() {
ResolvableObservable11.ResolvableObservable11Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(ResolvableObservable11.ResolvableObservable11Builder builder) {
ofNullable(getResolvedObservable()).ifPresent(builder::setResolvedObservable);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
ResolvableObservable11 _that = getType().cast(o);
if (!Objects.equals(resolvedObservable, _that.getResolvedObservable())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (resolvedObservable != null ? resolvedObservable.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ResolvableObservable11 {" +
"resolvedObservable=" + this.resolvedObservable +
'}';
}
}
/*********************** Builder Implementation of ResolvableObservable11 ***********************/
class ResolvableObservable11BuilderImpl implements ResolvableObservable11.ResolvableObservable11Builder {
protected ReferenceWithMetaObservable11.ReferenceWithMetaObservable11Builder resolvedObservable;
public ResolvableObservable11BuilderImpl() {
}
@Override
@RosettaAttribute("resolvedObservable")
public ReferenceWithMetaObservable11.ReferenceWithMetaObservable11Builder getResolvedObservable() {
return resolvedObservable;
}
@Override
public ReferenceWithMetaObservable11.ReferenceWithMetaObservable11Builder getOrCreateResolvedObservable() {
ReferenceWithMetaObservable11.ReferenceWithMetaObservable11Builder result;
if (resolvedObservable!=null) {
result = resolvedObservable;
}
else {
result = resolvedObservable = ReferenceWithMetaObservable11.builder();
}
return result;
}
@Override
@RosettaAttribute("resolvedObservable")
public ResolvableObservable11.ResolvableObservable11Builder setResolvedObservable(ReferenceWithMetaObservable11 resolvedObservable) {
this.resolvedObservable = resolvedObservable==null?null:resolvedObservable.toBuilder();
return this;
}
@Override
public ResolvableObservable11.ResolvableObservable11Builder setResolvedObservableValue(Observable11 resolvedObservable) {
this.getOrCreateResolvedObservable().setValue(resolvedObservable);
return this;
}
@Override
public ResolvableObservable11 build() {
return new ResolvableObservable11.ResolvableObservable11Impl(this);
}
@Override
public ResolvableObservable11.ResolvableObservable11Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public ResolvableObservable11.ResolvableObservable11Builder prune() {
if (resolvedObservable!=null && !resolvedObservable.prune().hasData()) resolvedObservable = null;
return this;
}
@Override
public boolean hasData() {
if (getResolvedObservable()!=null && getResolvedObservable().hasData()) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public ResolvableObservable11.ResolvableObservable11Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
ResolvableObservable11.ResolvableObservable11Builder o = (ResolvableObservable11.ResolvableObservable11Builder) other;
merger.mergeRosetta(getResolvedObservable(), o.getResolvedObservable(), this::setResolvedObservable);
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;
ResolvableObservable11 _that = getType().cast(o);
if (!Objects.equals(resolvedObservable, _that.getResolvedObservable())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (resolvedObservable != null ? resolvedObservable.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ResolvableObservable11Builder {" +
"resolvedObservable=" + this.resolvedObservable +
'}';
}
}
}