com.rosetta.testhard.model.Identifier Maven / Gradle / Ivy
package com.rosetta.testhard.model;
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.testhard.model.Identifier;
import com.rosetta.testhard.model.Identifier.IdentifierBuilder;
import com.rosetta.testhard.model.Identifier.IdentifierBuilderImpl;
import com.rosetta.testhard.model.Identifier.IdentifierImpl;
import com.rosetta.testhard.model.meta.IdentifierMeta;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* @version test
*/
@RosettaDataType(value="Identifier", builder=Identifier.IdentifierBuilderImpl.class, version="test")
public interface Identifier extends RosettaModelObject {
IdentifierMeta metaData = new IdentifierMeta();
/*********************** Getter Methods ***********************/
String getId();
/*********************** Build Methods ***********************/
Identifier build();
Identifier.IdentifierBuilder toBuilder();
static Identifier.IdentifierBuilder builder() {
return new Identifier.IdentifierBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends Identifier> metaData() {
return metaData;
}
@Override
default Class extends Identifier> getType() {
return Identifier.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("id"), String.class, getId(), this);
}
/*********************** Builder Interface ***********************/
interface IdentifierBuilder extends Identifier, RosettaModelObjectBuilder {
Identifier.IdentifierBuilder setId(String id);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("id"), String.class, getId(), this);
}
Identifier.IdentifierBuilder prune();
}
/*********************** Immutable Implementation of Identifier ***********************/
class IdentifierImpl implements Identifier {
private final String id;
protected IdentifierImpl(Identifier.IdentifierBuilder builder) {
this.id = builder.getId();
}
@Override
@RosettaAttribute("id")
public String getId() {
return id;
}
@Override
public Identifier build() {
return this;
}
@Override
public Identifier.IdentifierBuilder toBuilder() {
Identifier.IdentifierBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(Identifier.IdentifierBuilder builder) {
ofNullable(getId()).ifPresent(builder::setId);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
Identifier _that = getType().cast(o);
if (!Objects.equals(id, _that.getId())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (id != null ? id.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "Identifier {" +
"id=" + this.id +
'}';
}
}
/*********************** Builder Implementation of Identifier ***********************/
class IdentifierBuilderImpl implements Identifier.IdentifierBuilder {
protected String id;
public IdentifierBuilderImpl() {
}
@Override
@RosettaAttribute("id")
public String getId() {
return id;
}
@Override
@RosettaAttribute("id")
public Identifier.IdentifierBuilder setId(String id) {
this.id = id==null?null:id;
return this;
}
@Override
public Identifier build() {
return new Identifier.IdentifierImpl(this);
}
@Override
public Identifier.IdentifierBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public Identifier.IdentifierBuilder prune() {
return this;
}
@Override
public boolean hasData() {
if (getId()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public Identifier.IdentifierBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
Identifier.IdentifierBuilder o = (Identifier.IdentifierBuilder) other;
merger.mergeBasic(getId(), o.getId(), this::setId);
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;
Identifier _that = getType().cast(o);
if (!Objects.equals(id, _that.getId())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (id != null ? id.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "IdentifierBuilder {" +
"id=" + this.id +
'}';
}
}
}