001package org.dllearner.algorithms.isle.index;
002
003import org.semanticweb.owlapi.model.OWLEntity;
004
005/**
006 * Represents a scored entity. The score is produced from the path used to retrieve it from the candidates tree.
007 * @author Daniel Fleischhacker
008 */
009public class EntityScorePair implements Comparable<EntityScorePair> {
010    @Override
011    public String toString() {
012        return entity + " : " + score;
013    }
014
015    private OWLEntity entity;
016    private Double score;
017
018    @Override
019    public int compareTo(EntityScorePair o) {
020        int val = score.compareTo(o.score);
021
022        if (val == 0) {
023            val = entity.compareTo(o.entity);
024        }
025
026        return val;
027    }
028
029    public EntityScorePair(OWLEntity entity, Double score) {
030        this.entity = entity;
031        this.score = score;
032    }
033
034    public OWLEntity getEntity() {
035        return entity;
036    }
037
038    public void setEntity(OWLEntity entity) {
039        this.entity = entity;
040    }
041
042    public Double getScore() {
043        return score;
044    }
045
046    public void setScore(Double score) {
047        this.score = score;
048    }
049
050    @Override
051    public boolean equals(Object o) {
052        if (this == o) {
053            return true;
054        }
055        if (o == null || getClass() != o.getClass()) {
056            return false;
057        }
058
059        EntityScorePair that = (EntityScorePair) o;
060
061        if (entity != null ? !entity.equals(that.entity) : that.entity != null) {
062            return false;
063        }
064        if (score != null ? !score.equals(that.score) : that.score != null) {
065            return false;
066        }
067
068        return true;
069    }
070
071    @Override
072    public int hashCode() {
073        int result = entity != null ? entity.hashCode() : 0;
074        result = 31 * result + (score != null ? score.hashCode() : 0);
075        return result;
076    }
077}