diff --git a/module-core/src/main/java/openllet/core/KnowledgeBaseImpl.java b/module-core/src/main/java/openllet/core/KnowledgeBaseImpl.java index b8c2bf64..7ab9b106 100644 --- a/module-core/src/main/java/openllet/core/KnowledgeBaseImpl.java +++ b/module-core/src/main/java/openllet/core/KnowledgeBaseImpl.java @@ -3060,7 +3060,7 @@ public boolean hasInstance(final ATerm d) unknowns.add(x); } - final boolean hasInstance = !unknowns.isEmpty() && _abox.isType(unknowns, c); + final boolean hasInstance = !unknowns.isEmpty() && _abox.existType(unknowns, c); return hasInstance; } @@ -4580,7 +4580,7 @@ public Set retrieve(final ATermAppl d, final Collection in if (OpenlletOptions.INSTANCE_RETRIEVAL == InstanceRetrievalMethod.TRACING_BASED && OpenlletOptions.USE_TRACING) tracingBasedInstanceRetrieval(c, unknowns, knowns); else - if (_abox.isType(unknowns, c)) + if (_abox.existType(unknowns, c)) if (OpenlletOptions.INSTANCE_RETRIEVAL == InstanceRetrievalMethod.BINARY) binaryInstanceRetrieval(c, unknowns, knowns); else @@ -4634,7 +4634,7 @@ public void tracingBasedInstanceRetrieval(final ATermAppl c, final List explanationSet = getExplanationSet(); @@ -4676,10 +4676,7 @@ public void binaryInstanceRetrieval(final ATermAppl c, final List can if (candidates.isEmpty()) return; else - { - final List[] partitions = partition(candidates); - partitionInstanceRetrieval(c, partitions, results); - } + partitionInstanceRetrieval(c, partition(candidates), results); } private void partitionInstanceRetrieval(final ATermAppl c, final List[] partitions, final Collection results) @@ -4693,10 +4690,10 @@ private void partitionInstanceRetrieval(final ATermAppl c, final List results.add(i); } else - if (!_abox.isType(partitions[0], c)) + if (!_abox.existType(partitions[0], c)) binaryInstanceRetrieval(c, partitions[1], results); else - if (!_abox.isType(partitions[1], c)) + if (!_abox.existType(partitions[1], c)) binaryInstanceRetrieval(c, partitions[0], results); else { @@ -4713,7 +4710,7 @@ private static List[] partition(final List candidates) if (n <= 1) { partitions[0] = candidates; - partitions[1] = new ArrayList<>(); + partitions[1] = Collections.emptyList(); } else { diff --git a/module-core/src/main/java/openllet/core/boxes/abox/ABox.java b/module-core/src/main/java/openllet/core/boxes/abox/ABox.java index 8b600521..e07bff36 100644 --- a/module-core/src/main/java/openllet/core/boxes/abox/ABox.java +++ b/module-core/src/main/java/openllet/core/boxes/abox/ABox.java @@ -118,7 +118,7 @@ public interface ABox extends Logging * @param inds * @return true if any of the individuals in the given list belongs to type c. */ - public boolean isType(final List inds, ATermAppl c); + public boolean existType(final List inds, ATermAppl c); public Bool hasObviousPropertyValue(final ATermAppl s, final ATermAppl p, final ATermAppl o); diff --git a/module-core/src/main/java/openllet/core/boxes/abox/ABoxImpl.java b/module-core/src/main/java/openllet/core/boxes/abox/ABoxImpl.java index aa2f5286..569ff425 100644 --- a/module-core/src/main/java/openllet/core/boxes/abox/ABoxImpl.java +++ b/module-core/src/main/java/openllet/core/boxes/abox/ABoxImpl.java @@ -885,7 +885,7 @@ public boolean isType(final ATermAppl x, final ATermAppl cParam) final Optional timer = _kb.getTimers().startTimer("isType"); final boolean isType = !isConsistent(SetUtils.singleton(x), notC, false); - timer.ifPresent(t -> t.stop()); + timer.ifPresent(Timer::stop); if (_logger.isLoggable(Level.FINE)) _logger.fine("Type " + isType + " " + ATermUtils.toString(c) + " for individual " + ATermUtils.toString(x)); @@ -894,7 +894,7 @@ public boolean isType(final ATermAppl x, final ATermAppl cParam) } @Override - public boolean isType(final List inds, final ATermAppl cParam) + public boolean existType(final List inds, final ATermAppl cParam) { final ATermAppl c = ATermUtils.normalize(cParam); @@ -1328,22 +1328,22 @@ private boolean checkAssertedClashes() } /** - * Check the consistency of this ABox possibly after adding some type assertions. If c is null then nothing is added to ABox (pure consistency - * test) and the individuals should be an empty collection. If c is not null but individuals is empty, this is a satisfiability - * check for concept c so a new individual will be added with type c. If individuals is not empty, this means we will add type - * c to each of the individuals in the collection and check the consistency. + * Check the consistency of this ABox possibly after adding some type assertions. If c_ is null then nothing is added to ABox (pure consistency + * test) and the individuals should be an empty collection. If c_ is not null but individuals is empty, this is a satisfiability + * check for concept c_ so a new individual will be added with type c_. If individuals is not empty, this means we will add type + * c_ to each of the individuals in the collection and check the consistency. *

* The consistency checks will be done either on a copy of the ABox or its pseudo model depending on the situation. In either case this ABox will not be - * modified at all. After the consistency check _lastCompletion points to the modified ABox. + * modified at all. After the consistency check lastCompletion points to the modified ABox. * * @param individuals - * @param cParam + * @param c_ * @return true if consistent. */ - private boolean isConsistent(final Collection individualsParam, final ATermAppl cParam, final boolean cacheModel) + private boolean isConsistent(final Collection individualsParam, final ATermAppl c_, final boolean cacheModel) { Collection individuals = individualsParam; - ATermAppl c = cParam; + ATermAppl c = c_; final Optional timer = _kb.getTimers().startTimer("isConsistent"); diff --git a/module-core/src/main/java/openllet/core/utils/Timers.java b/module-core/src/main/java/openllet/core/utils/Timers.java index f107567d..5ff5bf01 100644 --- a/module-core/src/main/java/openllet/core/utils/Timers.java +++ b/module-core/src/main/java/openllet/core/utils/Timers.java @@ -131,7 +131,7 @@ public RESULT execute(final String name, final Supplier produce } finally { - timer.ifPresent(t -> t.stop()); + timer.ifPresent(Timer::stop); } }