package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.*; import java.util.stream.Collectors; public abstract class OafEntity extends Oaf implements Serializable { private String id; private List originalId; private List collectedfrom; private List pid; private String dateofcollection; private String dateoftransformation; private List extraInfo; private OAIProvenance oaiprovenance; public String getId() { return id; } public void setId(String id) { this.id = id; } public List getOriginalId() { return originalId; } public void setOriginalId(List originalId) { this.originalId = originalId; } public List getCollectedfrom() { return collectedfrom; } public void setCollectedfrom(List collectedfrom) { this.collectedfrom = collectedfrom; } public List getPid() { return pid; } public void setPid(List pid) { this.pid = pid; } public String getDateofcollection() { return dateofcollection; } public void setDateofcollection(String dateofcollection) { this.dateofcollection = dateofcollection; } public String getDateoftransformation() { return dateoftransformation; } public void setDateoftransformation(String dateoftransformation) { this.dateoftransformation = dateoftransformation; } public List getExtraInfo() { return extraInfo; } public void setExtraInfo(List extraInfo) { this.extraInfo = extraInfo; } public OAIProvenance getOaiprovenance() { return oaiprovenance; } public void setOaiprovenance(OAIProvenance oaiprovenance) { this.oaiprovenance = oaiprovenance; } public void mergeFrom(OafEntity e) { if (e == null) return; originalId = mergeLists(originalId, e.getOriginalId()); collectedfrom = mergeLists(collectedfrom, e.getCollectedfrom()); pid = mergeLists(pid, e.getPid()); if (e.getDateofcollection() != null && compareTrust(this, e) < 0) dateofcollection = e.getDateofcollection(); if (e.getDateoftransformation() != null && compareTrust(this, e) < 0) dateoftransformation = e.getDateoftransformation(); extraInfo = mergeLists(extraInfo, e.getExtraInfo()); if (e.getOaiprovenance() != null && compareTrust(this, e) < 0) oaiprovenance = e.getOaiprovenance(); } protected List mergeLists(final List... lists) { return Arrays.stream(lists).filter(Objects::nonNull).flatMap(List::stream).distinct().collect(Collectors.toList()); } }