Program: 9599
Project: 9599
Buggy source:
@SuppressWarnings("String_Node_Str") public SortedSet<Individual> getIndividualsImplFast(Description description) throws ReasoningMethodUnsupportedException {
  if (description instanceof NamedClass) {
    return (TreeSet<Individual>)classInstancesPos.get((NamedClass)description).clone();
  }
 else   if (description instanceof Negation) {
    if (description.getChild(0) instanceof NamedClass) {
      return (TreeSet<Individual>)classInstancesNeg.get((NamedClass)description.getChild(0)).clone();
    }
    return Helper.difference((TreeSet<Individual>)individuals.clone(),getIndividualsImpl(description.getChild(0)));
  }
 else   if (description instanceof Thing) {
    return (TreeSet<Individual>)individuals.clone();
  }
 else   if (description instanceof Nothing) {
    return new TreeSet<Individual>();
  }
 else   if (description instanceof Union) {
    SortedSet<Individual> ret=getIndividualsImpl(description.getChild(0));
    int childNr=0;
    for (    Description child : description.getChildren()) {
      if (childNr != 0) {
        ret.addAll(getIndividualsImpl(child));
      }
      childNr++;
    }
    return ret;
  }
 else   if (description instanceof Intersection) {
    SortedSet<Individual> ret=getIndividualsImpl(description.getChild(0));
    int childNr=0;
    for (    Description child : description.getChildren()) {
      if (childNr != 0) {
        ret.retainAll(getIndividualsImpl(child));
      }
      childNr++;
    }
    return ret;
  }
 else   if (description instanceof ObjectSomeRestriction) {
    SortedSet<Individual> targetSet=getIndividualsImpl(description.getChild(0));
    SortedSet<Individual> returnSet=new TreeSet<Individual>();
    ObjectPropertyExpression ope=((ObjectSomeRestriction)description).getRole();
    if (!(ope instanceof ObjectProperty)) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    ObjectProperty op=(ObjectProperty)ope;
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      SortedSet<Individual> inds=entry.getValue();
      for (      Individual ind : inds) {
        if (targetSet.contains(ind)) {
          returnSet.add(entry.getKey());
          continue;
        }
      }
    }
    return returnSet;
  }
 else   if (description instanceof ObjectAllRestriction) {
    SortedSet<Individual> targetSet=getIndividualsImpl(description.getChild(0));
    ObjectPropertyExpression ope=((ObjectAllRestriction)description).getRole();
    if (!(ope instanceof ObjectProperty)) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    ObjectProperty op=(ObjectProperty)ope;
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    SortedSet<Individual> returnSet=(SortedSet<Individual>)individuals.clone();
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      SortedSet<Individual> inds=entry.getValue();
      for (      Individual ind : inds) {
        if (!targetSet.contains(ind)) {
          returnSet.remove(entry.getKey());
          continue;
        }
      }
    }
    return returnSet;
  }
 else   if (description instanceof ObjectMinCardinalityRestriction) {
    ObjectPropertyExpression ope=((ObjectCardinalityRestriction)description).getRole();
    if (!(ope instanceof ObjectProperty)) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    ObjectProperty op=(ObjectProperty)ope;
    Description child=description.getChild(0);
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    SortedSet<Individual> targetSet=getIndividualsImpl(child);
    SortedSet<Individual> returnSet=new TreeSet<Individual>();
    int number=((ObjectCardinalityRestriction)description).getNumber();
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      SortedSet<Individual> inds=entry.getValue();
      if (inds.size() < number) {
        continue;
      }
      for (      Individual 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 ObjectMaxCardinalityRestriction) {
    ObjectPropertyExpression ope=((ObjectCardinalityRestriction)description).getRole();
    if (!(ope instanceof ObjectProperty)) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    ObjectProperty op=(ObjectProperty)ope;
    Description child=description.getChild(0);
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    SortedSet<Individual> targetSet=getIndividualsImpl(child);
    SortedSet<Individual> returnSet=(SortedSet<Individual>)individuals.clone();
    int number=((ObjectCardinalityRestriction)description).getNumber();
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      SortedSet<Individual> inds=entry.getValue();
      if (number < inds.size()) {
        returnSet.add(entry.getKey());
        continue;
      }
      for (      Individual 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 ObjectValueRestriction) {
    Individual i=((ObjectValueRestriction)description).getIndividual();
    ObjectProperty op=(ObjectProperty)((ObjectValueRestriction)description).getRestrictedPropertyExpression();
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    SortedSet<Individual> returnSet=new TreeSet<Individual>();
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      if (entry.getValue().contains(i)) {
        returnSet.add(entry.getKey());
      }
    }
    return returnSet;
  }
 else   if (description instanceof BooleanValueRestriction) {
    DatatypeProperty dp=((BooleanValueRestriction)description).getRestrictedPropertyExpression();
    boolean value=((BooleanValueRestriction)description).getBooleanValue();
    if (value) {
      return (TreeSet<Individual>)bdPos.get(dp).clone();
    }
 else {
      return (TreeSet<Individual>)bdNeg.get(dp).clone();
    }
  }
 else   if (description instanceof DatatypeSomeRestriction) {
    DatatypeSomeRestriction dsr=(DatatypeSomeRestriction)description;
    DatatypeProperty dp=(DatatypeProperty)dsr.getRestrictedPropertyExpression();
    DataRange dr=dsr.getDataRange();
    Map<Individual,SortedSet<Double>> mapping=dd.get(dp);
    SortedSet<Individual> returnSet=new TreeSet<Individual>();
    if (dr instanceof DoubleMaxValue) {
      for (      Entry<Individual,SortedSet<Double>> entry : mapping.entrySet()) {
        if (entry.getValue().first() <= ((DoubleMaxValue)dr).getValue()) {
          returnSet.add(entry.getKey());
        }
      }
    }
 else     if (dr instanceof DoubleMinValue) {
      for (      Entry<Individual,SortedSet<Double>> entry : mapping.entrySet()) {
        if (entry.getValue().last() >= ((DoubleMinValue)dr).getValue()) {
          returnSet.add(entry.getKey());
        }
      }
    }
  }
  throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public SortedSet<Individual> getIndividualsImplFast(Description description) throws ReasoningMethodUnsupportedException {
  if (description instanceof NamedClass) {
    if (((NamedClass)description).getName().equals("String_Node_Str")) {
      return new TreeSet<Individual>();
    }
    return (TreeSet<Individual>)classInstancesPos.get((NamedClass)description).clone();
  }
 else   if (description instanceof Negation) {
    if (description.getChild(0) instanceof NamedClass) {
      return (TreeSet<Individual>)classInstancesNeg.get((NamedClass)description.getChild(0)).clone();
    }
    return Helper.difference((TreeSet<Individual>)individuals.clone(),getIndividualsImpl(description.getChild(0)));
  }
 else   if (description instanceof Thing) {
    return (TreeSet<Individual>)individuals.clone();
  }
 else   if (description instanceof Nothing) {
    return new TreeSet<Individual>();
  }
 else   if (description instanceof Union) {
    SortedSet<Individual> ret=getIndividualsImpl(description.getChild(0));
    int childNr=0;
    for (    Description child : description.getChildren()) {
      if (childNr != 0) {
        ret.addAll(getIndividualsImpl(child));
      }
      childNr++;
    }
    return ret;
  }
 else   if (description instanceof Intersection) {
    SortedSet<Individual> ret=getIndividualsImpl(description.getChild(0));
    int childNr=0;
    for (    Description child : description.getChildren()) {
      if (childNr != 0) {
        ret.retainAll(getIndividualsImpl(child));
      }
      childNr++;
    }
    return ret;
  }
 else   if (description instanceof ObjectSomeRestriction) {
    SortedSet<Individual> targetSet=getIndividualsImpl(description.getChild(0));
    SortedSet<Individual> returnSet=new TreeSet<Individual>();
    ObjectPropertyExpression ope=((ObjectSomeRestriction)description).getRole();
    if (!(ope instanceof ObjectProperty)) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    ObjectProperty op=(ObjectProperty)ope;
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      SortedSet<Individual> inds=entry.getValue();
      for (      Individual ind : inds) {
        if (targetSet.contains(ind)) {
          returnSet.add(entry.getKey());
          continue;
        }
      }
    }
    return returnSet;
  }
 else   if (description instanceof ObjectAllRestriction) {
    SortedSet<Individual> targetSet=getIndividualsImpl(description.getChild(0));
    ObjectPropertyExpression ope=((ObjectAllRestriction)description).getRole();
    if (!(ope instanceof ObjectProperty)) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    ObjectProperty op=(ObjectProperty)ope;
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    SortedSet<Individual> returnSet=(SortedSet<Individual>)individuals.clone();
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      SortedSet<Individual> inds=entry.getValue();
      for (      Individual ind : inds) {
        if (!targetSet.contains(ind)) {
          returnSet.remove(entry.getKey());
          continue;
        }
      }
    }
    return returnSet;
  }
 else   if (description instanceof ObjectMinCardinalityRestriction) {
    ObjectPropertyExpression ope=((ObjectCardinalityRestriction)description).getRole();
    if (!(ope instanceof ObjectProperty)) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    ObjectProperty op=(ObjectProperty)ope;
    Description child=description.getChild(0);
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    SortedSet<Individual> targetSet=getIndividualsImpl(child);
    SortedSet<Individual> returnSet=new TreeSet<Individual>();
    int number=((ObjectCardinalityRestriction)description).getNumber();
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      SortedSet<Individual> inds=entry.getValue();
      if (inds.size() < number) {
        continue;
      }
      for (      Individual 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 ObjectMaxCardinalityRestriction) {
    ObjectPropertyExpression ope=((ObjectCardinalityRestriction)description).getRole();
    if (!(ope instanceof ObjectProperty)) {
      throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
    }
    ObjectProperty op=(ObjectProperty)ope;
    Description child=description.getChild(0);
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    SortedSet<Individual> targetSet=getIndividualsImpl(child);
    SortedSet<Individual> returnSet=(SortedSet<Individual>)individuals.clone();
    int number=((ObjectCardinalityRestriction)description).getNumber();
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      SortedSet<Individual> inds=entry.getValue();
      if (number < inds.size()) {
        returnSet.add(entry.getKey());
        continue;
      }
      for (      Individual 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 ObjectValueRestriction) {
    Individual i=((ObjectValueRestriction)description).getIndividual();
    ObjectProperty op=(ObjectProperty)((ObjectValueRestriction)description).getRestrictedPropertyExpression();
    Map<Individual,SortedSet<Individual>> mapping=opPos.get(op);
    SortedSet<Individual> returnSet=new TreeSet<Individual>();
    for (    Entry<Individual,SortedSet<Individual>> entry : mapping.entrySet()) {
      if (entry.getValue().contains(i)) {
        returnSet.add(entry.getKey());
      }
    }
    return returnSet;
  }
 else   if (description instanceof BooleanValueRestriction) {
    DatatypeProperty dp=((BooleanValueRestriction)description).getRestrictedPropertyExpression();
    boolean value=((BooleanValueRestriction)description).getBooleanValue();
    if (value) {
      return (TreeSet<Individual>)bdPos.get(dp).clone();
    }
 else {
      return (TreeSet<Individual>)bdNeg.get(dp).clone();
    }
  }
 else   if (description instanceof DatatypeSomeRestriction) {
    DatatypeSomeRestriction dsr=(DatatypeSomeRestriction)description;
    DatatypeProperty dp=(DatatypeProperty)dsr.getRestrictedPropertyExpression();
    DataRange dr=dsr.getDataRange();
    Map<Individual,SortedSet<Double>> mapping=dd.get(dp);
    SortedSet<Individual> returnSet=new TreeSet<Individual>();
    if (dr instanceof DoubleMaxValue) {
      for (      Entry<Individual,SortedSet<Double>> entry : mapping.entrySet()) {
        if (entry.getValue().first() <= ((DoubleMaxValue)dr).getValue()) {
          returnSet.add(entry.getKey());
        }
      }
    }
 else     if (dr instanceof DoubleMinValue) {
      for (      Entry<Individual,SortedSet<Double>> entry : mapping.entrySet()) {
        if (entry.getValue().last() >= ((DoubleMinValue)dr).getValue()) {
          returnSet.add(entry.getKey());
        }
      }
    }
  }
  throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
}