com.rosetta.externalsynonym.model.Identifier7 Maven / Gradle / Ivy
package com.rosetta.externalsynonym.model;
import com.google.common.collect.ImmutableList;
import com.rosetta.externalsynonym.model.AssignedIdentifier7;
import com.rosetta.externalsynonym.model.Identifier7;
import com.rosetta.externalsynonym.model.Identifier7.Identifier7Builder;
import com.rosetta.externalsynonym.model.Identifier7.Identifier7BuilderImpl;
import com.rosetta.externalsynonym.model.Identifier7.Identifier7Impl;
import com.rosetta.externalsynonym.model.meta.Identifier7Meta;
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 com.rosetta.util.ListEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Identifier7", builder=Identifier7.Identifier7BuilderImpl.class, version="test")
public interface Identifier7 extends RosettaModelObject {
Identifier7Meta metaData = new Identifier7Meta();
/*********************** Getter Methods ***********************/
List extends AssignedIdentifier7> getAssignedId();
/*********************** Build Methods ***********************/
Identifier7 build();
Identifier7.Identifier7Builder toBuilder();
static Identifier7.Identifier7Builder builder() {
return new Identifier7.Identifier7BuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Identifier7> metaData() {
return metaData;
}
@Override
default Class extends Identifier7> getType() {
return Identifier7.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processRosetta(path.newSubPath("assignedId"), processor, AssignedIdentifier7.class, getAssignedId());
}
/*********************** Builder Interface ***********************/
interface Identifier7Builder extends Identifier7, RosettaModelObjectBuilder {
AssignedIdentifier7.AssignedIdentifier7Builder getOrCreateAssignedId(int _index);
List extends AssignedIdentifier7.AssignedIdentifier7Builder> getAssignedId();
Identifier7.Identifier7Builder addAssignedId(AssignedIdentifier7 assignedId0);
Identifier7.Identifier7Builder addAssignedId(AssignedIdentifier7 assignedId1, int _idx);
Identifier7.Identifier7Builder addAssignedId(List extends AssignedIdentifier7> assignedId2);
Identifier7.Identifier7Builder setAssignedId(List extends AssignedIdentifier7> assignedId3);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processRosetta(path.newSubPath("assignedId"), processor, AssignedIdentifier7.AssignedIdentifier7Builder.class, getAssignedId());
}
Identifier7.Identifier7Builder prune();
}
/*********************** Immutable Implementation of Identifier7 ***********************/
class Identifier7Impl implements Identifier7 {
private final List extends AssignedIdentifier7> assignedId;
protected Identifier7Impl(Identifier7.Identifier7Builder builder) {
this.assignedId = ofNullable(builder.getAssignedId()).filter(_l->!_l.isEmpty()).map(list -> list.stream().filter(Objects::nonNull).map(f->f.build()).filter(Objects::nonNull).collect(ImmutableList.toImmutableList())).orElse(null);
}
@Override
@RosettaAttribute("assignedId")
public List extends AssignedIdentifier7> getAssignedId() {
return assignedId;
}
@Override
public Identifier7 build() {
return this;
}
@Override
public Identifier7.Identifier7Builder toBuilder() {
Identifier7.Identifier7Builder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Identifier7.Identifier7Builder builder) {
ofNullable(getAssignedId()).ifPresent(builder::setAssignedId);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Identifier7 _that = getType().cast(o);
if (!ListEquals.listEquals(assignedId, _that.getAssignedId())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (assignedId != null ? assignedId.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Identifier7 {" +
"assignedId=" + this.assignedId +
'}';
}
}
/*********************** Builder Implementation of Identifier7 ***********************/
class Identifier7BuilderImpl implements Identifier7.Identifier7Builder {
protected List assignedId = new ArrayList<>();
public Identifier7BuilderImpl() {
}
@Override
@RosettaAttribute("assignedId")
public List extends AssignedIdentifier7.AssignedIdentifier7Builder> getAssignedId() {
return assignedId;
}
public AssignedIdentifier7.AssignedIdentifier7Builder getOrCreateAssignedId(int _index) {
if (assignedId==null) {
this.assignedId = new ArrayList<>();
}
AssignedIdentifier7.AssignedIdentifier7Builder result;
return getIndex(assignedId, _index, () -> {
AssignedIdentifier7.AssignedIdentifier7Builder newAssignedId = AssignedIdentifier7.builder();
return newAssignedId;
});
}
@Override
public Identifier7.Identifier7Builder addAssignedId(AssignedIdentifier7 assignedId) {
if (assignedId!=null) this.assignedId.add(assignedId.toBuilder());
return this;
}
@Override
public Identifier7.Identifier7Builder addAssignedId(AssignedIdentifier7 assignedId, int _idx) {
getIndex(this.assignedId, _idx, () -> assignedId.toBuilder());
return this;
}
@Override
public Identifier7.Identifier7Builder addAssignedId(List extends AssignedIdentifier7> assignedIds) {
if (assignedIds != null) {
for (AssignedIdentifier7 toAdd : assignedIds) {
this.assignedId.add(toAdd.toBuilder());
}
}
return this;
}
@Override
@RosettaAttribute("assignedId")
public Identifier7.Identifier7Builder setAssignedId(List extends AssignedIdentifier7> assignedIds) {
if (assignedIds == null) {
this.assignedId = new ArrayList<>();
}
else {
this.assignedId = assignedIds.stream()
.map(_a->_a.toBuilder())
.collect(Collectors.toCollection(()->new ArrayList<>()));
}
return this;
}
@Override
public Identifier7 build() {
return new Identifier7.Identifier7Impl(this);
}
@Override
public Identifier7.Identifier7Builder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Identifier7.Identifier7Builder prune() {
assignedId = assignedId.stream().filter(b->b!=null).map(b->b.prune()).filter(b->b.hasData()).collect(Collectors.toList());
return this;
}
@Override
public boolean hasData() {
if (getAssignedId()!=null && getAssignedId().stream().filter(Objects::nonNull).anyMatch(a->a.hasData())) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Identifier7.Identifier7Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Identifier7.Identifier7Builder o = (Identifier7.Identifier7Builder) other;
merger.mergeRosetta(getAssignedId(), o.getAssignedId(), this::getOrCreateAssignedId);
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;
Identifier7 _that = getType().cast(o);
if (!ListEquals.listEquals(assignedId, _that.getAssignedId())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (assignedId != null ? assignedId.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Identifier7Builder {" +
"assignedId=" + this.assignedId +
'}';
}
}
}