2021-07-01 14:29:47 +02:00
|
|
|
|
|
|
|
package eu.dnetlib.dhp.schema.sx.scholix;
|
|
|
|
|
2022-02-22 17:26:05 +01:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
2021-07-01 14:29:47 +02:00
|
|
|
import java.io.Serializable;
|
2022-02-22 17:26:05 +01:00
|
|
|
import java.util.Objects;
|
|
|
|
import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*;
|
2021-07-01 14:29:47 +02:00
|
|
|
|
2022-02-22 17:26:05 +01:00
|
|
|
public class ScholixRelationship implements Serializable, Comparable<ScholixRelationship> {
|
2021-07-01 14:29:47 +02:00
|
|
|
private String name;
|
|
|
|
private String schema;
|
|
|
|
private String inverse;
|
|
|
|
|
|
|
|
public ScholixRelationship() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public ScholixRelationship(String name, String schema, String inverse) {
|
|
|
|
this.name = name;
|
|
|
|
this.schema = schema;
|
|
|
|
this.inverse = inverse;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSchema() {
|
|
|
|
return schema;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSchema(String schema) {
|
|
|
|
this.schema = schema;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getInverse() {
|
|
|
|
return inverse;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setInverse(String inverse) {
|
|
|
|
this.inverse = inverse;
|
|
|
|
}
|
2022-02-22 17:26:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (!(o instanceof ScholixRelationship)) return false;
|
|
|
|
ScholixRelationship that = (ScholixRelationship) o;
|
|
|
|
return this.compareTo(that) ==0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return Objects.hash(normalizeString(getName()), normalizeString(getSchema()), normalizeString(getInverse()));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int compareTo(ScholixRelationship other) {
|
|
|
|
if (other == null)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
final int nameCompare = StringUtils.compare(normalizeString(name), normalizeString(other.getName()));
|
|
|
|
if (nameCompare!= 0 )
|
|
|
|
return nameCompare;
|
|
|
|
|
|
|
|
final int schemaCompare = StringUtils.compare(normalizeString(schema), normalizeString(other.getSchema()));
|
|
|
|
if (schemaCompare!= 0 )
|
|
|
|
return schemaCompare;
|
|
|
|
|
|
|
|
return StringUtils.compare(normalizeString(inverse), normalizeString(other.getInverse()));
|
|
|
|
}
|
2021-07-01 14:29:47 +02:00
|
|
|
}
|