elk-reasoner/src/main/java/org/semanticweb/elk/reasoner/Reasoner.java
public synchronized Set<? extends Node<ElkNamedIndividual>> getInstances(
			ElkClassExpression classExpression, boolean direct)
			throws ElkInconsistentOntologyException, ElkException {

		if (classExpression instanceof ElkClass) {
			final TypeNode<ElkClass, ElkNamedIndividual> queryNode = getTypeNode(
					(ElkClass) classExpression);
			return direct ? queryNode.getDirectInstanceNodes()
					: queryNode.getAllInstanceNodes();
		}

		final Set<? extends Node<ElkNamedIndividual>> instances = queryDirectInstances(
				classExpression);
		if (direct) {
			return instances;
		}
		// else all instances

		final Set<? extends Node<ElkClass>> subNodes = queryDirectSubClasses(
				classExpression);
		final InstanceTaxonomy<ElkClass, ElkNamedIndividual> taxonomy = restoreInstanceTaxonomy();

		return TaxonomyNodeUtils.collectFromAllReachable(Operations.map(
				subNodes,
				new Operations.Transformation<Node<ElkClass>, TypeNode<ElkClass, ElkNamedIndividual>>() {

					@Override
					public TypeNode<ElkClass, ElkNamedIndividual> transform(
							final Node<ElkClass> node) {
						return taxonomy.getNode(node.getCanonicalMember());
					}

				}), Operations.map(instances,
						new Operations.Transformation<Node<ElkNamedIndividual>, InstanceNode<ElkClass, ElkNamedIndividual>>() {

							@Override
							public InstanceNode<ElkClass, ElkNamedIndividual> transform(
									final Node<ElkNamedIndividual> node) {
								return taxonomy.getInstanceNode(
										node.getCanonicalMember());
							}

						}),
				new Operations.Functor<TypeNode<ElkClass, ElkNamedIndividual>, Set<? extends TypeNode<ElkClass, ElkNamedIndividual>>>() {

					@Override
					public Set<? extends TypeNode<ElkClass, ElkNamedIndividual>> apply(
							final TypeNode<ElkClass, ElkNamedIndividual> node) {
						return node.getDirectSubNodes();
					}

				},
				new Operations.Functor<TypeNode<ElkClass, ElkNamedIndividual>, Set<? extends InstanceNode<ElkClass, ElkNamedIndividual>>>() {

					@Override
					public Set<? extends InstanceNode<ElkClass, ElkNamedIndividual>> apply(
							final TypeNode<ElkClass, ElkNamedIndividual> node) {
						return node.getDirectInstanceNodes();
					}

				});
	}
public synchronized Set<? extends Node<ElkNamedIndividual>> getInstances(
			ElkClassExpression classExpression, boolean direct)
			throws ElkInconsistentOntologyException, ElkException {

		if (classExpression instanceof ElkClass) {
			final TypeNode<ElkClass, ElkNamedIndividual> queryNode = getTypeNode(
					(ElkClass) classExpression);
			return direct ? queryNode.getDirectInstanceNodes()
					: queryNode.getAllInstanceNodes();
		}

		final Set<? extends Node<ElkNamedIndividual>> instances = queryDirectInstances(
				classExpression);
		if (direct) {
			return instances;
		}
		// else all instances

		final Set<? extends Node<ElkClass>> subNodes = queryDirectSubClasses(
				classExpression);
		final InstanceTaxonomy<ElkClass, ElkNamedIndividual> taxonomy = restoreInstanceTaxonomy();

		return TaxonomyNodeUtils.collectFromAllReachable(Operations.map(
				subNodes,
				new Operations.Transformation<Node<ElkClass>, TypeNode<ElkClass, ElkNamedIndividual>>() {

					@Override
					public TypeNode<ElkClass, ElkNamedIndividual> transform(
							final Node<ElkClass> node) {
						return taxonomy.getNode(node.getCanonicalMember());
					}

				}), Operations.map(instances,
						new Operations.Transformation<Node<ElkNamedIndividual>, InstanceNode<ElkClass, ElkNamedIndividual>>() {

							@Override
							public InstanceNode<ElkClass, ElkNamedIndividual> transform(
									final Node<ElkNamedIndividual> node) {
								return taxonomy.getInstanceNode(
										node.getCanonicalMember());
							}

						}),
				new Operations.Functor<TypeNode<ElkClass, ElkNamedIndividual>, Set<? extends TypeNode<ElkClass, ElkNamedIndividual>>>() {

					@Override
					public Set<? extends TypeNode<ElkClass, ElkNamedIndividual>> apply(
							final TypeNode<ElkClass, ElkNamedIndividual> node) {
						return node.getDirectSubNodes();
					}

				},
				new Operations.Functor<TypeNode<ElkClass, ElkNamedIndividual>, Set<? extends InstanceNode<ElkClass, ElkNamedIndividual>>>() {

					@Override
					public Set<? extends InstanceNode<ElkClass, ElkNamedIndividual>> apply(
							final TypeNode<ElkClass, ElkNamedIndividual> node) {
						return node.getDirectInstanceNodes();
					}

				});
	}
public synchronized Set < ? extends Node < ElkNamedIndividual > > getInstances ( ElkClassExpression classExpression , boolean direct ) throws ElkInconsistentOntologyException , ElkException { if ( classExpression instanceof ElkClass ) { final TypeNode < ElkClass , ElkNamedIndividual > queryNode = getTypeNode ( ( ElkClass ) classExpression ) ; return direct ? queryNode . getDirectInstanceNodes ( ) : queryNode . getAllInstanceNodes ( ) ; } final Set < ? extends Node < ElkNamedIndividual > > instances = queryDirectInstances ( classExpression ) ; if ( direct ) { return instances ; } // else all instances final Set < ? extends Node < ElkClass > > subNodes = queryDirectSubClasses ( classExpression ) ; final InstanceTaxonomy < ElkClass , ElkNamedIndividual > taxonomy = restoreInstanceTaxonomy ( ) ; return TaxonomyNodeUtils . collectFromAllReachable ( Operations . map ( subNodes , new Operations . Transformation < Node < ElkClass > , TypeNode < ElkClass , ElkNamedIndividual > > ( ) { @ Override public TypeNode < ElkClass , ElkNamedIndividual > transform ( final Node < ElkClass > node ) { return taxonomy . getNode ( node . getCanonicalMember ( ) ) ; } } ) , Operations . map ( instances , new Operations . Transformation < Node < ElkNamedIndividual > , InstanceNode < ElkClass , ElkNamedIndividual > > ( ) { @ Override public InstanceNode < ElkClass , ElkNamedIndividual > transform ( final Node < ElkNamedIndividual > node ) { return taxonomy . getInstanceNode ( node . getCanonicalMember ( ) ) ; } } ) , new Operations . Functor < TypeNode < ElkClass , ElkNamedIndividual > , Set < ? extends TypeNode < ElkClass , ElkNamedIndividual > > > ( ) { @ Override public Set < ? extends TypeNode < ElkClass , ElkNamedIndividual > > apply ( final TypeNode < ElkClass , ElkNamedIndividual > node ) { return node . getDirectSubNodes ( ) ; } } , new Operations . Functor < TypeNode < ElkClass , ElkNamedIndividual > , Set < ? extends InstanceNode < ElkClass , ElkNamedIndividual > > > ( ) { @ Override public Set < ? extends InstanceNode < ElkClass , ElkNamedIndividual > > apply ( final TypeNode < ElkClass , ElkNamedIndividual > node ) { return node . getDirectInstanceNodes ( ) ; } } ) ; }
Return the (direct or indirect) instances of the given
{@link ElkClassExpression} as specified by the parameter. The method
returns a set of {@link Node}s, each of which representing an equivalent
class of instances. Calling of this method may trigger the computation of
the realization, if it has not been done yet.

@param classExpression
the {@link ElkClassExpression} for which to return the
instances {@link Node}s
@param direct
if {@code true}, only direct instances are returned
@return the set of {@link Node}s for direct or indirect instances of the
given {@link ElkClassExpression} according to the specified
parameter
@throws ElkInconsistentOntologyException
if the ontology is inconsistent
@throws ElkException
if the result cannot be computed
Return the ( direct or indirect ) instances of the given { @link ElkClassExpression } as specified by the parameter . The method returns a set of { @link Node } s each of which representing an equivalent class of instances . Calling of this method may trigger the computation of the realization if it has not been done yet .