Program: 9325
Project: 9325
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<>();
  }
 else   if (!description.isAnonymous()) {
    if (classInstancesPos.containsKey(description.asOWLClass())) {
      return (TreeSet<OWLIndividual>)classInstancesPos.get(description).clone();
    }
 else {
      return new TreeSet<>();
    }
  }
 else   if (description instanceof OWLObjectComplementOf) {
    OWLClassExpression operand=((OWLObjectComplementOf)description).getOperand();
    if (!operand.isAnonymous()) {
      if (isDefaultNegation()) {
        if (precomputeNegations) {
          return (TreeSet<OWLIndividual>)classInstancesNeg.get(operand).clone();
        }
        SetView<OWLIndividual> diff=Sets.difference(individuals,classInstancesPos.get(operand));
        return new TreeSet<>(diff);
      }
 else {
        return (TreeSet<OWLIndividual>)classInstancesNeg.get(operand).clone();
      }
    }
    return new TreeSet<>(Sets.difference(individuals,getIndividualsImpl(operand)));
  }
 else   if (description instanceof OWLObjectUnionOf) {
    SortedSet<OWLIndividual> ret=new TreeSet<>();
    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) {
    OWLObjectPropertyExpression property=((OWLObjectSomeValuesFrom)description).getProperty();
    OWLClassExpression filler=((OWLObjectSomeValuesFrom)description).getFiller();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=getTargetIndividuals(property);
    return mapping.entrySet().stream().filter(e -> e.getValue().stream().anyMatch(targetSet::contains)).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
  }
 else   if (description instanceof OWLObjectAllValuesFrom) {
    OWLObjectPropertyExpression property=((OWLObjectAllValuesFrom)description).getProperty();
    OWLClassExpression filler=((OWLObjectAllValuesFrom)description).getFiller();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=getTargetIndividuals(property);
    SortedSet<OWLIndividual> returnSet=(SortedSet<OWLIndividual>)individuals.clone();
    mapping.entrySet().stream().filter(e -> e.getValue().stream().anyMatch(ind -> !targetSet.contains(ind))).forEach(e -> returnSet.remove(e.getKey()));
    return returnSet;
  }
 else   if (description instanceof OWLObjectMinCardinality) {
    OWLObjectPropertyExpression property=((OWLObjectMinCardinality)description).getProperty();
    OWLClassExpression filler=((OWLObjectMinCardinality)description).getFiller();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=getTargetIndividuals(property);
    SortedSet<OWLIndividual> returnSet=new TreeSet<>();
    int number=((OWLObjectMinCardinality)description).getCardinality();
    for (    Entry<OWLIndividual,? extends Collection<OWLIndividual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      Collection<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();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=getTargetIndividuals(property);
    SortedSet<OWLIndividual> returnSet=(SortedSet<OWLIndividual>)individuals.clone();
    for (    Entry<OWLIndividual,? extends Collection<OWLIndividual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      Collection<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).getFiller();
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=property.isAnonymous() ? Multimaps.invertFrom(MapUtils.createSortedMultiMap(opPos.get(property.getNamedProperty())),TreeMultimap.create()).asMap() : opPos.get(property.getNamedProperty());
    return mapping.entrySet().stream().filter(e -> e.getValue().contains(value)).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
  }
 else   if (description instanceof OWLDataSomeValuesFrom) {
    OWLDataPropertyExpression property=((OWLDataSomeValuesFrom)description).getProperty();
    OWLDataRange filler=((OWLDataSomeValuesFrom)description).getFiller();
    if (filler.isDatatype()) {
      return new TreeSet<>(dpPos.get(property).keySet());
    }
 else     if (filler instanceof OWLDataIntersectionOf) {
      return ((OWLDataIntersectionOf)filler).getOperands().stream().map(dr -> getIndividuals(df.getOWLDataSomeValuesFrom(property,dr))).reduce((s1,s2) -> {
        s1.retainAll(s2);
        return s1;
      }
).orElse(new TreeSet<>());
    }
 else     if (filler instanceof OWLDataUnionOf) {
      return ((OWLDataUnionOf)filler).getOperands().stream().map(dr -> getIndividuals(df.getOWLDataSomeValuesFrom(property,dr))).reduce((s1,s2) -> {
        s1.addAll(s2);
        return s1;
      }
).orElse(new TreeSet<>());
    }
 else     if (filler instanceof OWLDataComplementOf) {
      return new TreeSet<>(Sets.difference(individuals,getIndividualsImpl(df.getOWLDataSomeValuesFrom(property,((OWLDataComplementOf)filler).getDataRange()))));
    }
 else     if (filler instanceof OWLDatatypeRestriction) {
      OWLDatatype datatype=((OWLDatatypeRestriction)filler).getDatatype();
      Set<OWLFacetRestriction> facetRestrictions=((OWLDatatypeRestriction)filler).getFacetRestrictions();
      if (OWLAPIUtils.floatDatatypes.contains(datatype)) {
        double min=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MIN_INCLUSIVE).map(fr -> fr.getFacetValue().isDouble() ? fr.getFacetValue().parseDouble() : (double)fr.getFacetValue().parseFloat()).findAny().orElse(-Double.MAX_VALUE);
        double max=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MAX_INCLUSIVE).map(fr -> fr.getFacetValue().isDouble() ? fr.getFacetValue().parseDouble() : (double)fr.getFacetValue().parseFloat()).findAny().orElse(Double.MAX_VALUE);
        return dd.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> {
          SortedSet<Double> values=e.getValue();
          if (values.last() < min || values.first() > max) {
            return false;
          }
          return values.stream().anyMatch(val -> val >= min && val <= max);
        }
).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
      }
 else       if (OWLAPIUtils.intDatatypes.contains(datatype)) {
        int min=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MIN_INCLUSIVE).map(fr -> fr.getFacetValue().parseInteger()).findAny().orElse(-Integer.MAX_VALUE);
        int max=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MAX_INCLUSIVE).map(fr -> fr.getFacetValue().parseInteger()).findAny().orElse(Integer.MAX_VALUE);
        return id.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> {
          SortedSet<Integer> values=e.getValue();
          if (values.last() < min || values.first() > max) {
            return false;
          }
          return values.stream().anyMatch(val -> val >= min && val <= max);
        }
).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
      }
 else       if (OWLAPIUtils.dtDatatypes.contains(datatype)) {
        OWLLiteral min=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MIN_INCLUSIVE).map(OWLFacetRestriction::getFacetValue).findAny().orElse(null);
        OWLLiteral max=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MAX_INCLUSIVE).map(OWLFacetRestriction::getFacetValue).findAny().orElse(null);
        return dpPos.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> e.getValue().stream().anyMatch(val -> OWLAPIUtils.inRange(val,min,max))).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
      }
    }
 else     if (filler.getDataRangeType() == DataRangeType.DATA_ONE_OF) {
      OWLDataOneOf dataOneOf=(OWLDataOneOf)filler;
      Set<OWLLiteral> values=dataOneOf.getValues();
      return dpPos.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> !Sets.intersection(e.getValue(),values).isEmpty()).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
    }
  }
 else   if (description instanceof OWLDataHasValue) {
    OWLDataPropertyExpression property=((OWLDataHasValue)description).getProperty();
    OWLLiteral value=((OWLDataHasValue)description).getFiller();
    return dpPos.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> e.getValue().contains(value)).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
  }
 else   if (description instanceof OWLObjectOneOf) {
    return new TreeSet(((OWLObjectOneOf)description).getIndividuals());
  }
  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<>();
  }
 else   if (!description.isAnonymous()) {
    if (classInstancesPos.containsKey(description.asOWLClass())) {
      return (TreeSet<OWLIndividual>)classInstancesPos.get(description).clone();
    }
 else {
      return new TreeSet<>();
    }
  }
 else   if (description instanceof OWLObjectComplementOf) {
    OWLClassExpression operand=((OWLObjectComplementOf)description).getOperand();
    if (!operand.isAnonymous()) {
      if (isDefaultNegation()) {
        if (precomputeNegations) {
          return (TreeSet<OWLIndividual>)classInstancesNeg.get(operand).clone();
        }
        SetView<OWLIndividual> diff=Sets.difference(individuals,classInstancesPos.get(operand));
        return new TreeSet<>(diff);
      }
 else {
        return (TreeSet<OWLIndividual>)classInstancesNeg.get(operand).clone();
      }
    }
    return new TreeSet<>(Sets.difference(individuals,getIndividualsImpl(operand)));
  }
 else   if (description instanceof OWLObjectUnionOf) {
    SortedSet<OWLIndividual> ret=new TreeSet<>();
    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) {
    OWLObjectPropertyExpression property=((OWLObjectSomeValuesFrom)description).getProperty();
    OWLClassExpression filler=((OWLObjectSomeValuesFrom)description).getFiller();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=getTargetIndividuals(property);
    return mapping.entrySet().stream().filter(e -> e.getValue().stream().anyMatch(targetSet::contains)).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
  }
 else   if (description instanceof OWLObjectAllValuesFrom) {
    OWLObjectPropertyExpression property=((OWLObjectAllValuesFrom)description).getProperty();
    OWLClassExpression filler=((OWLObjectAllValuesFrom)description).getFiller();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=getTargetIndividuals(property);
    SortedSet<OWLIndividual> returnSet=(SortedSet<OWLIndividual>)individuals.clone();
    mapping.entrySet().stream().filter(e -> e.getValue().stream().anyMatch(ind -> !targetSet.contains(ind))).forEach(e -> returnSet.remove(e.getKey()));
    return returnSet;
  }
 else   if (description instanceof OWLObjectMinCardinality) {
    OWLObjectPropertyExpression property=((OWLObjectMinCardinality)description).getProperty();
    OWLClassExpression filler=((OWLObjectMinCardinality)description).getFiller();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=getTargetIndividuals(property);
    SortedSet<OWLIndividual> returnSet=new TreeSet<>();
    int number=((OWLObjectMinCardinality)description).getCardinality();
    for (    Entry<OWLIndividual,? extends Collection<OWLIndividual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      Collection<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();
    SortedSet<OWLIndividual> targetSet=getIndividualsImpl(filler);
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=getTargetIndividuals(property);
    SortedSet<OWLIndividual> returnSet=(SortedSet<OWLIndividual>)individuals.clone();
    for (    Entry<OWLIndividual,? extends Collection<OWLIndividual>> entry : mapping.entrySet()) {
      int nrOfFillers=0;
      int index=0;
      Collection<OWLIndividual> fillers=entry.getValue();
      if (fillers.size() <= number) {
        continue;
      }
      for (      OWLIndividual ind : fillers) {
        if (nrOfFillers > number) {
          returnSet.remove(entry.getKey());
          break;
        }
        if (fillers.size() - index + nrOfFillers <= number) {
          break;
        }
        if (targetSet.contains(ind)) {
          nrOfFillers++;
        }
        index++;
      }
    }
    return returnSet;
  }
 else   if (description instanceof OWLObjectHasValue) {
    OWLObjectPropertyExpression property=((OWLObjectHasValue)description).getProperty();
    OWLIndividual value=((OWLObjectHasValue)description).getFiller();
    Map<OWLIndividual,? extends Collection<OWLIndividual>> mapping=property.isAnonymous() ? Multimaps.invertFrom(MapUtils.createSortedMultiMap(opPos.get(property.getNamedProperty())),TreeMultimap.create()).asMap() : opPos.get(property.getNamedProperty());
    return mapping.entrySet().stream().filter(e -> e.getValue().contains(value)).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
  }
 else   if (description instanceof OWLDataSomeValuesFrom) {
    OWLDataPropertyExpression property=((OWLDataSomeValuesFrom)description).getProperty();
    OWLDataRange filler=((OWLDataSomeValuesFrom)description).getFiller();
    if (filler.isDatatype()) {
      return new TreeSet<>(dpPos.get(property).keySet());
    }
 else     if (filler instanceof OWLDataIntersectionOf) {
      return ((OWLDataIntersectionOf)filler).getOperands().stream().map(dr -> getIndividuals(df.getOWLDataSomeValuesFrom(property,dr))).reduce((s1,s2) -> {
        s1.retainAll(s2);
        return s1;
      }
).orElse(new TreeSet<>());
    }
 else     if (filler instanceof OWLDataUnionOf) {
      return ((OWLDataUnionOf)filler).getOperands().stream().map(dr -> getIndividuals(df.getOWLDataSomeValuesFrom(property,dr))).reduce((s1,s2) -> {
        s1.addAll(s2);
        return s1;
      }
).orElse(new TreeSet<>());
    }
 else     if (filler instanceof OWLDataComplementOf) {
      return new TreeSet<>(Sets.difference(individuals,getIndividualsImpl(df.getOWLDataSomeValuesFrom(property,((OWLDataComplementOf)filler).getDataRange()))));
    }
 else     if (filler instanceof OWLDatatypeRestriction) {
      OWLDatatype datatype=((OWLDatatypeRestriction)filler).getDatatype();
      Set<OWLFacetRestriction> facetRestrictions=((OWLDatatypeRestriction)filler).getFacetRestrictions();
      if (OWLAPIUtils.floatDatatypes.contains(datatype)) {
        double min=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MIN_INCLUSIVE).map(fr -> fr.getFacetValue().isDouble() ? fr.getFacetValue().parseDouble() : (double)fr.getFacetValue().parseFloat()).findAny().orElse(-Double.MAX_VALUE);
        double max=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MAX_INCLUSIVE).map(fr -> fr.getFacetValue().isDouble() ? fr.getFacetValue().parseDouble() : (double)fr.getFacetValue().parseFloat()).findAny().orElse(Double.MAX_VALUE);
        return dd.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> {
          SortedSet<Double> values=e.getValue();
          if (values.last() < min || values.first() > max) {
            return false;
          }
          return values.stream().anyMatch(val -> val >= min && val <= max);
        }
).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
      }
 else       if (OWLAPIUtils.intDatatypes.contains(datatype)) {
        int min=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MIN_INCLUSIVE).map(fr -> fr.getFacetValue().parseInteger()).findAny().orElse(-Integer.MAX_VALUE);
        int max=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MAX_INCLUSIVE).map(fr -> fr.getFacetValue().parseInteger()).findAny().orElse(Integer.MAX_VALUE);
        return id.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> {
          SortedSet<Integer> values=e.getValue();
          if (values.last() < min || values.first() > max) {
            return false;
          }
          return values.stream().anyMatch(val -> val >= min && val <= max);
        }
).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
      }
 else       if (OWLAPIUtils.dtDatatypes.contains(datatype)) {
        OWLLiteral min=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MIN_INCLUSIVE).map(OWLFacetRestriction::getFacetValue).findAny().orElse(null);
        OWLLiteral max=facetRestrictions.stream().filter(fr -> fr.getFacet() == OWLFacet.MAX_INCLUSIVE).map(OWLFacetRestriction::getFacetValue).findAny().orElse(null);
        return dpPos.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> e.getValue().stream().anyMatch(val -> OWLAPIUtils.inRange(val,min,max))).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
      }
    }
 else     if (filler.getDataRangeType() == DataRangeType.DATA_ONE_OF) {
      OWLDataOneOf dataOneOf=(OWLDataOneOf)filler;
      Set<OWLLiteral> values=dataOneOf.getValues();
      return dpPos.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> !Sets.intersection(e.getValue(),values).isEmpty()).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
    }
  }
 else   if (description instanceof OWLDataHasValue) {
    OWLDataPropertyExpression property=((OWLDataHasValue)description).getProperty();
    OWLLiteral value=((OWLDataHasValue)description).getFiller();
    return dpPos.getOrDefault(property,new HashMap<>()).entrySet().stream().filter(e -> e.getValue().contains(value)).map(Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
  }
 else   if (description instanceof OWLObjectOneOf) {
    return new TreeSet(((OWLObjectOneOf)description).getIndividuals());
  }
  throw new ReasoningMethodUnsupportedException("String_Node_Str" + description + "String_Node_Str");
}