001/** 002 * 003 */ 004package org.dllearner.algorithms.miles; 005 006import org.semanticweb.owlapi.model.OWLClassExpression; 007 008/** 009 * A description/concept that has a weight. 010 * @author Lorenz Buehmann 011 * 012 */ 013public class WeightedDescription { 014 015 private OWLClassExpression description; 016 private double weight; 017 018 public WeightedDescription(OWLClassExpression description, double weight) { 019 this.description = description; 020 this.weight = weight; 021 } 022 023 /** 024 * @return the description 025 */ 026 public OWLClassExpression getDescription() { 027 return description; 028 } 029 030 /** 031 * @return the weight 032 */ 033 public double getWeight() { 034 return weight; 035 } 036 037 /* (non-Javadoc) 038 * @see java.lang.Object#toString() 039 */ 040 @Override 041 public String toString() { 042 return weight + "*" + description.toString(); 043 } 044 045 @Override 046 public int hashCode() { 047 final int prime = 31; 048 int result = 1; 049 result = prime * result + ((description == null) ? 0 : description.hashCode()); 050 long temp; 051 temp = Double.doubleToLongBits(weight); 052 result = prime * result + (int) (temp ^ (temp >>> 32)); 053 return result; 054 } 055 056 @Override 057 public boolean equals(Object obj) { 058 if (this == obj) 059 return true; 060 if (obj == null) 061 return false; 062 if (getClass() != obj.getClass()) 063 return false; 064 WeightedDescription other = (WeightedDescription) obj; 065 if (description == null) { 066 if (other.description != null) 067 return false; 068 } else if (!description.equals(other.description)) 069 return false; 070 if (Double.doubleToLongBits(weight) != Double.doubleToLongBits(other.weight)) 071 return false; 072 return true; 073 } 074 075 076 077}