a bit of syntactic sugar on the object inheritance

This commit is contained in:
Claudio Atzori 2019-10-25 10:55:35 +02:00
parent b0aa7cd7fb
commit 4eaff36ea6
11 changed files with 120 additions and 79 deletions

View File

@ -3,7 +3,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.List;
public class Dataset extends Result implements Serializable {
public class Dataset extends Result<Dataset> implements Serializable {
private Field<String> storagedate;
@ -81,4 +81,9 @@ public class Dataset extends Result implements Serializable {
this.geolocation = geolocation;
return this;
}
@Override
protected Dataset self() {
return this;
}
}

View File

@ -3,7 +3,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.List;
public class Datasource extends OafEntity implements Serializable {
public class Datasource extends OafEntity<Datasource> implements Serializable {
private Qualifier datasourcetype;
@ -396,4 +396,9 @@ public class Datasource extends OafEntity implements Serializable {
this.journal = journal;
return this;
}
@Override
protected Datasource self() {
return this;
}
}

View File

@ -2,27 +2,29 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
public abstract class Oaf implements Serializable {
public abstract class Oaf<T extends Oaf<T>> implements Serializable {
private DataInfo dataInfo;
private Long lastupdatetimestamp;
protected abstract T self();
public DataInfo getDataInfo() {
return dataInfo;
}
public Oaf setDataInfo(DataInfo dataInfo) {
public T setDataInfo(DataInfo dataInfo) {
this.dataInfo = dataInfo;
return this;
return self();
}
public Long getLastupdatetimestamp() {
return lastupdatetimestamp;
}
public Oaf setLastupdatetimestamp(Long lastupdatetimestamp) {
public T setLastupdatetimestamp(Long lastupdatetimestamp) {
this.lastupdatetimestamp = lastupdatetimestamp;
return this;
return self();
}
}

View File

@ -3,7 +3,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.List;
public abstract class OafEntity extends Oaf implements Serializable {
public abstract class OafEntity<T extends OafEntity<T>> extends Oaf<T> implements Serializable {
private String id;
@ -21,76 +21,75 @@ public abstract class OafEntity extends Oaf implements Serializable {
private OAIProvenance oaiprovenance;
public String getId() {
return id;
}
public OafEntity setId(String id) {
public T setId(String id) {
this.id = id;
return this;
return self();
}
public List<String> getOriginalId() {
return originalId;
}
public OafEntity setOriginalId(List<String> originalId) {
public T setOriginalId(List<String> originalId) {
this.originalId = originalId;
return this;
return self();
}
public List<KeyValue> getCollectedfrom() {
return collectedfrom;
}
public OafEntity setCollectedfrom(List<KeyValue> collectedfrom) {
public T setCollectedfrom(List<KeyValue> collectedfrom) {
this.collectedfrom = collectedfrom;
return this;
return self();
}
public List<StructuredProperty> getPid() {
return pid;
}
public OafEntity setPid(List<StructuredProperty> pid) {
public T setPid(List<StructuredProperty> pid) {
this.pid = pid;
return this;
return self();
}
public String getDateofcollection() {
return dateofcollection;
}
public OafEntity setDateofcollection(String dateofcollection) {
public T setDateofcollection(String dateofcollection) {
this.dateofcollection = dateofcollection;
return this;
return self();
}
public String getDateoftransformation() {
return dateoftransformation;
}
public OafEntity setDateoftransformation(String dateoftransformation) {
public T setDateoftransformation(String dateoftransformation) {
this.dateoftransformation = dateoftransformation;
return this;
return self();
}
public List<ExtraInfo> getExtraInfo() {
return extraInfo;
}
public OafEntity setExtraInfo(List<ExtraInfo> extraInfo) {
public T setExtraInfo(List<ExtraInfo> extraInfo) {
this.extraInfo = extraInfo;
return this;
return self();
}
public OAIProvenance getOaiprovenance() {
return oaiprovenance;
}
public OafEntity setOaiprovenance(OAIProvenance oaiprovenance) {
public T setOaiprovenance(OAIProvenance oaiprovenance) {
this.oaiprovenance = oaiprovenance;
return this;
return self();
}
}

View File

@ -3,7 +3,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.List;
public class Organization extends OafEntity implements Serializable {
public class Organization extends OafEntity<Organization> implements Serializable {
private Field<String> legalshortname;
@ -180,4 +180,9 @@ public class Organization extends OafEntity implements Serializable {
this.country = country;
return this;
}
@Override
protected Organization self() {
return this;
}
}

View File

@ -3,7 +3,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.List;
public class OtherResearchProducts extends Result implements Serializable {
public class OtherResearchProducts extends Result<OtherResearchProducts> implements Serializable {
private List<Field<String>> contactperson;
@ -37,4 +37,9 @@ public class OtherResearchProducts extends Result implements Serializable {
this.tool = tool;
return this;
}
@Override
protected OtherResearchProducts self() {
return this;
}
}

View File

@ -3,7 +3,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.List;
public class Project extends OafEntity implements Serializable {
public class Project extends OafEntity<Project> implements Serializable {
private Field<String> websiteurl;
@ -290,4 +290,9 @@ public class Project extends OafEntity implements Serializable {
this.fundedamount = fundedamount;
return this;
}
@Override
protected Project self() {
return this;
}
}

View File

@ -2,7 +2,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
public class Publication extends Result implements Serializable {
public class Publication extends Result<Publication> implements Serializable {
// publication specific
private Journal journal;
@ -15,4 +15,9 @@ public class Publication extends Result implements Serializable {
this.journal = journal;
return this;
}
@Override
protected Publication self() {
return self();
}
}

View File

@ -2,7 +2,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.util.List;
public class Relation extends Oaf {
public class Relation extends Oaf<Relation> {
private String relType;
@ -22,7 +22,7 @@ public class Relation extends Oaf {
public Relation setRelType(String relType) {
this.relType = relType;
return this;
return self();
}
public String getSubRelType() {
@ -31,7 +31,7 @@ public class Relation extends Oaf {
public Relation setSubRelType(String subRelType) {
this.subRelType = subRelType;
return this;
return self();
}
public String getRelClass() {
@ -40,7 +40,7 @@ public class Relation extends Oaf {
public Relation setRelClass(String relClass) {
this.relClass = relClass;
return this;
return self();
}
public String getSource() {
@ -49,7 +49,7 @@ public class Relation extends Oaf {
public Relation setSource(String source) {
this.source = source;
return this;
return self();
}
public String getTarget() {
@ -58,7 +58,7 @@ public class Relation extends Oaf {
public Relation setTarget(String target) {
this.target = target;
return this;
return self();
}
public List<KeyValue> getCollectedFrom() {
@ -67,6 +67,11 @@ public class Relation extends Oaf {
public Relation setCollectedFrom(List<KeyValue> collectedFrom) {
this.collectedFrom = collectedFrom;
return self();
}
@Override
protected Relation self() {
return this;
}
}

View File

@ -3,7 +3,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.List;
public abstract class Result extends OafEntity implements Serializable {
public abstract class Result<T extends Result<T>> extends OafEntity<T> implements Serializable {
private List<Author> author;
@ -53,188 +53,188 @@ public abstract class Result extends OafEntity implements Serializable {
return author;
}
public Result setAuthor(List<Author> author) {
public T setAuthor(List<Author> author) {
this.author = author;
return this;
return self();
}
public Qualifier getResulttype() {
return resulttype;
}
public Result setResulttype(Qualifier resulttype) {
public T setResulttype(Qualifier resulttype) {
this.resulttype = resulttype;
return this;
return self();
}
public Qualifier getLanguage() {
return language;
}
public Result setLanguage(Qualifier language) {
public T setLanguage(Qualifier language) {
this.language = language;
return this;
return self();
}
public List<Qualifier> getCountry() {
return country;
}
public Result setCountry(List<Qualifier> country) {
public T setCountry(List<Qualifier> country) {
this.country = country;
return this;
return self();
}
public List<StructuredProperty> getSubject() {
return subject;
}
public Result setSubject(List<StructuredProperty> subject) {
public T setSubject(List<StructuredProperty> subject) {
this.subject = subject;
return this;
return self();
}
public List<StructuredProperty> getTitle() {
return title;
}
public Result setTitle(List<StructuredProperty> title) {
public T setTitle(List<StructuredProperty> title) {
this.title = title;
return this;
return self();
}
public List<StructuredProperty> getRelevantdate() {
return relevantdate;
}
public Result setRelevantdate(List<StructuredProperty> relevantdate) {
public T setRelevantdate(List<StructuredProperty> relevantdate) {
this.relevantdate = relevantdate;
return this;
return self();
}
public List<Field<String>> getDescription() {
return description;
}
public Result setDescription(List<Field<String>> description) {
public T setDescription(List<Field<String>> description) {
this.description = description;
return this;
return self();
}
public Field<String> getDateofacceptance() {
return dateofacceptance;
}
public Result setDateofacceptance(Field<String> dateofacceptance) {
public T setDateofacceptance(Field<String> dateofacceptance) {
this.dateofacceptance = dateofacceptance;
return this;
return self();
}
public Field<String> getPublisher() {
return publisher;
}
public Result setPublisher(Field<String> publisher) {
public T setPublisher(Field<String> publisher) {
this.publisher = publisher;
return this;
return self();
}
public Field<String> getEmbargoenddate() {
return embargoenddate;
}
public Result setEmbargoenddate(Field<String> embargoenddate) {
public T setEmbargoenddate(Field<String> embargoenddate) {
this.embargoenddate = embargoenddate;
return this;
return self();
}
public List<Field<String>> getSource() {
return source;
}
public Result setSource(List<Field<String>> source) {
public T setSource(List<Field<String>> source) {
this.source = source;
return this;
return self();
}
public List<Field<String>> getFulltext() {
return fulltext;
}
public Result setFulltext(List<Field<String>> fulltext) {
public T setFulltext(List<Field<String>> fulltext) {
this.fulltext = fulltext;
return this;
return self();
}
public List<Field<String>> getFormat() {
return format;
}
public Result setFormat(List<Field<String>> format) {
public T setFormat(List<Field<String>> format) {
this.format = format;
return this;
return self();
}
public List<Field<String>> getContributor() {
return contributor;
}
public Result setContributor(List<Field<String>> contributor) {
public T setContributor(List<Field<String>> contributor) {
this.contributor = contributor;
return this;
return self();
}
public Qualifier getResourcetype() {
return resourcetype;
}
public Result setResourcetype(Qualifier resourcetype) {
public T setResourcetype(Qualifier resourcetype) {
this.resourcetype = resourcetype;
return this;
return self();
}
public List<Field<String>> getCoverage() {
return coverage;
}
public Result setCoverage(List<Field<String>> coverage) {
public T setCoverage(List<Field<String>> coverage) {
this.coverage = coverage;
return this;
return self();
}
public Field<String> getRefereed() {
return refereed;
}
public Result setRefereed(Field<String> refereed) {
public T setRefereed(Field<String> refereed) {
this.refereed = refereed;
return this;
return self();
}
public List<Context> getContext() {
return context;
}
public Result setContext(List<Context> context) {
public T setContext(List<Context> context) {
this.context = context;
return this;
return self();
}
public List<ExternalReference> getExternalReference() {
return externalReference;
}
public Result setExternalReference(List<ExternalReference> externalReference) {
public T setExternalReference(List<ExternalReference> externalReference) {
this.externalReference = externalReference;
return this;
return self();
}
public List<Instance> getInstance() {
return instance;
}
public Result setInstance(List<Instance> instance) {
public T setInstance(List<Instance> instance) {
this.instance = instance;
return this;
return self();
}
}

View File

@ -3,7 +3,7 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.List;
public class Software extends Result implements Serializable {
public class Software extends Result<Software> implements Serializable {
private List<Field<String>> documentationUrl;
@ -48,4 +48,9 @@ public class Software extends Result implements Serializable {
this.programmingLanguage = programmingLanguage;
return this;
}
@Override
protected Software self() {
return this;
}
}