Program: 9399
Project: 9399
Buggy source:
@SuppressWarnings("String_Node_Str") public SortedSet<OWLIndividual> getIndividualsImplFast(OWLClassExpression description) throws ReasoningMethodUnsupportedException {
  if (description.isOWLThing()) {
    return (TreeSet<OWLIndividual>)individuals.clone();
  }
 else   if (description.isOWLNothing()) {
    return new TreeSet<OWLIndividual>();
  }
 else   if (!description.isAnonymous()) {
    if (classInstancesPos.containsKey(description.asOWLClass())) {
      return (TreeSet<OWLIndividual>)classInstancesPos.get(description).clone();
    }
 else {
      return new TreeSet<OWLIndividual>();
    }
  }
 else   if (description instanceof OWLObjectComplementOf) {
    OWLClassExpression operand=((OWLObjectComplementOf)description).getOperand();
    if (!operand.isAnonymous()) {
      return (TreeSet<OWLIndividual>)classInstancesNeg.get(operand).clone();
    }
    return Helper.difference((TreeSet<OWLIndividual>)individuals.clone(),getIndividualsImpl(operand));
  }
 else   if (description instanceof OWLObjectUnionOf) {
    SortedSet<OWLIndividual> ret=new TreeSet<OWLIndividual>();
    for (    OWLClassExpression operand : ((OWLObjectUnionOf)description).getOperands()) {
      ret.addAll(getIndividualsImpl(operand));
    }
    return ret;
  }
 else   if (description instanceof OWLObjectIntersectionOf) {
    Iterator<OWLClassExpression> iterator=((OWLObjectIntersectionOf)description).getOperands().iterator();
    SortedSet<OWLIndividual> ret=getIndividualsImpl(iterator.next());
    while (iterator.hasNext()) {
      ret.retainAll(getIndividualsImpl(iterator.next()));
    }
    return ret;
  }
 else   if (description instanceof OWLObjectSomeValuesFrom) {
    SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
    OWLObjectPropertyExpression property=((OWLObjectSomeValuesFrom)description).getProperty();
    OWLClassExpression filler=((OWLObjectSomeValuesFrom)description).getFiller();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      SortedSet<OWLIndividual> inds=entry.getValue();
      for (      OWLIndividual ind : inds) {
        if (targetSet.contains(ind)) {
          returnSet.add(entry.getKey());
          break;
        }
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLObjectAllValuesFrom) {
    OWLObjectPropertyExpression property=((OWLObjectAllValuesFrom)description).getProperty();
    OWLClassExpression filler=((OWLObjectAllValuesFrom)description).getFiller();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    SortedSet<OWLIndividual> returnSet=(SortedSet<OWLIndividual>)individuals.clone();
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      SortedSet<OWLIndividual> inds=entry.getValue();
      for (      OWLIndividual ind : inds) {
        if (!targetSet.contains(ind)) {
          returnSet.remove(entry.getKey());
          break;
        }
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLObjectMinCardinality) {
    OWLObjectPropertyExpression property=((OWLObjectMinCardinality)description).getProperty();
    OWLClassExpression filler=((OWLObjectMinCardinality)description).getFiller();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
    int number=((OWLObjectMinCardinality)description).getCardinality();
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      SortedSet<OWLIndividual> inds=entry.getValue();
      if (inds.size() < number) {
        continue;
      }
      for (      OWLIndividual ind : inds) {
        if (nrOfFillers >= number) {
          returnSet.add(entry.getKey());
          break;
        }
        if (inds.size() - index < number) {
          break;
        }
        if (targetSet.contains(ind)) {
          nrOfFillers++;
        }
        index++;
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLObjectMaxCardinality) {
    OWLObjectPropertyExpression property=((OWLObjectMaxCardinality)description).getProperty();
    OWLClassExpression filler=((OWLObjectMaxCardinality)description).getFiller();
    int number=((OWLObjectMaxCardinality)description).getCardinality();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    SortedSet<OWLIndividual> returnSet=(SortedSet<OWLIndividual>)individuals.clone();
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      SortedSet<OWLIndividual> inds=entry.getValue();
      if (number < inds.size()) {
        returnSet.add(entry.getKey());
        continue;
      }
      for (      OWLIndividual ind : inds) {
        if (nrOfFillers >= number) {
          break;
        }
        if (inds.size() - index < number) {
          returnSet.add(entry.getKey());
          break;
        }
        if (targetSet.contains(ind)) {
          nrOfFillers++;
        }
        index++;
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLObjectHasValue) {
    OWLObjectPropertyExpression property=((OWLObjectHasValue)description).getProperty();
    OWLIndividual value=((OWLObjectHasValue)description).getValue();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      if (entry.getValue().contains(value)) {
        returnSet.add(entry.getKey());
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLDataSomeValuesFrom) {
    OWLDataPropertyExpression property=((OWLDataSomeValuesFrom)description).getProperty();
    OWLDataRange filler=((OWLDataSomeValuesFrom)description).getFiller();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    if (filler.isDatatype()) {
      return new TreeSet<OWLIndividual>(dpPos.get(property).keySet());
    }
 else     if (filler instanceof OWLDatatypeRestriction) {
      OWLDatatype datatype=((OWLDatatypeRestriction)filler).getDatatype();
      Set<OWLFacetRestriction> facetRestrictions=((OWLDatatypeRestriction)filler).getFacetRestrictions();
      if (datatype.isDouble()) {
        double min=-Double.MAX_VALUE;
        double max=Double.MAX_VALUE;
        for (        OWLFacetRestriction facet : facetRestrictions) {
          if (facet.getFacet() == OWLFacet.MIN_INCLUSIVE) {
            min=facet.getFacetValue().parseDouble();
          }
 else           if (facet.getFacet() == OWLFacet.MAX_INCLUSIVE) {
            max=facet.getFacetValue().parseDouble();
          }
        }
        Map<OWLIndividual,SortedSet<Double>> mapping=dd.get(property);
        SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
        for (        Entry<OWLIndividual,SortedSet<Double>> entry : mapping.entrySet()) {
          if (entry.getValue().last() < min || entry.getValue().first() > max) {
            continue;
          }
          for (          Double value : entry.getValue()) {
            if (value >= min && value <= max) {
              returnSet.add(entry.getKey());
              break;
            }
          }
        }
        return returnSet;
      }
    }
  }
 else   if (description instanceof OWLDataHasValue) {
    OWLDataPropertyExpression property=((OWLDataHasValue)description).getProperty();
    OWLLiteral value=((OWLDataHasValue)description).getValue();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
    Map<OWLIndividual,SortedSet<OWLLiteral>> mapping=dpPos.get(property);
    for (    Entry<OWLIndividual,SortedSet<OWLLiteral>> entry : mapping.entrySet()) {
      if (entry.getValue().contains(value)) {
        returnSet.add(entry.getKey());
      }
    }
    return returnSet;
  }
  throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public SortedSet<OWLIndividual> getIndividualsImplFast(OWLClassExpression description) throws ReasoningMethodUnsupportedException {
  if (description.isOWLThing()) {
    return (TreeSet<OWLIndividual>)individuals.clone();
  }
 else   if (description.isOWLNothing()) {
    return new TreeSet<OWLIndividual>();
  }
 else   if (!description.isAnonymous()) {
    if (classInstancesPos.containsKey(description.asOWLClass())) {
      return (TreeSet<OWLIndividual>)classInstancesPos.get(description).clone();
    }
 else {
      return new TreeSet<OWLIndividual>();
    }
  }
 else   if (description instanceof OWLObjectComplementOf) {
    OWLClassExpression operand=((OWLObjectComplementOf)description).getOperand();
    if (!operand.isAnonymous()) {
      if (isDefaultNegation()) {
        return new TreeSet<OWLIndividual>(Sets.difference(individuals,classInstancesPos.get(operand)));
      }
 else {
        return (TreeSet<OWLIndividual>)classInstancesNeg.get(operand).clone();
      }
    }
    return Helper.difference((TreeSet<OWLIndividual>)individuals.clone(),getIndividualsImpl(operand));
  }
 else   if (description instanceof OWLObjectUnionOf) {
    SortedSet<OWLIndividual> ret=new TreeSet<OWLIndividual>();
    for (    OWLClassExpression operand : ((OWLObjectUnionOf)description).getOperands()) {
      ret.addAll(getIndividualsImpl(operand));
    }
    return ret;
  }
 else   if (description instanceof OWLObjectIntersectionOf) {
    Iterator<OWLClassExpression> iterator=((OWLObjectIntersectionOf)description).getOperands().iterator();
    SortedSet<OWLIndividual> ret=getIndividualsImpl(iterator.next());
    while (iterator.hasNext()) {
      ret.retainAll(getIndividualsImpl(iterator.next()));
    }
    return ret;
  }
 else   if (description instanceof OWLObjectSomeValuesFrom) {
    SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
    OWLObjectPropertyExpression property=((OWLObjectSomeValuesFrom)description).getProperty();
    OWLClassExpression filler=((OWLObjectSomeValuesFrom)description).getFiller();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      SortedSet<OWLIndividual> inds=entry.getValue();
      for (      OWLIndividual ind : inds) {
        if (targetSet.contains(ind)) {
          returnSet.add(entry.getKey());
          break;
        }
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLObjectAllValuesFrom) {
    OWLObjectPropertyExpression property=((OWLObjectAllValuesFrom)description).getProperty();
    OWLClassExpression filler=((OWLObjectAllValuesFrom)description).getFiller();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    SortedSet<OWLIndividual> returnSet=(SortedSet<OWLIndividual>)individuals.clone();
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      SortedSet<OWLIndividual> inds=entry.getValue();
      for (      OWLIndividual ind : inds) {
        if (!targetSet.contains(ind)) {
          returnSet.remove(entry.getKey());
          break;
        }
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLObjectMinCardinality) {
    OWLObjectPropertyExpression property=((OWLObjectMinCardinality)description).getProperty();
    OWLClassExpression filler=((OWLObjectMinCardinality)description).getFiller();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
    int number=((OWLObjectMinCardinality)description).getCardinality();
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      SortedSet<OWLIndividual> inds=entry.getValue();
      if (inds.size() < number) {
        continue;
      }
      for (      OWLIndividual ind : inds) {
        if (nrOfFillers >= number) {
          returnSet.add(entry.getKey());
          break;
        }
        if (inds.size() - index < number) {
          break;
        }
        if (targetSet.contains(ind)) {
          nrOfFillers++;
        }
        index++;
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLObjectMaxCardinality) {
    OWLObjectPropertyExpression property=((OWLObjectMaxCardinality)description).getProperty();
    OWLClassExpression filler=((OWLObjectMaxCardinality)description).getFiller();
    int number=((OWLObjectMaxCardinality)description).getCardinality();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    SortedSet<OWLIndividual> returnSet=(SortedSet<OWLIndividual>)individuals.clone();
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      SortedSet<OWLIndividual> inds=entry.getValue();
      if (number < inds.size()) {
        returnSet.add(entry.getKey());
        continue;
      }
      for (      OWLIndividual ind : inds) {
        if (nrOfFillers >= number) {
          break;
        }
        if (inds.size() - index < number) {
          returnSet.add(entry.getKey());
          break;
        }
        if (targetSet.contains(ind)) {
          nrOfFillers++;
        }
        index++;
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLObjectHasValue) {
    OWLObjectPropertyExpression property=((OWLObjectHasValue)description).getProperty();
    OWLIndividual value=((OWLObjectHasValue)description).getValue();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    Map<OWLIndividual,SortedSet<OWLIndividual>> mapping=opPos.get(property.asOWLObjectProperty());
    SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
    for (    Entry<OWLIndividual,SortedSet<OWLIndividual>> entry : mapping.entrySet()) {
      if (entry.getValue().contains(value)) {
        returnSet.add(entry.getKey());
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLDataSomeValuesFrom) {
    OWLDataPropertyExpression property=((OWLDataSomeValuesFrom)description).getProperty();
    OWLDataRange filler=((OWLDataSomeValuesFrom)description).getFiller();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    if (filler.isDatatype()) {
      return new TreeSet<OWLIndividual>(dpPos.get(property).keySet());
    }
 else     if (filler instanceof OWLDatatypeRestriction) {
      OWLDatatype datatype=((OWLDatatypeRestriction)filler).getDatatype();
      Set<OWLFacetRestriction> facetRestrictions=((OWLDatatypeRestriction)filler).getFacetRestrictions();
      if (datatype.isDouble()) {
        double min=-Double.MAX_VALUE;
        double max=Double.MAX_VALUE;
        for (        OWLFacetRestriction facet : facetRestrictions) {
          if (facet.getFacet() == OWLFacet.MIN_INCLUSIVE) {
            min=facet.getFacetValue().parseDouble();
          }
 else           if (facet.getFacet() == OWLFacet.MAX_INCLUSIVE) {
            max=facet.getFacetValue().parseDouble();
          }
        }
        Map<OWLIndividual,SortedSet<Double>> mapping=dd.get(property);
        SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
        for (        Entry<OWLIndividual,SortedSet<Double>> entry : mapping.entrySet()) {
          if (entry.getValue().last() < min || entry.getValue().first() > max) {
            continue;
          }
          for (          Double value : entry.getValue()) {
            if (value >= min && value <= max) {
              returnSet.add(entry.getKey());
              break;
            }
          }
        }
        return returnSet;
      }
    }
  }
 else   if (description instanceof OWLDataHasValue) {
    OWLDataPropertyExpression property=((OWLDataHasValue)description).getProperty();
    OWLLiteral value=((OWLDataHasValue)description).getValue();
    if (property.isAnonymous()) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    SortedSet<OWLIndividual> returnSet=new TreeSet<OWLIndividual>();
    Map<OWLIndividual,SortedSet<OWLLiteral>> mapping=dpPos.get(property);
    for (    Entry<OWLIndividual,SortedSet<OWLLiteral>> entry : mapping.entrySet()) {
      if (entry.getValue().contains(value)) {
        returnSet.add(entry.getKey());
      }
    }
    return returnSet;
  }
  throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
}