001/** 002 * Copyright (C) 2007 - 2016, Jens Lehmann 003 * 004 * This file is part of DL-Learner. 005 * 006 * DL-Learner is free software; you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation; either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * DL-Learner is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package org.dllearner.core.owl.fuzzydll; 020 021import org.semanticweb.owlapi.model.IRI; 022 023import uk.ac.manchester.cs.owl.owlapi.OWLNamedIndividualImpl; 024 025public class FuzzyIndividual extends OWLNamedIndividualImpl{ 026 027 private double truthDegree; 028 029 public FuzzyIndividual(String name, double fuzzyDegree) { 030 super(IRI.create(name)); 031 this.truthDegree = fuzzyDegree; 032 } 033 034 public double getTruthDegree() { 035 return truthDegree; 036 } 037 038 public void setTruthDegree(double beliefDegree) { 039 this.truthDegree = beliefDegree; 040 } 041 042 public int compareTo(FuzzyIndividual o) { 043 int d = Double.compare(truthDegree, o.getTruthDegree()); 044 if (d == 0) 045 return super.compareTo(o); 046 else 047 return d; 048 } 049 050 @Override 051 public boolean equals(Object o) { 052 if (this == o) return true; 053 if (!(o instanceof FuzzyIndividual)) return false; 054 if (!super.equals(o)) return false; 055 056 FuzzyIndividual that = (FuzzyIndividual) o; 057 058 return Double.compare(that.truthDegree, truthDegree) == 0; 059 060 } 061 062 @Override 063 public int hashCode() { 064 int result = super.hashCode(); 065 long temp; 066 temp = Double.doubleToLongBits(truthDegree); 067 result = 31 * result + (int) (temp ^ (temp >>> 32)); 068 return result; 069 } 070}