2021-07-01 14:29:47 +02:00
|
|
|
|
|
|
|
package eu.dnetlib.dhp.schema.sx.scholix;
|
|
|
|
|
2022-02-21 10:57:47 +01:00
|
|
|
import com.google.common.collect.ComparisonChain;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeString;
|
2021-07-01 14:29:47 +02:00
|
|
|
import java.io.Serializable;
|
2021-07-06 09:54:26 +02:00
|
|
|
import java.util.Objects;
|
2021-07-01 14:29:47 +02:00
|
|
|
|
2022-02-21 10:57:47 +01:00
|
|
|
public class ScholixIdentifier implements Serializable, Comparable<ScholixIdentifier> {
|
2021-07-01 14:29:47 +02:00
|
|
|
private String identifier;
|
|
|
|
private String schema;
|
2021-07-06 09:54:26 +02:00
|
|
|
private String url;
|
2021-07-01 14:29:47 +02:00
|
|
|
|
|
|
|
public ScholixIdentifier() {
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:54:26 +02:00
|
|
|
public ScholixIdentifier(String identifier, String schema, String url) {
|
2021-07-01 14:29:47 +02:00
|
|
|
this.identifier = identifier;
|
|
|
|
this.schema = schema;
|
2021-07-06 09:54:26 +02:00
|
|
|
this.url = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getUrl() {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUrl(String url) {
|
|
|
|
this.url = url;
|
|
|
|
}
|
|
|
|
|
2021-07-01 14:29:47 +02:00
|
|
|
public String getIdentifier() {
|
|
|
|
return identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setIdentifier(String identifier) {
|
|
|
|
this.identifier = identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSchema() {
|
|
|
|
return schema;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSchema(String schema) {
|
|
|
|
this.schema = schema;
|
|
|
|
}
|
2022-02-21 10:57:47 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int compareTo(ScholixIdentifier o) {
|
|
|
|
final int idComp = StringUtils.compare(normalizeString(identifier), normalizeString(o.getIdentifier()));
|
|
|
|
if (idComp !=0)
|
|
|
|
return idComp;
|
|
|
|
final int schemaComp = StringUtils.compare(normalizeString(schema), normalizeString(o.getSchema()));
|
|
|
|
if (schemaComp !=0)
|
|
|
|
return schemaComp;
|
|
|
|
final int urlComp = StringUtils.compare(normalizeString(url), normalizeString(o.getUrl()));
|
|
|
|
return urlComp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
ScholixIdentifier that = (ScholixIdentifier) o;
|
|
|
|
return compareTo(that) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return Objects.hash(normalizeString(identifier), normalizeString(schema), normalizeString(url));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-01 14:29:47 +02:00
|
|
|
}
|