signature:
public class Operations { /** * Splits the input { @ link Iterable } on batches with at most given number of
 * elements .
 * @ param elements
 * the { @ link Iterable } to be split
 * @ param batchSize
 * the maximal number of elements in batches
 * @ return a { @ link Iterable } of batches containing elements from the input
 * collection
 * @ see # concat ( Iterable ) */
public static < T > Iterable < ArrayList < T > > split ( final Iterable < ? extends T > elements , final int batchSize ) { } }

implementation: return new Iterable < ArrayList < T > > ( ) { @ Override public Iterator < ArrayList < T > > iterator ( ) { return new Iterator < ArrayList < T > > ( ) { final Iterator < ? extends T > elementsIterator = elements . iterator ( ) ; @ Override public boolean hasNext ( ) { return elementsIterator . hasNext ( ) ; } @ Override public ArrayList < T > next ( ) { final ArrayList < T > nextBatch = new ArrayList < T > ( batchSize ) ; int count = 0 ; while ( count ++ < batchSize && elementsIterator . hasNext ( ) ) { nextBatch . add ( elementsIterator . next ( ) ) ; } return nextBatch ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( "Deletion is not supported" ) ; } } ; } } ;


signature:
public class Operations { /** * Splits the input { @ link Collection } on batches with at most given number
 * of elements .
 * @ param elements
 * the { @ link Collection } to be split
 * @ param batchSize
 * the maximal number of elements in batches
 * @ return a { @ link Collection } of batches containing elements from the
 * input collection */
public static < T > Collection < ArrayList < T > > split ( final Collection < ? extends T > elements , final int batchSize ) { } }

implementation:
return new AbstractCollection < ArrayList < T > > ( ) { @ Override public Iterator < ArrayList < T > > iterator ( ) { return split ( ( Iterable < ? extends T > ) elements , batchSize ) . iterator ( ) ; } @ Override public int size ( ) { // rounding up
return ( elements . size ( ) + batchSize - 1 ) / batchSize ; } } ;


signature:
public class Operations { /** * Returns read - only view of the given set consisting of the elements
 * satisfying a given condition , if the number of such elements is known
 * @ param input
 * the given set to be filtered
 * @ param condition
 * the condition used for filtering the set . Must be consistent
 * with equals ( ) for T , that is : a . equals ( b ) must imply that
 * holds ( a ) = = holds ( b )
 * @ param size
 * the number of elements in the filtered set
 * @ return the set consisting of the elements of the input set satisfying
 * the given condition */
public static < T > Set < T > filter ( final Set < ? extends T > input , final Condition < ? super T > condition , final int size ) { } }

implementation:
return new Set < T > ( ) { @ Override public int size ( ) { return size ; } @ Override public boolean isEmpty ( ) { return size == 0 ; } @ Override @ SuppressWarnings ( "unchecked" ) public boolean contains ( Object o ) { if ( ! input . contains ( o ) ) return false ; T elem = null ; try { elem = ( T ) o ; } catch ( ClassCastException cce ) { return false ; } /* * here ' s why the condition must be consistent with equals ( ) : we
 * check it on the passed element while we really need to check
 * it on the element which is in the underlying set ( and is
 * equal to o according to equals ( ) ) . However , as long as the
 * condition is consistent , the result will be the same . */
return condition . holds ( elem ) ; } @ Override public Iterator < T > iterator ( ) { return filter ( input , condition ) . iterator ( ) ; } @ Override public Object [ ] toArray ( ) { Object [ ] result = new Object [ size ] ; int i = 0 ; for ( Object o : filter ( input , condition ) ) { result [ i ++ ] = o ; } return result ; } @ Override public < S > S [ ] toArray ( S [ ] a ) { throw new UnsupportedOperationException ( ) ; } @ Override public boolean add ( T e ) { throw new UnsupportedOperationException ( ) ; } @ Override public boolean remove ( Object o ) { throw new UnsupportedOperationException ( ) ; } @ Override public boolean containsAll ( Collection < ? > c ) { for ( Object o : c ) { if ( contains ( o ) ) return false ; } return true ; } @ Override public boolean addAll ( Collection < ? extends T > c ) { throw new UnsupportedOperationException ( ) ; } @ Override public boolean retainAll ( Collection < ? > c ) { throw new UnsupportedOperationException ( ) ; } @ Override public boolean removeAll ( Collection < ? > c ) { throw new UnsupportedOperationException ( ) ; } @ Override public void clear ( ) { throw new UnsupportedOperationException ( ) ; } } ;


signature:
public class Operations { /** * Prints key - value entries present in the first { @ link Multimap } but not in
 * the second { @ link Multimap } using the given { @ link Writer } and prefixing
 * all messages with a given prefix .
 * @ param first
 * @ param second
 * @ param writer
 * @ param prefix
 * @ throws IOException */
public static < K , V > void dumpDiff ( Multimap < K , V > first , Multimap < K , V > second , Writer writer , String prefix ) throws IOException { } }

implementation: for ( K key : first . keySet ( ) ) { Collection < V > firstValues = first . get ( key ) ; Collection < V > secondValues = second . get ( key ) ; dumpDiff ( firstValues , secondValues , writer , prefix + key + "->" ) ; }


signature:
public class Operations { /** * Prints the elements present in the first { @ link Collection } but not in
 * the second { @ link Collection } using the given { @ link Writer } and
 * prefixing all messages with a given prefix .
 * @ param first
 * @ param second
 * @ param writer
 * @ param prefix
 * @ throws IOException */
public static < T > void dumpDiff ( Collection < T > first , Collection < T > second , Writer writer , String prefix ) throws IOException { } }

implementation: for ( T element : first ) if ( ! second . contains ( element ) ) writer . append ( prefix + element + "\n" ) ;


signature:
public class Operations { /** * A simple second - order map function for sets
 * @ param input
 * @ param functor
 * @ return a set which contains the results of applying the functor to the
 * elements in the input set */
public static < I , O > Set < O > map ( final Set < ? extends I > input , final FunctorEx < I , O > functor ) { } }

implementation: return new AbstractSet < O > ( ) { @ Override public Iterator < O > iterator ( ) { return new MapIterator < I , O > ( input . iterator ( ) , functor ) ; } @ Override public boolean contains ( Object o ) { I element = functor . deapply ( o ) ; return element == null ? false : input . contains ( element ) ; } @ Override public int size ( ) { return input . size ( ) ; } } ;


signature:
public class ArraySlicedSet { /** * Returns the bit fragment that encodes the membership of an element for
 * the given position in slices . The returned fragment is an integer whose
 * lower bits correspond to whether an element occurs in the slice or not
 * ( the lowest bit corresponds to the membership in slice = 0 , next bit in
 * slice = 1 , etc )
 * @ param sl
 * the logarithm of the number of slices
 * @ param masks
 * the table storing all masks encoding the membership of
 * elements in slices
 * @ param pos
 * the position of an element in the table for which the fragment
 * should be returned
 * @ return the integer whose bits encode membership of the element at the
 * given position in slices */
static int getFragment ( byte sl , int [ ] masks , int pos ) { } }

implementation:
/* * one element of the masks table stores fragments for 32 / ( 2 ^ sl )
 * elements ; since it is a power of 2 , we can divide on this value and
 * compute the remainder efficiently */
int shift = ( 5 - sl ) ; int p = pos >> shift ; // = pos / ( 32 / ( 2 ^ sl ) )
int r = ( p << shift ) ^ pos ; // the remainder after the devision
// extract the r - th fragment of the length 2 ^ sl
return ( masks [ p ] >> ( r << sl ) ) & MSK_ [ sl ] ;


signature:
public class ArraySlicedSet { /** * Changes the fragment that corresponds to the encoding of membership of an
 * element at the given position . The change is specified by the bits of the
 * last parameter : bit 1 means the corresponding value of the fragment
 * should flip , bit 0 means it should stay the same .
 * @ param sl
 * the logarithm of the number of slices
 * @ param masks
 * the table storing all masks encoding the membership of
 * elements in slices
 * @ param pos
 * the position of an element in the table for which the fragment
 * should be changed
 * @ param diff
 * the sequence of bits that describes the change ; the new
 * fragment is obtained by applying bitwise XOR operation */
static void changeFragment ( byte sl , int [ ] masks , int pos , int diff ) { } }

implementation: int shift = ( 5 - sl ) ; int p = pos >> shift ; int r = ( p << shift ) ^ pos ; masks [ p ] ^= diff << ( r << sl ) ;


signature:
public class ArraySlicedSet { /** * Increasing the capacity of the table */
private void enlarge ( ) { } }

implementation: int oldCapacity = data . length ; if ( oldCapacity == LinearProbing . MAXIMUM_CAPACITY ) throw new IllegalArgumentException ( "The set cannot grow beyond the capacity: " + LinearProbing . MAXIMUM_CAPACITY ) ; E [ ] oldData = data ; int [ ] oldMasks = masks ; int newCapacity = oldCapacity << 1 ; @ SuppressWarnings ( "unchecked" ) E [ ] newData = ( E [ ] ) new Object [ newCapacity ] ; int [ ] newMasks = new int [ getMaskCapacity ( logs , newCapacity ) ] ; for ( int i = 0 ; i < oldCapacity ; i ++ ) { E e = oldData [ i ] ; if ( e != null ) addMask ( logs , newData , newMasks , e , getFragment ( logs , oldMasks , i ) ) ; } this . data = newData ; this . masks = newMasks ;


signature:
public class ArraySlicedSet { /** * Decreasing the capacity of the table */
private void shrink ( ) { } }

implementation: int oldCapacity = data . length ; if ( oldCapacity == 1 ) return ; E [ ] oldData = data ; int [ ] oldMasks = masks ; int newCapacity = oldCapacity >> 1 ; @ SuppressWarnings ( "unchecked" ) E [ ] newData = ( E [ ] ) new Object [ newCapacity ] ; int [ ] newMasks = new int [ getMaskCapacity ( logs , newCapacity ) ] ; for ( int i = 0 ; i < oldCapacity ; i ++ ) { E e = oldData [ i ] ; if ( e != null ) addMask ( logs , newData , newMasks , e , getFragment ( logs , oldMasks , i ) ) ; } this . data = newData ; this . masks = newMasks ;


signature:
public class ArraySlicedSet { /** * Inserts a given element into the given slice
 * @ param s
 * the slice id
 * @ param e
 * the elements to be inserted in to the given slice
 * @ return { @ code true } if the given element did not occur in the given
 * slice and thus was inserted . Otherwise { @ code false } is returned
 * and nothing is modified . */
public boolean add ( int s , E e ) { } }

implementation: if ( e == null ) throw new NullPointerException ( ) ; int mask = ( 1 << s ) ; int oldMask = addMask ( logs , data , masks , e , mask ) ; int newMask = oldMask | mask ; if ( newMask == oldMask ) return false ; else if ( oldMask == 0 && ++ occupied == LinearProbing . getUpperSize ( data . length ) ) enlarge ( ) ; sizes [ s ] ++ ; return true ;


signature:
public class ArraySlicedSet { /** * Removes the given object from the given slice
 * @ param s
 * the slice id
 * @ param o
 * the object that should be removed from the given slice
 * @ return { @ code true } if the given object is equal to some element of the
 * given slice ; this element will be removed from the slice . If
 * there is no such an object , { @ code false } is returned and nothing
 * is modified */
public boolean remove ( int s , Object o ) { } }

implementation:
if ( o == null ) throw new NullPointerException ( ) ; int mask = 1 << s ; int oldMask = removeMask ( logs , data , masks , o , mask ) ; int newMask = oldMask & ~ mask ; if ( newMask == oldMask ) return false ; // else
if ( newMask == 0 && -- occupied == LinearProbing . getLowerSize ( data . length ) ) shrink ( ) ; sizes [ s ] -- ; return true ;


signature:
public class ArraySlicedSet { /** * Clears all slices of this { @ link ArraySlicedSet } . After calling this
 * methods , all slices are empty . */
@ SuppressWarnings ( "unchecked" ) public void clear ( ) { } }

implementation: int capacity = data . length >> 2 ; if ( capacity == 0 ) capacity = 1 ; initSizes ( ) ; this . data = ( E [ ] ) new Object [ capacity ] ; this . masks = new int [ getMaskCapacity ( logs , capacity ) ] ;


signature:
public class InferenceMatchVisitor { /** * Generates inferences for SubClassInclusion ( extendedRootMatchExpression
 * rootMatchExpression ) where the arguments correspond to the values of
 * respectively extendedRootMatch and rootMatch under
 * { @ link # toElkExpression ( IndexedContextRootMatch ) }
 * @ param extendedRootMatch
 * must be an extension of rootMatch ( i . e . , obtained by sequence
 * of calls
 * { @ link IndexedContextRootMatch # extend ( ElkClassExpression ) }
 * @ param rootMatch */
private void deriveInclusion ( IndexedContextRootMatch extendedRootMatch , IndexedContextRootMatch rootMatch ) { } }

implementation:
if ( rootMatch . equals ( extendedRootMatch ) ) { // nothing to do
return ; } List < ? extends ElkClassExpression > rootFillers = getFillerRanges ( rootMatch ) ; List < ? extends ElkClassExpression > extendedRootFillers = getFillerRanges ( extendedRootMatch ) ; int rootFillersCount = rootFillers . size ( ) ; if ( rootFillersCount == 1 ) { elkInferenceFactory_ . getElkClassInclusionObjectIntersectionOfDecomposition ( extendedRootFillers , 0 ) ; } else { List < Integer > positions = new ArrayList < Integer > ( rootFillersCount ) ; for ( int i = 0 ; i < rootFillersCount ; i ++ ) { positions . add ( i ) ; } elkInferenceFactory_ . getElkClassInclusionObjectIntersectionOfInclusion ( extendedRootFillers , positions ) ; }


signature:
public class ClassConclusionCounter { /** * Adds all counters of the argument to the corresponding counters of this
 * object . The counters should not be directly modified other than using
 * this method during this operation . The counter in the argument will be
 * reseted after this operation .
 * @ param counter
 * the object which counters should be added */
public synchronized void add ( ClassConclusionCounter counter ) { } }

implementation: this . countSubClassInclusionDecomposed += counter . countSubClassInclusionDecomposed ; this . countSubClassInclusionComposed += counter . countSubClassInclusionComposed ; this . countBackwardLink += counter . countBackwardLink ; this . countForwardLink += counter . countForwardLink ; this . countContradiction += counter . countContradiction ; this . countPropagation += counter . countPropagation ; this . countDisjointSubsumer += counter . countDisjointSubsumer ; this . countContextInitialization += counter . countContextInitialization ; this . countSubContextInitialization += counter . countSubContextInitialization ;


signature:
public class Statistics { /** * Log the start of a particular operation with INFO priority . This method
 * should be used for long - running tasks and is mainly intended . Multiple
 * threads can independently log operations of the same name , but
 * ( obviously ) no single thread should use the same operation name to record
 * the start and end of overlapping code .
 * @ param operationName
 * @ param logger */
public static void logOperationStart ( String operationName , Logger logger ) { } }

implementation: logOperationStart ( operationName , logger , LogLevel . INFO ) ;


signature:
public class Statistics { /** * Log the start of a particular operation with the given priority . This
 * method should be used for long - running tasks and is mainly intended .
 * Multiple threads can independently log operations of the same name , but
 * ( obviously ) no single thread should use the same operation name to record
 * the start and end of overlapping code .
 * @ param operationName
 * @ param logger
 * @ param priority */
public static void logOperationStart ( String operationName , Logger logger , LogLevel priority ) { } }

implementation:
if ( LoggerWrap . isEnabledFor ( logger , priority ) ) { LoggerWrap . log ( logger , priority , operationName + " started" ) ; ElkTimer timer = ElkTimer . getNamedTimer ( operationName , ElkTimer . RECORD_WALLTIME ) ; timer . reset ( ) ; // needed in case this was done before
timer . start ( ) ; }


signature:
public class Statistics { /** * Log the end of a particular operation the beginning of which has been
 * logged using logOperationStart ( ) , using INFO priority .
 * @ param operationName
 * @ param logger */
public static void logOperationFinish ( String operationName , Logger logger ) { } }

implementation: logOperationFinish ( operationName , logger , LogLevel . INFO ) ;


signature:
public class Statistics { /** * Log the end of a particular operation the beginning of which has been
 * logged using logOperationStart ( ) , using the given logging priority .
 * @ param operationName
 * @ param logger
 * @ param priority */
public static void logOperationFinish ( String operationName , Logger logger , LogLevel priority ) { } }

implementation: if ( LoggerWrap . isEnabledFor ( logger , priority ) ) { ElkTimer timer = ElkTimer . getNamedTimer ( operationName , ElkTimer . RECORD_WALLTIME ) ; timer . stop ( ) ; LoggerWrap . log ( logger , priority , operationName + " took " + timer . getTotalWallTime ( ) / 1000000 + " ms" ) ; }


signature:
public class Statistics { /** * Log the current total memory usage with the specified priority .
 * @ param logger
 * @ param priority */
public static void logMemoryUsage ( Logger logger , LogLevel priority ) { } }

implementation:
if ( LoggerWrap . isEnabledFor ( logger , priority ) ) { // Getting the runtime reference from system
Runtime runtime = Runtime . getRuntime ( ) ; LoggerWrap . log ( logger , priority , "Memory (MB) Used/Total/Max: " + ( runtime . totalMemory ( ) - runtime . freeMemory ( ) ) / megaBytes + "/" + runtime . totalMemory ( ) / megaBytes + "/" + runtime . maxMemory ( ) / megaBytes ) ; }


signature:
public class Reasoner { /** * This supposed to be the central place where the reasoner gets its
 * configuration options
 * @ param config */
public synchronized void setConfigurationOptions ( ReasonerConfiguration config ) { } }

implementation: this . workerNo_ = config . getParameterAsInt ( ReasonerConfiguration . NUM_OF_WORKING_THREADS ) ; setAllowIncrementalMode ( config . getParameterAsBoolean ( ReasonerConfiguration . INCREMENTAL_MODE_ALLOWED ) ) ;


signature:
public class Reasoner { /** * Tries to shut down the reasoner within the specified time
 * @ param timeout
 * the maximum time to wait
 * @ param unit
 * the time unit of the timeout argument
 * @ return { @ code true } if the operation was successful
 * @ throws InterruptedException
 * if the current thread was interrupted */
public synchronized boolean shutdown ( long timeout , TimeUnit unit ) throws InterruptedException { } }

implementation: boolean success = true ; if ( success ) { LOGGER_ . info ( "ELK reasoner has shut down" ) ; } else { LOGGER_ . error ( "ELK reasoner failed to shut down!" ) ; } return success ;


signature:
public class Reasoner { /** * Helper method to get a { @ link TaxonomyNode } from the taxonomy .
 * @ param elkClass
 * an { @ link ElkClass } for which to find a { @ link TaxonomyNode }
 * @ return the { @ link TaxonomyNode } for the given { @ link ElkClass } */
protected TaxonomyNode < ElkClass > getTaxonomyNode ( ElkClass elkClass ) throws ElkException { } }

implementation:
final Taxonomy < ElkClass > taxonomy = getTaxonomy ( ) ; final TaxonomyNode < ElkClass > node = taxonomy . getNode ( elkClass ) ; if ( node != null ) return node ; // else
if ( allowFreshEntities ) return new FreshTaxonomyNode < ElkClass > ( elkClass , taxonomy ) ; // else
throw new ElkFreshEntitiesException ( elkClass ) ;


signature:
public class Reasoner { /** * Helper method to get an { @ link InstanceNode } from the taxonomy .
 * @ param elkNamedIndividual
 * @ return the { @ link InstanceNode } for the given { @ link ElkNamedIndividual }
 * @ throws ElkException
 * if the result cannot be computed */
protected InstanceNode < ElkClass , ElkNamedIndividual > getInstanceNode ( ElkNamedIndividual elkNamedIndividual ) throws ElkException { } }

implementation:
final InstanceTaxonomy < ElkClass , ElkNamedIndividual > instanceTaxonomy = getInstanceTaxonomy ( ) ; final InstanceNode < ElkClass , ElkNamedIndividual > node = instanceTaxonomy . getInstanceNode ( elkNamedIndividual ) ; if ( node != null ) return node ; // else
if ( allowFreshEntities ) return new FreshInstanceNode < ElkClass , ElkNamedIndividual > ( elkNamedIndividual , instanceTaxonomy ) ; // else
throw new ElkFreshEntitiesException ( elkNamedIndividual ) ;


signature:
public class Reasoner { /** * Helper method to get a { @ link TypeNode } from the taxonomy .
 * @ param elkClass
 * @ return the { @ link TypeNode } for the given { @ link ElkClass }
 * @ throws ElkException
 * if the result cannot be computed */
protected TypeNode < ElkClass , ElkNamedIndividual > getTypeNode ( ElkClass elkClass ) throws ElkException { } }

implementation:
final InstanceTaxonomy < ElkClass , ElkNamedIndividual > instanceTaxonomy = getInstanceTaxonomy ( ) ; final TypeNode < ElkClass , ElkNamedIndividual > node = instanceTaxonomy . getNode ( elkClass ) ; if ( node != null ) return node ; // else
if ( allowFreshEntities ) return new FreshTypeNode < ElkClass , ElkNamedIndividual > ( elkClass , instanceTaxonomy ) ; // else
throw new ElkFreshEntitiesException ( elkClass ) ;


signature:
public class Reasoner { /** * Helper method to get a { @ link TaxonomyNode } from the property taxonomy .
 * @ param elkProperty
 * an { @ link ElkObjectProperty } for which to find a
 * { @ link TaxonomyNode }
 * @ return the { @ link TaxonomyNode } for the given { @ link ElkObjectProperty } */
protected TaxonomyNode < ElkObjectProperty > getObjectPropertyTaxonomyNode ( final ElkObjectProperty elkProperty ) throws ElkException { } }

implementation:
final Taxonomy < ElkObjectProperty > propertyTaxonomy = getObjectPropertyTaxonomy ( ) ; final TaxonomyNode < ElkObjectProperty > node = propertyTaxonomy . getNode ( elkProperty ) ; if ( node != null ) { return node ; } // else
if ( allowFreshEntities ) { return new FreshTaxonomyNode < ElkObjectProperty > ( elkProperty , propertyTaxonomy ) ; } // else
throw new ElkFreshEntitiesException ( elkProperty ) ;


signature:
public class Reasoner { /** * Return the { @ code Node } containing equivalent classes of the given
 * { @ link ElkClassExpression } . Calling of this method may trigger the
 * computation of the taxonomy , if it has not been done yet .
 * @ param classExpression
 * the { @ link ElkClassExpression } for which to return the
 * { @ link Node }
 * @ return the set of { @ link Node } whose members are { @ link ElkClass } es
 * equivalent to the given { @ link ElkClassExpression }
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the result cannot be computed */
public synchronized Node < ElkClass > getEquivalentClasses ( ElkClassExpression classExpression ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
if ( classExpression instanceof ElkClass ) { return getTaxonomyNode ( ( ElkClass ) classExpression ) ; } // else
return queryEquivalentClasses ( classExpression ) ;


signature:
public class Reasoner { /** * Return the { @ code Node } containing equivalent classes of the given
 * { @ link ElkClassExpression } . Calling of this method may trigger the
 * computation of the taxonomy , if it has not been done yet .
 * @ param classExpression
 * the { @ link ElkClassExpression } for which to return the
 * { @ link Node }
 * @ return the set of { @ link Node } whose members are { @ link ElkClass } es
 * equivalent to the given { @ link ElkClassExpression }
 * @ throws ElkException
 * if the result cannot be computed */
public synchronized Node < ElkClass > getEquivalentClassesQuietly ( ElkClassExpression classExpression ) throws ElkException { } }

implementation:
try { return getEquivalentClasses ( classExpression ) ; } catch ( final ElkInconsistentOntologyException e ) { // All classes are equivalent to each other , so also to owl : Nothing .
return getTaxonomyQuietly ( ) . getBottomNode ( ) ; }


signature:
public class Reasoner { /** * Return the ( direct or indirect ) subclasses 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 subclasses . Calling of this method may trigger the computation
 * of the taxonomy , if it has not been done yet .
 * @ param classExpression
 * the { @ link ElkClassExpression } for which to return the
 * subclass { @ link Node } s
 * @ param direct
 * if { @ code true } , only direct subclasses should be returned
 * @ return the set of { @ link Node } s for direct or indirect subclasses 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 */
public synchronized Set < ? extends Node < ElkClass > > getSubClasses ( ElkClassExpression classExpression , boolean direct ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
if ( classExpression instanceof ElkClass ) { final TaxonomyNode < ElkClass > queryNode = getTaxonomyNode ( ( ElkClass ) classExpression ) ; return direct ? queryNode . getDirectSubNodes ( ) : queryNode . getAllSubNodes ( ) ; } else { final Set < ? extends Node < ElkClass > > subNodes = queryDirectSubClasses ( classExpression ) ; if ( direct ) { return subNodes ; } // else all nodes
final Taxonomy < ElkClass > taxonomy = restoreTaxonomy ( ) ; return TaxonomyNodeUtils . getAllReachable ( Operations . map ( subNodes , new Operations . Transformation < Node < ElkClass > , TaxonomyNode < ElkClass > > ( ) { @ Override public TaxonomyNode < ElkClass > transform ( final Node < ElkClass > node ) { return taxonomy . getNode ( node . getCanonicalMember ( ) ) ; } } ) , new Operations . Functor < TaxonomyNode < ElkClass > , Set < ? extends TaxonomyNode < ElkClass > > > ( ) { @ Override public Set < ? extends TaxonomyNode < ElkClass > > apply ( final TaxonomyNode < ElkClass > node ) { return node . getDirectSubNodes ( ) ; } } ) ; }


signature:
public class Reasoner { /** * Return the ( direct or indirect ) subclasses 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 subclasses . Calling of this method may trigger the computation
 * of the taxonomy , if it has not been done yet .
 * @ param classExpression
 * the { @ link ElkClassExpression } for which to return the
 * subclass { @ link Node } s
 * @ param direct
 * if { @ code true } , only direct subclasses should be returned
 * @ return the set of { @ link Node } s for direct or indirect subclasses of the
 * given { @ link ElkClassExpression } according to the specified
 * parameter
 * @ throws ElkException
 * if the result cannot be computed */
public synchronized Set < ? extends Node < ElkClass > > getSubClassesQuietly ( final ElkClassExpression classExpression , final boolean direct ) throws ElkException { } }

implementation:
try { return getSubClasses ( classExpression , direct ) ; } catch ( final ElkInconsistentOntologyException e ) { // All classes are equivalent to each other , so also to owl : Nothing .
final TaxonomyNode < ElkClass > node = getTaxonomyQuietly ( ) . getBottomNode ( ) ; return direct ? node . getDirectSubNodes ( ) : node . getAllSubNodes ( ) ; }


signature:
public class Reasoner { /** * Return the ( direct or indirect ) superclasses 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 superclasses . Calling of this method may trigger the computation
 * of the taxonomy , if it has not been done yet .
 * @ param classExpression
 * the { @ link ElkClassExpression } for which to return the
 * superclass { @ link Node } s
 * @ param direct
 * if { @ code true } , only direct superclasses are returned
 * @ return the set of { @ link Node } s for direct or indirect superclasses 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 */
public synchronized Set < ? extends Node < ElkClass > > getSuperClasses ( ElkClassExpression classExpression , boolean direct ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
if ( classExpression instanceof ElkClass ) { final TaxonomyNode < ElkClass > queryNode = getTaxonomyNode ( ( ElkClass ) classExpression ) ; return direct ? queryNode . getDirectSuperNodes ( ) : queryNode . getAllSuperNodes ( ) ; } else { final Set < ? extends Node < ElkClass > > superNodes = queryDirectSuperClasses ( classExpression ) ; if ( direct ) { return superNodes ; } // else all nodes
final Taxonomy < ElkClass > taxonomy = restoreTaxonomy ( ) ; return TaxonomyNodeUtils . getAllReachable ( Operations . map ( superNodes , new Operations . Transformation < Node < ElkClass > , TaxonomyNode < ElkClass > > ( ) { @ Override public TaxonomyNode < ElkClass > transform ( final Node < ElkClass > node ) { return taxonomy . getNode ( node . getCanonicalMember ( ) ) ; } } ) , new Operations . Functor < TaxonomyNode < ElkClass > , Set < ? extends TaxonomyNode < ElkClass > > > ( ) { @ Override public Set < ? extends TaxonomyNode < ElkClass > > apply ( final TaxonomyNode < ElkClass > node ) { return node . getDirectSuperNodes ( ) ; } } ) ; }


signature:
public class Reasoner { /** * Return the ( direct or indirect ) superclasses 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 superclasses . Calling of this method may trigger the computation
 * of the taxonomy , if it has not been done yet .
 * @ param classExpression
 * the { @ link ElkClassExpression } for which to return the
 * superclass { @ link Node } s
 * @ param direct
 * if { @ code true } , only direct superclasses are returned
 * @ return the set of { @ link Node } s for direct or indirect superclasses of
 * the given { @ link ElkClassExpression } according to the specified
 * parameter
 * @ throws ElkException
 * if the result cannot be computed */
public synchronized Set < ? extends Node < ElkClass > > getSuperClassesQuietly ( ElkClassExpression classExpression , boolean direct ) throws ElkException { } }

implementation:
try { return getSuperClasses ( classExpression , direct ) ; } catch ( final ElkInconsistentOntologyException e ) { // All classes are equivalent to each other , so also to owl : Nothing .
final TaxonomyNode < ElkClass > node = getTaxonomyQuietly ( ) . getBottomNode ( ) ; return direct ? node . getDirectSuperNodes ( ) : node . getAllSuperNodes ( ) ; }


signature:
public class Reasoner { /** * Return the ( direct or indirect ) sub - properties of the given
 * { @ link ElkObjectProperty } as specified by the parameter . The method
 * returns a set of { @ link Node } s , each of which representing an equivalence
 * class of sub - properties . Calling of this method may trigger the
 * computation of the taxonomy , if it has not been done yet .
 * @ param property
 * the { @ link ElkObjectProperty } for which to return the
 * sub - property { @ link Node } s
 * @ param direct
 * if { @ code true } , only direct sub - properties should be returned
 * @ return the set of { @ link Node } s for direct or indirect sub - properties of
 * the given { @ link ElkObjectProperty } according to the specified
 * parameter
 * @ throws ElkException
 * if the result cannot be computed */
public synchronized Set < ? extends Node < ElkObjectProperty > > getSubObjectProperties ( final ElkObjectProperty property , final boolean direct ) throws ElkException { } }

implementation: final TaxonomyNode < ElkObjectProperty > queryNode = getObjectPropertyNode ( property ) ; return ( direct ) ? queryNode . getDirectSubNodes ( ) : queryNode . getAllSubNodes ( ) ;


signature:
public class Reasoner { /** * Return the ( direct or indirect ) super - properties of the given
 * { @ link ElkObjectProperty } as specified by the parameter . The method
 * returns a set of { @ link Node } s , each of which representing an equivalence
 * class of super - properties . Calling of this method may trigger the
 * computation of the taxonomy , if it has not been done yet .
 * @ param property
 * the { @ link ElkObjectProperty } for which to return the
 * super - property { @ link Node } s
 * @ param direct
 * if { @ code true } , only direct super - properties are returned
 * @ return the set of { @ link Node } s for direct or indirect super - properties
 * of the given { @ link ElkObjectProperty } according to the specified
 * parameter
 * @ throws ElkException
 * if the result cannot be computed */
public synchronized Set < ? extends Node < ElkObjectProperty > > getSuperObjectProperties ( final ElkObjectProperty property , final boolean direct ) throws ElkException { } }

implementation: TaxonomyNode < ElkObjectProperty > queryNode = getObjectPropertyNode ( property ) ; return ( direct ) ? queryNode . getDirectSuperNodes ( ) : queryNode . getAllSuperNodes ( ) ;


signature:
public class Reasoner { /** * 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 */
public synchronized Set < ? extends Node < ElkNamedIndividual > > getInstances ( ElkClassExpression classExpression , boolean direct ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
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 ( ) ; } } ) ;


signature:
public class Reasoner { /** * 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 ElkException
 * if the result cannot be computed */
public synchronized Set < ? extends Node < ElkNamedIndividual > > getInstancesQuietly ( ElkClassExpression classExpression , boolean direct ) throws ElkException { } }

implementation:
try { return getInstances ( classExpression , direct ) ; } catch ( final ElkInconsistentOntologyException e ) { // All classes are equivalent to each other , so also to owl : Nothing .
final TypeNode < ElkClass , ElkNamedIndividual > node = getInstanceTaxonomyQuietly ( ) . getBottomNode ( ) ; return direct ? node . getDirectInstanceNodes ( ) : node . getAllInstanceNodes ( ) ; }


signature:
public class Reasoner { /** * Return the ( direct or indirect ) types of the given
 * { @ link ElkNamedIndividual } . The method returns a set of { @ link Node } s ,
 * each of which representing an equivalent class of types . Calling of this
 * method may trigger the computation of the realization , if it has not been
 * done yet .
 * @ param elkNamedIndividual
 * the { @ link ElkNamedIndividual } for which to return the types
 * { @ link Node } s
 * @ param direct
 * if { @ code true } , only direct types are returned
 * @ return the set of { @ link Node } s for the direct or indirect types of the
 * given { @ link ElkNamedIndividual } according to the specified
 * parameter
 * @ throws ElkException
 * if the result cannot be computed */
public synchronized Set < ? extends Node < ElkClass > > getTypes ( ElkNamedIndividual elkNamedIndividual , boolean direct ) throws ElkException { } }

implementation: InstanceNode < ElkClass , ElkNamedIndividual > node = getInstanceNode ( elkNamedIndividual ) ; return direct ? node . getDirectTypeNodes ( ) : node . getAllTypeNodes ( ) ;


signature:
public class Reasoner { /** * Check if the given { @ link ElkClassExpression } is satisfiable , that is , if
 * it can possibly have instances . { @ link ElkClassExpression } s are not
 * satisfiable if they are equivalent to { @ code owl : Nothing } . A satisfiable
 * { @ link ElkClassExpression } is also called consistent or coherent . Calling
 * of this method may trigger the computation of the taxonomy , if it has not
 * been done yet .
 * @ param classExpression
 * the { @ link ElkClassExpression } for which to check
 * satisfiability
 * @ return { @ code true } if the given input is satisfiable
 * @ throws ElkException
 * if the result cannot be computed */
public synchronized boolean isSatisfiable ( ElkClassExpression classExpression ) throws ElkException { } }

implementation: if ( classExpression instanceof ElkClass ) { final TaxonomyNode < ElkClass > queryNode = getTaxonomyNode ( ( ElkClass ) classExpression ) ; return ! queryNode . contains ( getElkFactory ( ) . getOwlNothing ( ) ) ; } return querySatisfiability ( classExpression ) ;


signature:
public class StatisticsPrinter { /** * Prints the heading together with the separators */
public void printHeader ( ) { } }

implementation: printSeparator ( ) ; addPadding ( ' ' , headerParams_ ) ; logger_ . debug ( String . format ( headerFormat_ , headerParams_ ) ) ; printSeparator ( ) ;


signature:
public class StatisticsPrinter { /** * Appends a string consisting of the given character to the first value so
 * that when the values when formatted have in total { @ value # FORMAT _ WIDTH _ }
 * characters
 * @ param c
 * @ param values
 * @ return */
Object [ ] addPadding ( char c , Object ... values ) { } }

implementation: String firstValue = values [ 0 ] . toString ( ) ; int paddingLength = maxPaddingWidth_ - firstValue . length ( ) ; if ( paddingLength > 0 ) { String padding = getString ( c , paddingLength ) ; values [ 0 ] = firstValue + padding ; } return values ;


signature:
public class StatisticsPrinter { /** * Formats and the given values , adding padding symbols if necessary . The
 * given array may be modified , but the values themselves are not modified .
 * @ param values */
public void print ( Object ... values ) { } }

implementation: addPadding ( '.' , values ) ; logger_ . debug ( String . format ( valuesFormat_ , values ) ) ;


signature:
public class StatisticsPrinter { /** * Creates a string of the given length consisting of the given character
 * @ param c
 * @ param n
 * @ return */
static String getString ( char c , int n ) { } }

implementation: StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { sb . append ( c ) ; } return sb . toString ( ) ;


signature:
public class PredefinedElkIris { /** * Defines an ordering on IRIs starting with { @ link # OWL _ NOTHING } ,
 * { @ link # OWL _ THING } , followed by the remaining IRIs in alphabetical order .
 * @ param firstIri
 * the fist { @ link ElkIri } to compare with the second
 * @ param secondIri
 * the second { @ link ElkIri } to compare with the first
 * @ return a negative integer , zero , or a positive integer as the first IRI
 * is less , equal , or greater than the second IRI in the specified
 * order */
public static int compare ( ElkIri firstIri , ElkIri secondIri ) { } }

implementation:
boolean isOwl0 = firstIri . equals ( OWL_THING ) || firstIri . equals ( OWL_NOTHING ) ; boolean isOwl1 = secondIri . equals ( OWL_THING ) || secondIri . equals ( OWL_NOTHING ) ; if ( isOwl0 == isOwl1 ) return firstIri . compareTo ( secondIri ) ; // else
return isOwl0 ? - 1 : 1 ;


signature:
public class NativeRunner { /** * Arguments are as follows : 0 - name of the reasoning task ( SAT , query ,
 * classification , consistency ) 1 - ontology path 2 - output path 3 -
 * concept URI , in case of SAT
 * @ param args
 * @ throws Exception */
public static void main ( String [ ] args ) throws Exception { } }

implementation:
Task task = validateArgs ( args ) ; // help
if ( task == null ) { printHelp ( ) ; return ; } NativeRunner runner = new NativeRunner ( ) ; runner . run ( args , task ) ;


signature:
public class InlinedClassInclusionExistentialPropertyExpansionStep { /** * Checks if { @ link ProofStep } is derived by
 * { @ link ElkClassInclusionExistentialComposition } inference where the last
 * premise is derived from
 * { @ link ElkPropertyInclusionOfTransitiveObjectProperty }
 * @ param step
 * @ return the transitivity axiom node that is the premise of the inference
 * for the last premise */
static ProofNode < OWLAxiom > canConvertStep ( ProofStep < OWLAxiom > step ) { } }

implementation:
if ( step . getName ( ) != ElkClassInclusionExistentialComposition . NAME ) { return null ; } List < ? extends ProofNode < OWLAxiom > > premises = step . getPremises ( ) ; ProofNode < OWLAxiom > lastPremise = premises . get ( premises . size ( ) - 1 ) ; Collection < ? extends ProofStep < OWLAxiom > > lastPremiseSteps = lastPremise . getInferences ( ) ; if ( lastPremiseSteps . size ( ) != 1 ) { return null ; } // else
for ( ProofStep < OWLAxiom > lastPremiseStep : lastPremiseSteps ) { if ( lastPremiseStep . getName ( ) == ElkPropertyInclusionOfTransitiveObjectProperty . NAME ) { return lastPremiseStep . getPremises ( ) . get ( 0 ) ; } } // else
return null ;


signature:
public class ClassTaxonomyState { /** * Prunes { @ link # toAdd _ } .
 * < strong > { @ code taxonomy _ } must not be { @ code null } ! < / strong >
 * @ return The resulting size of { @ link # toAdd _ } . */
private int pruneToAdd ( ) { } }

implementation:
final Iterator < IndexedClass > iter = toAdd_ . iterator ( ) ; int size = 0 ; while ( iter . hasNext ( ) ) { final IndexedClass cls = iter . next ( ) ; /* @ formatter : off
 * Should be pruned when :
 * it is not in ontology , or
 * it is in the top node , or
 * it has super - nodes in taxonomy .
 * @ formatter : on */
if ( ! cls . occurs ( ) ) { iter . remove ( ) ; continue ; } // else
final Context context = saturationState_ . getContext ( cls ) ; if ( context == null || ! context . isInitialized ( ) || ! context . isSaturated ( ) ) { // it is not saturated .
size ++ ; continue ; } // else
final TaxonomyNode < ElkClass > node = taxonomy_ . getNode ( cls . getElkEntity ( ) ) ; if ( node == null ) { // it is not in taxonomy
size ++ ; continue ; } // else
if ( node . equals ( taxonomy_ . getTopNode ( ) ) ) { iter . remove ( ) ; continue ; } // else
if ( ! node . getDirectSuperNodes ( ) . isEmpty ( ) ) { iter . remove ( ) ; continue ; } // else
size ++ ; } return size ;


signature:
public class ClassTaxonomyState { /** * Prunes { @ link # toRemove _ } .
 * < strong > { @ code taxonomy _ } must not be { @ code null } ! < / strong >
 * @ return The resulting size of { @ link # toRemove _ } . */
private int pruneToRemove ( ) { } }

implementation:
final Iterator < IndexedClass > iter = toRemove_ . iterator ( ) ; int size = 0 ; while ( iter . hasNext ( ) ) { final IndexedClass cls = iter . next ( ) ; /* @ formatter : off
 * Should be pruned when
 * it is not in taxonomy , or
 * it is in the bottom class .
 * @ formatter : on */
final TaxonomyNode < ElkClass > node = taxonomy_ . getNode ( cls . getElkEntity ( ) ) ; if ( node == null ) { iter . remove ( ) ; continue ; } // else
if ( cls == ontologyIndex_ . getOwlNothing ( ) ) { iter . remove ( ) ; continue ; } size ++ ; } return size ;


signature:
public class RuleCounter { /** * Add the values the corresponding values of the given counter
 * @ param counter */
public synchronized void add ( RuleCounter counter ) { } }

implementation: countOwlThingContextInitRule += counter . countOwlThingContextInitRule ; countRootContextInitializationRule += counter . countRootContextInitializationRule ; countDisjointSubsumerFromMemberRule += counter . countDisjointSubsumerFromMemberRule ; countContradictionFromNegationRule += counter . countContradictionFromNegationRule ; countObjectIntersectionFromFirstConjunctRule += counter . countObjectIntersectionFromFirstConjunctRule ; countObjectIntersectionFromSecondConjunctRule += counter . countObjectIntersectionFromSecondConjunctRule ; countSuperClassFromSubClassRule += counter . countSuperClassFromSubClassRule ; countPropagationFromExistentialFillerRule += counter . countPropagationFromExistentialFillerRule ; countObjectUnionFromDisjunctRule += counter . countObjectUnionFromDisjunctRule ; countBackwardLinkChainFromBackwardLinkRule += counter . countBackwardLinkChainFromBackwardLinkRule ; countSubsumerBackwardLinkRule += counter . countSubsumerBackwardLinkRule ; countContradictionOverBackwardLinkRule += counter . countContradictionOverBackwardLinkRule ; countContradictionPropagationRule += counter . countContradictionPropagationRule ; countContradictionCompositionRule += counter . countContradictionCompositionRule ; countNonReflexiveBackwardLinkCompositionRule += counter . countNonReflexiveBackwardLinkCompositionRule ; countIndexedObjectIntersectionOfDecomposition += counter . countIndexedObjectIntersectionOfDecomposition ; countIndexedObjectSomeValuesFromDecomposition += counter . countIndexedObjectSomeValuesFromDecomposition ; countIndexedObjectComplementOfDecomposition += counter . countIndexedObjectComplementOfDecomposition ; countIndexedObjectHasSelfDecomposition += counter . countIndexedObjectHasSelfDecomposition ; countContradictionFromOwlNothingRule += counter . countContradictionFromOwlNothingRule ; countSubsumerPropagationRule += counter . countSubsumerPropagationRule ; countReflexiveBackwardLinkCompositionRule += counter . countReflexiveBackwardLinkCompositionRule ; countPropagationInitializationRule += counter . countPropagationInitializationRule ; countBackwardLinkFromForwardLinkRule += counter . countBackwardLinkFromForwardLinkRule ; countComposedFromDecomposedSubsumerRule += counter . countComposedFromDecomposedSubsumerRule ; countIndexedClassDecompositionRule += counter . countIndexedClassDecompositionRule ; countIndexedClassFromDefinitionRule += counter . countIndexedClassFromDefinitionRule ; countEquivalentClassFirstFromSecondRule += counter . countEquivalentClassFirstFromSecondRule ; countEquivalentClassSecondFromFirstRule += counter . countEquivalentClassSecondFromFirstRule ;


signature:
public class ReasonerComputation { /** * Process the given input concurrently using the provided input processor .
 * If the process has been interrupted , this method can be called again to
 * continue the computation . */
public void process ( ) { } }

implementation:
if ( ! start ( ) ) { String message = "Could not start workers required for reasoner computation!" ; LOGGER_ . error ( message ) ; throw new ElkRuntimeException ( message ) ; } try { finish ( ) ; } catch ( InterruptedException e ) { // restore interrupt status
Thread . currentThread ( ) . interrupt ( ) ; throw new ElkRuntimeException ( "Reasoner computation interrupted externally!" ) ; }


signature:
public class XhtmlResourceMessageConverter { /** * From { @ link ServletServerHttpRequest } : Use { @ link javax . servlet . ServletRequest # getParameterMap ( ) } to reconstruct
 * the body of a form ' POST ' providing a predictable outcome as opposed to reading from the body , which can fail if
 * any other code has used ServletRequest to access a parameter thus causing the input stream to be " consumed " . */
private InputStream getBodyFromServletRequestParameters ( HttpServletRequest request , String charset ) throws IOException { } }

implementation: ByteArrayOutputStream bos = new ByteArrayOutputStream ( 1024 ) ; Writer writer = new OutputStreamWriter ( bos , charset ) ; @ SuppressWarnings ( "unchecked" ) Map < String , String [ ] > form = request . getParameterMap ( ) ; for ( Iterator < String > nameIterator = form . keySet ( ) . iterator ( ) ; nameIterator . hasNext ( ) ; ) { String name = nameIterator . next ( ) ; List < String > values = Arrays . asList ( form . get ( name ) ) ; for ( Iterator < String > valueIterator = values . iterator ( ) ; valueIterator . hasNext ( ) ; ) { String value = valueIterator . next ( ) ; writer . write ( URLEncoder . encode ( name , charset ) ) ; if ( value != null ) { writer . write ( '=' ) ; writer . write ( URLEncoder . encode ( value , charset ) ) ; if ( valueIterator . hasNext ( ) ) { writer . write ( '&' ) ; } } } if ( nameIterator . hasNext ( ) ) { writer . append ( '&' ) ; } } writer . flush ( ) ; return new ByteArrayInputStream ( bos . toByteArray ( ) ) ;


signature:
public class XhtmlResourceMessageConverter { /** * Recursively converts object to xhtml data .
 * @ param object
 * to convert
 * @ param writer
 * to write to */
private void writeResource ( XhtmlWriter writer , Object object ) { } }

implementation:
if ( object == null ) { return ; } try { if ( object instanceof Resource ) { Resource < ? > resource = ( Resource < ? > ) object ; writer . beginListItem ( ) ; writeResource ( writer , resource . getContent ( ) ) ; writer . writeLinks ( resource . getLinks ( ) ) ; writer . endListItem ( ) ; } else if ( object instanceof Resources ) { Resources < ? > resources = ( Resources < ? > ) object ; // TODO set name using EVO see HypermediaSupportBeanDefinitionRegistrar
writer . beginListItem ( ) ; writer . beginUnorderedList ( ) ; Collection < ? > content = resources . getContent ( ) ; writeResource ( writer , content ) ; writer . endUnorderedList ( ) ; writer . writeLinks ( resources . getLinks ( ) ) ; writer . endListItem ( ) ; } else if ( object instanceof ResourceSupport ) { ResourceSupport resource = ( ResourceSupport ) object ; writer . beginListItem ( ) ; writeObject ( writer , resource ) ; writer . writeLinks ( resource . getLinks ( ) ) ; writer . endListItem ( ) ; } else if ( object instanceof Collection ) { Collection < ? > collection = ( Collection < ? > ) object ; for ( Object item : collection ) { writeResource ( writer , item ) ; } } else { // TODO : write li for simple objects in Resources Collection
writeObject ( writer , object ) ; } } catch ( Exception ex ) { throw new RuntimeException ( "failed to transform object " + object , ex ) ; }


signature:
public class SpringActionDescriptor { /** * Gets input parameter info which is part of the URL mapping , be it request parameters , path variables or request
 * body attributes .
 * @ param name
 * to retrieve
 * @ return parameter descriptor or null */
@ Override public ActionInputParameter getActionInputParameter ( String name ) { } }

implementation:
ActionInputParameter ret = requestParams . get ( name ) ; if ( ret == null ) { ret = pathVariables . get ( name ) ; } if ( ret == null ) { for ( ActionInputParameter annotatedParameter : getInputParameters ( ) ) { // TODO create ActionInputParameter for bean property at property path
// TODO field access in addition to bean ?
PropertyDescriptor pd = getPropertyDescriptorForPropertyPath ( name , annotatedParameter . getParameterType ( ) ) ; if ( pd != null ) { if ( pd . getWriteMethod ( ) != null ) { Object callValue = annotatedParameter . getValue ( ) ; Object propertyValue = null ; if ( callValue != null ) { BeanWrapper beanWrapper = PropertyAccessorFactory . forBeanPropertyAccess ( callValue ) ; propertyValue = beanWrapper . getPropertyValue ( name ) ; } ret = new SpringActionInputParameter ( new MethodParameter ( pd . getWriteMethod ( ) , 0 ) , propertyValue ) ; } break ; } } } return ret ;


signature:
public class SpringActionDescriptor { /** * Recursively navigate to return a BeanWrapper for the nested property path .
 * @ param propertyPath
 * property property path , which may be nested
 * @ return a BeanWrapper for the target bean */
PropertyDescriptor getPropertyDescriptorForPropertyPath ( String propertyPath , Class < ? > propertyType ) { } }

implementation:
int pos = PropertyAccessorUtils . getFirstNestedPropertySeparatorIndex ( propertyPath ) ; // Handle nested properties recursively .
if ( pos > - 1 ) { String nestedProperty = propertyPath . substring ( 0 , pos ) ; String nestedPath = propertyPath . substring ( pos + 1 ) ; PropertyDescriptor propertyDescriptor = BeanUtils . getPropertyDescriptor ( propertyType , nestedProperty ) ; // BeanWrapperImpl nestedBw = getNestedBeanWrapper ( nestedProperty ) ;
return getPropertyDescriptorForPropertyPath ( nestedPath , propertyDescriptor . getPropertyType ( ) ) ; } else { return BeanUtils . getPropertyDescriptor ( propertyType , propertyPath ) ; }


signature:
public class SpringActionDescriptor { /** * Determines action input parameters for required url variables .
 * @ return required url variables */
@ Override public Map < String , ActionInputParameter > getRequiredParameters ( ) { } }

implementation:
Map < String , ActionInputParameter > ret = new HashMap < String , ActionInputParameter > ( ) ; for ( Map . Entry < String , ActionInputParameter > entry : requestParams . entrySet ( ) ) { ActionInputParameter annotatedParameter = entry . getValue ( ) ; if ( annotatedParameter . isRequired ( ) ) { ret . put ( entry . getKey ( ) , annotatedParameter ) ; } } for ( Map . Entry < String , ActionInputParameter > entry : pathVariables . entrySet ( ) ) { ActionInputParameter annotatedParameter = entry . getValue ( ) ; ret . put ( entry . getKey ( ) , annotatedParameter ) ; } // requestBody not supported , would have to use exploded modifier
return ret ;


signature:
public class DataType { /** * Determines if the given class holds only one data item . Can be useful to determine if a value should be rendered
 * as scalar .
 * @ param clazz
 * to check
 * @ return true if class is scalar */
public static boolean isSingleValueType ( Class < ? > clazz ) { } }

implementation: boolean ret ; if ( isNumber ( clazz ) || isBoolean ( clazz ) || isString ( clazz ) || isEnum ( clazz ) || isDate ( clazz ) || isCalendar ( clazz ) || isCurrency ( clazz ) ) { ret = true ; } else { ret = false ; } return ret ;


signature:
public class DataType { /** * Determines if the given string contains only 0-9 [ ISO - LATIN - 1 ] or an optional leading + / - sign .
 * @ param str
 * to check
 * @ return true if condition holds , false otherwise
 * @ see < a href = " http : / / stackoverflow . com / a / 29331473/743507 " > Comparison of regex and char array performance < / a >
 * @ see Character # isDigit Examples for non - ISO - Latin - 1 - Digits */
public static boolean isIsoLatin1Number ( String str ) { } }

implementation: if ( str == null ) return false ; char [ ] data = str . toCharArray ( ) ; if ( data . length == 0 ) return false ; int index = 0 ; if ( data . length > 1 && ( data [ 0 ] == '-' || data [ 0 ] == '+' ) ) index = 1 ; for ( ; index < data . length ; index ++ ) { if ( data [ index ] < '0' || data [ index ] > '9' ) return false ; } return true ;


signature:
public class Affordance { /** * The relation type of the link .
 * @ param rel IANA - registered type or extension relation type . */
public void addRel ( String rel ) { } }

implementation: Assert . hasLength ( rel ) ; linkParams . add ( REL . paramName , rel ) ;


signature:
public class Affordance { /** * The " type " parameter , when present , is a hint indicating what the media type of the result of dereferencing the
 * link should be . Note that this is only a hint ; for example , it does not override the Content - Type header of a
 * HTTP response obtained by actually following the link . There MUST NOT be more than one type parameter in a link -
 * value .
 * @ param mediaType to set */
public void setType ( String mediaType ) { } }

implementation: if ( mediaType != null ) linkParams . set ( TYPE . paramName , mediaType ) ; else linkParams . remove ( TYPE . paramName ) ;


signature:
public class Affordance { /** * The " hreflang " parameter , when present , is a hint indicating what the language of the result of dereferencing the
 * link should be . Note that this is only a hint ; for example , it does not override the Content - Language header of
 * a HTTP response obtained by actually following the link . Multiple " hreflang " parameters on a single link - value
 * indicate that multiple languages are available from the indicated resource .
 * @ param hreflang to add */
public void addHreflang ( String hreflang ) { } }

implementation: Assert . hasLength ( hreflang ) ; linkParams . add ( HREFLANG . paramName , hreflang ) ;


signature:
public class Affordance { /** * The " title " parameter , when present , is used to label the destination of a link such that it can be used as a
 * human - readable identifier ( e . g . , a menu entry ) in the language indicated by the Content - Language header ( if
 * present ) . The " title " parameter MUST NOT appear more than once in a given link - value ; occurrences after the
 * first MUST be ignored by parsers .
 * @ param title to set */
public void setTitle ( String title ) { } }

implementation: if ( title != null ) linkParams . set ( TITLE . paramName , title ) ; else { linkParams . remove ( TITLE . paramName ) ; }


signature:
public class Affordance { /** * The " title * " parameter can be used to encode the title label in a different character set , and / or contain
 * language information as per < a href = " https : / / tools . ietf . org / html / rfc5987 " > RFC - 5987 < / a > . The " title * " parameter MUST NOT appear more than once in a given
 * link - value ; occurrences after the first MUST be ignored by parsers . If the parameter does not contain language
 * information , its language is indicated by the Content - Language header ( when present ) .
 * If both the " title " and " title * " parameters appear in a link - value , processors SHOULD use the " title * "
 * parameter ' s value . < p > The example below shows an instance of the Link header encoding a link title using < a href = " https : / / tools . ietf . org / html / rfc2231 " > RFC - 2231 < / a >
 * encoding to encode both non - ASCII characters and language information . < / p >
 * < pre >
 * Link : & lt ; / TheBook / chapter2 & gt ;
 * rel = " next " ; title * = UTF - 8 ' de ' n % c3 % a4chstes % 20Kapitel
 * < / pre >
 * @ param titleStar to set */
public void setTitleStar ( String titleStar ) { } }

implementation: if ( titleStar != null ) linkParams . set ( TITLE_STAR . paramName , titleStar ) ; else linkParams . remove ( TITLE_STAR . paramName ) ;


signature:
public class Affordance { /** * The " media " parameter , when present , is used to indicate intended destination medium or media for style
 * information ( see [ W3C . REC - html401-19991224 ] , Section 6.13 ) . Note that this may be updated by
 * [ W3C . CR - css3 - mediaqueries - 20090915 ] ) . Its value MUST be quoted if it contains a semicolon ( " ; " ) or comma ( " , " ) ,
 * and there MUST NOT be more than one " media " parameter in a link - value .
 * @ param mediaDesc to set */
public void setMedia ( String mediaDesc ) { } }

implementation: if ( mediaDesc != null ) linkParams . set ( MEDIA . paramName , mediaDesc ) ; else linkParams . remove ( MEDIA . paramName ) ;


signature:
public class Affordance { /** * The " rev " parameter has been used in the past to indicate that the semantics of the relationship are in the
 * reverse direction . That is , a link from A to B with REL = " X " expresses the same relationship as a link from B to
 * A with REV = " X " . " rev " is deprecated by this specification because it often confuses authors and readers ; in most
 * cases , using a separate relation type is preferable .
 * @ param rev to add */
public void addRev ( String rev ) { } }

implementation: Assert . hasLength ( rev ) ; linkParams . add ( REV . paramName , rev ) ;


signature:
public class Affordance { /** * By default , the context of a link conveyed in the Link header field is the IRI of the requested resource . < p > When
 * present , the anchor parameter overrides this with another URI , such as a fragment of this resource , or a third
 * resource ( i . e . , when the anchor value is an absolute URI ) . If the anchor parameter ' s value is a relative URI ,
 * parsers MUST resolve it as per [ RFC3986 ] , Section 5 . Note that any base URI from the body ' s content is not
 * applied .
 * @ param anchor base uri to define */
public void setAnchor ( String anchor ) { } }

implementation: if ( anchor != null ) linkParams . set ( ANCHOR . paramName , anchor ) ; else linkParams . remove ( ANCHOR . paramName ) ;


signature:
public class Affordance { /** * Adds link - extension params , i . e . custom params which are not described in the web linking rfc .
 * @ param paramName of link - extension
 * @ param values one or more values to add */
public void addLinkParam ( String paramName , String ... values ) { } }

implementation: Assert . notEmpty ( values ) ; for ( String value : values ) { Assert . hasLength ( value ) ; linkParams . add ( paramName , value ) ; }


signature:
public class Affordance { /** * Affordance represented as http link header value . Note that the href may be templated , for convenience you can
 * use { @ link # getHeaderName ( ) } to ensure a Link or Link - Header is produced appropriately .
 * @ return Link or Link - template header value */
public String asHeader ( ) { } }

implementation: StringBuilder result = new StringBuilder ( ) ; for ( Map . Entry < String , List < String > > linkParamEntry : linkParams . entrySet ( ) ) { if ( result . length ( ) != 0 ) { result . append ( "; " ) ; } String linkParamEntryKey = linkParamEntry . getKey ( ) ; if ( REL . paramName . equals ( linkParamEntryKey ) || REV . paramName . equals ( linkParamEntryKey ) ) { result . append ( linkParamEntryKey ) . append ( "=" ) ; result . append ( "\"" ) . append ( StringUtils . collectionToDelimitedString ( linkParamEntry . getValue ( ) , " " ) ) . append ( "\"" ) ; } else { StringBuilder linkParams = new StringBuilder ( ) ; for ( String value : linkParamEntry . getValue ( ) ) { if ( linkParams . length ( ) != 0 ) { linkParams . append ( "; " ) ; } linkParams . append ( linkParamEntryKey ) . append ( "=" ) ; linkParams . append ( "\"" ) . append ( value ) . append ( "\"" ) ; } result . append ( linkParams ) ; } } String linkHeader = "<" + partialUriTemplate . asComponents ( ) . toString ( ) + ">; " ; return result . insert ( 0 , linkHeader ) . toString ( ) ;


signature:
public class Affordance { /** * Expands template variables , arguments must satisfy all required template variables , unsatisfied optional
 * arguments will be removed .
 * @ param arguments to expansion
 * @ return expanded affordance */
@ Override public Affordance expand ( Map < String , ? extends Object > arguments ) { } }

implementation: UriTemplate template = new UriTemplate ( partialUriTemplate . asComponents ( ) . toString ( ) ) ; String expanded = template . expand ( arguments ) . toASCIIString ( ) ; return new Affordance ( expanded , linkParams , actionDescriptors ) ;


signature:
public class Affordance { /** * Expands template variables as far as possible , unsatisfied variables will remain variables . This is primarily for
 * manually created affordances . If the Affordance has been created with linkTo - methodOn , it should not be necessary
 * to expand the affordance again .
 * @ param arguments for expansion , in the order they appear in the template
 * @ return partially expanded affordance */
public Affordance expandPartially ( Object ... arguments ) { } }

implementation: return new Affordance ( partialUriTemplate . expand ( arguments ) . toString ( ) , linkParams , actionDescriptors ) ;


signature:
public class Affordance { /** * Expands template variables as far as possible , unsatisfied variables will remain variables . This is primarily for
 * manually created affordances . If the Affordance has been created with linkTo - methodOn , it should not be necessary
 * to expand the affordance again .
 * @ param arguments for expansion
 * @ return partially expanded affordance */
public Affordance expandPartially ( Map < String , ? extends Object > arguments ) { } }

implementation: return new Affordance ( partialUriTemplate . expand ( ( Map < String , Object > ) arguments ) . toString ( ) , linkParams , actionDescriptors ) ;


signature:
public class Affordance { /** * Allows to retrieve all rels defined for this affordance .
 * @ return rels */
@ JsonIgnore public List < String > getRels ( ) { } }

implementation: final List < String > rels = linkParams . get ( REL . paramName ) ; return rels == null ? Collections . < String > emptyList ( ) : Collections . unmodifiableList ( rels ) ;


signature:
public class Affordance { /** * Retrieves all revs for this affordance .
 * @ return revs */
@ JsonIgnore public List < String > getRevs ( ) { } }

implementation: final List < String > revs = linkParams . get ( REV . paramName ) ; return revs == null ? Collections . < String > emptyList ( ) : Collections . unmodifiableList ( revs ) ;


signature:
public class Affordance { /** * Determines if the affordance has unsatisfied required variables . This allows to decide if the affordance can also
 * be treated as a plain Link without template variables if the caller omits all optional variables . Serializers can
 * use this to render it as a resource with optional search features .
 * @ return true if the affordance has unsatisfied required variables */
@ JsonIgnore public boolean hasUnsatisfiedRequiredVariables ( ) { } }

implementation: for ( ActionDescriptor actionDescriptor : actionDescriptors ) { Map < String , ActionInputParameter > requiredParameters = actionDescriptor . getRequiredParameters ( ) ; for ( ActionInputParameter annotatedParameter : requiredParameters . values ( ) ) { if ( ! annotatedParameter . hasValue ( ) ) { return true ; } } } return false ;


signature:
public class ForwardedHeader { /** * Creates a new { @ link ForwardedHeader } from the given source .
 * @ param source can be { @ literal null } .
 * @ return */
public static ForwardedHeader of ( String source ) { } }

implementation: if ( ! StringUtils . hasText ( source ) ) { return NO_HEADER ; } Map < String , String > elements = new HashMap < String , String > ( ) ; for ( String part : source . split ( ";" ) ) { String [ ] keyValue = part . split ( "=" ) ; if ( keyValue . length != 2 ) { continue ; } elements . put ( keyValue [ 0 ] . trim ( ) , keyValue [ 1 ] . trim ( ) ) ; } Assert . notNull ( elements , "Forwarded elements must not be null!" ) ; Assert . isTrue ( ! elements . isEmpty ( ) , "At least one forwarded element needs to be present!" ) ; return new ForwardedHeader ( elements ) ;


signature:
public class SpringActionInputParameter { /** * The value of the parameter at sample invocation time , formatted according to conversion configuration .
 * @ return value , may be null */
public String getValueFormatted ( ) { } }

implementation: String ret ; if ( value == null ) { ret = null ; } else { ret = ( String ) conversionService . convert ( value , typeDescriptor , TypeDescriptor . valueOf ( String . class ) ) ; } return ret ;


signature:
public class SpringActionInputParameter { /** * Gets HTML5 parameter type for input field according to { @ link Type } annotation .
 * @ return the type */
@ Override public Type getHtmlInputFieldType ( ) { } }

implementation: final Type ret ; if ( inputAnnotation == null || inputAnnotation . value ( ) == Type . FROM_JAVA ) { if ( isArrayOrCollection ( ) || isRequestBody ( ) ) { ret = null ; } else if ( DataType . isNumber ( getParameterType ( ) ) ) { ret = Type . NUMBER ; } else { ret = Type . TEXT ; } } else { ret = inputAnnotation . value ( ) ; } return ret ;


signature:
public class SpringActionInputParameter { /** * Determines if request body input parameter has a hidden input property .
 * @ param property name or property path
 * @ return true if hidden */
@ Override public boolean isHidden ( String property ) { } }

implementation: Annotation [ ] paramAnnotations = methodParameter . getParameterAnnotations ( ) ; Input inputAnnotation = methodParameter . getParameterAnnotation ( Input . class ) ; return inputAnnotation != null && arrayContains ( inputAnnotation . hidden ( ) , property ) ;


signature:
public class SpringActionInputParameter { /** * Find out if property is included by searching through all annotations .
 * @ param property
 * @ return */
private boolean containsPropertyIncludeValue ( String property ) { } }

implementation: return arrayContains ( inputAnnotation . readOnly ( ) , property ) || arrayContains ( inputAnnotation . hidden ( ) , property ) || arrayContains ( inputAnnotation . include ( ) , property ) ;


signature:
public class SpringActionInputParameter { /** * Has any explicit include value or might have implicit includes because there is a hidden or readOnly flag .
 * @ return true if explicitly or implicitly included . */
private boolean hasExplicitOrImplicitPropertyIncludeValue ( ) { } }

implementation:
// TODO maybe not a useful optimization
return inputAnnotation != null && inputAnnotation . readOnly ( ) . length > 0 || inputAnnotation . hidden ( ) . length > 0 || inputAnnotation . include ( ) . length > 0 ;


signature:
public class SpringActionInputParameter { /** * Determines if request body input parameter should be excluded , considering { @ link Input # exclude } .
 * @ param property name or property path
 * @ return true if excluded , false if no include statement found or not excluded */
@ Override public boolean isExcluded ( String property ) { } }

implementation: return inputAnnotation != null && arrayContains ( inputAnnotation . exclude ( ) , property ) ;


signature:
public class SpringActionInputParameter { /** * Is this action input parameter required , based on the presence of a default value , the parameter annotations and
 * the kind of input parameter .
 * @ return true if required */
public boolean isRequired ( ) { } }

implementation: boolean ret ; if ( isRequestBody ( ) ) { ret = requestBody . required ( ) ; } else if ( isRequestParam ( ) ) { ret = ! ( isDefined ( requestParam . defaultValue ( ) ) || ! requestParam . required ( ) ) ; } else if ( isRequestHeader ( ) ) { ret = ! ( isDefined ( requestHeader . defaultValue ( ) ) || ! requestHeader . required ( ) ) ; } else { ret = true ; } return ret ;


signature:
public class SpringActionInputParameter { /** * Determines default value of request param or request header , if available .
 * @ return value or null */
public String getDefaultValue ( ) { } }

implementation: String ret ; if ( isRequestParam ( ) ) { ret = isDefined ( requestParam . defaultValue ( ) ) ? requestParam . defaultValue ( ) : null ; } else if ( isRequestHeader ( ) ) { ret = ! ( ValueConstants . DEFAULT_NONE . equals ( requestHeader . defaultValue ( ) ) ) ? requestHeader . defaultValue ( ) : null ; } else { ret = null ; } return ret ;


signature:
public class SpringActionInputParameter { /** * Allows convenient access to multiple call values in case that this input parameter is an array or collection .
 * Make sure to check { @ link # isArrayOrCollection ( ) } before calling this method .
 * @ return call values or empty array
 * @ throws UnsupportedOperationException if this input parameter is not an array or collection */
public Object [ ] getValues ( ) { } }

implementation: Object [ ] callValues ; if ( ! isArrayOrCollection ( ) ) { throw new UnsupportedOperationException ( "parameter is not an array or collection" ) ; } Object callValue = getValue ( ) ; if ( callValue == null ) { callValues = new Object [ 0 ] ; } else { Class < ? > parameterType = getParameterType ( ) ; if ( parameterType . isArray ( ) ) { callValues = ( Object [ ] ) callValue ; } else { callValues = ( ( Collection < ? > ) callValue ) . toArray ( ) ; } } return callValues ;


signature:
public class SpringActionInputParameter { /** * Gets request parameter name of this action input parameter .
 * @ return name */
@ Override public String getParameterName ( ) { } }

implementation: String ret = null ; if ( requestParam != null ) { String requestParamName = requestParam . value ( ) ; if ( ! requestParamName . isEmpty ( ) ) ret = requestParamName ; } if ( pathVariable != null ) { String pathVariableName = pathVariable . value ( ) ; if ( ! pathVariableName . isEmpty ( ) ) ret = pathVariableName ; } if ( ret == null ) { String parameterName = methodParameter . getParameterName ( ) ; if ( parameterName == null ) { methodParameter . initParameterNameDiscovery ( new LocalVariableTableParameterNameDiscoverer ( ) ) ; ret = methodParameter . getParameterName ( ) ; } else { ret = parameterName ; } } return ret ;


signature:
public class LinkListSerializer { /** * Writes bean description recursively .
 * @ param jgen to write to
 * @ param currentVocab in context
 * @ param valueType class of value
 * @ param allRootParameters of the method that receives the request body
 * @ param rootParameter the request body
 * @ param currentCallValue the value at the current recursion level
 * @ param propertyPath of the current recursion level
 * @ throws IntrospectionException
 * @ throws IOException */
private void recurseSupportedProperties ( JsonGenerator jgen , String currentVocab , Class < ? > valueType , ActionDescriptor allRootParameters , ActionInputParameter rootParameter , Object currentCallValue , String propertyPath ) throws IntrospectionException , IOException { } }

implementation:
Map < String , ActionInputParameter > properties = new HashMap < String , ActionInputParameter > ( ) ; // collect supported properties from ctor
Constructor [ ] constructors = valueType . getConstructors ( ) ; // find default ctor
Constructor constructor = PropertyUtils . findDefaultCtor ( constructors ) ; // find ctor with JsonCreator ann
if ( constructor == null ) { constructor = PropertyUtils . findJsonCreator ( constructors , JsonCreator . class ) ; } if ( constructor == null ) { // TODO this can be a generic collection , find a way to describe it
LOG . warn ( "can't describe supported properties, no default constructor or JsonCreator found for type " + valueType . getName ( ) ) ; return ; } int parameterCount = constructor . getParameterTypes ( ) . length ; if ( parameterCount > 0 ) { Annotation [ ] [ ] annotationsOnParameters = constructor . getParameterAnnotations ( ) ; Class [ ] parameters = constructor . getParameterTypes ( ) ; int paramIndex = 0 ; for ( Annotation [ ] annotationsOnParameter : annotationsOnParameters ) { for ( Annotation annotation : annotationsOnParameter ) { if ( JsonProperty . class == annotation . annotationType ( ) ) { JsonProperty jsonProperty = ( JsonProperty ) annotation ; // TODO use required attribute of JsonProperty
String paramName = jsonProperty . value ( ) ; Object propertyValue = PropertyUtils . getPropertyOrFieldValue ( currentCallValue , paramName ) ; ActionInputParameter constructorParamInputParameter = new SpringActionInputParameter ( new MethodParameter ( constructor , paramIndex ) , propertyValue ) ; // TODO collect ctor params , setter params and process
// TODO then handle single , collection and bean for both
properties . put ( paramName , constructorParamInputParameter ) ; paramIndex ++ ; // increase for each @ JsonProperty
} } } Assert . isTrue ( parameters . length == paramIndex , "not all constructor arguments of @JsonCreator " + constructor . getName ( ) + " are annotated with @JsonProperty" ) ; } // collect supported properties from setters
// TODO support Option provider by other method args ?
final BeanInfo beanInfo = Introspector . getBeanInfo ( valueType ) ; final PropertyDescriptor [ ] propertyDescriptors = beanInfo . getPropertyDescriptors ( ) ; // TODO collection and map
// TODO distinguish which properties should be printed as supported - now just setters
for ( PropertyDescriptor propertyDescriptor : propertyDescriptors ) { final Method writeMethod = propertyDescriptor . getWriteMethod ( ) ; if ( writeMethod == null ) { continue ; } // TODO : the property name must be a valid URI - need to check context for terms ?
String propertyName = getWritableExposedPropertyOrPropertyName ( propertyDescriptor ) ; Object propertyValue = PropertyUtils . getPropertyOrFieldValue ( currentCallValue , propertyDescriptor . getName ( ) ) ; MethodParameter methodParameter = new MethodParameter ( propertyDescriptor . getWriteMethod ( ) , 0 ) ; ActionInputParameter propertySetterInputParameter = new SpringActionInputParameter ( methodParameter , propertyValue ) ; properties . put ( propertyName , propertySetterInputParameter ) ; } // write all supported properties
// TODO we are using the annotatedParameter . parameterName but should use the key of properties here :
for ( ActionInputParameter annotatedParameter : properties . values ( ) ) { String nextPropertyPathLevel = propertyPath . isEmpty ( ) ? annotatedParameter . getParameterName ( ) : propertyPath + '.' + annotatedParameter . getParameterName ( ) ; Class < ? > parameterType = annotatedParameter . getParameterType ( ) ; if ( DataType . isSingleValueType ( parameterType ) ) { final Object [ ] possiblePropertyValues = rootParameter . getPossibleValues ( allRootParameters ) ; if ( rootParameter . isIncluded ( nextPropertyPathLevel ) && ! rootParameter . isExcluded ( nextPropertyPathLevel ) ) { writeSupportedProperty ( jgen , currentVocab , annotatedParameter , annotatedParameter . getParameterName ( ) , possiblePropertyValues ) ; } // TODO collections ?
// } else if ( DataType . isArrayOrCollection ( parameterType ) ) {
// Object [ ] callValues = rootParameter . getValues ( ) ;
// int items = callValues . length ;
// for ( int i = 0 ; i < items ; i + + ) {
// Object value ;
// if ( i < callValues . length ) {
// value = callValues [ i ] ;
// } else {
// value = null ;
// recurseSupportedProperties ( jgen , currentVocab , rootParameter
// . getParameterType ( ) ,
// allRootParameters , rootParameter , value ) ;
} else { jgen . writeStartObject ( ) ; jgen . writeStringField ( "hydra:property" , annotatedParameter . getParameterName ( ) ) ; // TODO : is the property required - > for bean props we need the Access annotation to express that
Expose expose = AnnotationUtils . getAnnotation ( parameterType , Expose . class ) ; String subClass = null ; if ( expose != null ) { subClass = expose . value ( ) ; } else { if ( List . class . isAssignableFrom ( parameterType ) ) { Type genericParameterType = annotatedParameter . getGenericParameterType ( ) ; if ( genericParameterType instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) genericParameterType ; Type [ ] actualTypeArguments = parameterizedType . getActualTypeArguments ( ) ; if ( actualTypeArguments . length == 1 ) { Type actualTypeArgument = actualTypeArguments [ 0 ] ; if ( actualTypeArgument instanceof Class ) { parameterType = ( Class < ? > ) actualTypeArgument ; subClass = parameterType . getSimpleName ( ) ; } else if ( actualTypeArgument instanceof ParameterizedType ) { ParameterizedType genericItemType = ( ParameterizedType ) actualTypeArgument ; Type rawType = genericItemType . getRawType ( ) ; if ( rawType instanceof Class ) { parameterType = ( Class < ? > ) rawType ; subClass = parameterType . getSimpleName ( ) ; } } } } if ( subClass != null ) { String multipleValueProp = getPropertyOrClassNameInVocab ( currentVocab , "multipleValues" , LdContextFactory . HTTP_SCHEMA_ORG , "schema:" ) ; jgen . writeBooleanField ( multipleValueProp , true ) ; } } } if ( subClass == null ) { subClass = parameterType . getSimpleName ( ) ; } jgen . writeObjectFieldStart ( getPropertyOrClassNameInVocab ( currentVocab , "rangeIncludes" , LdContextFactory . HTTP_SCHEMA_ORG , "schema:" ) ) ; jgen . writeStringField ( getPropertyOrClassNameInVocab ( currentVocab , "subClassOf" , "http://www.w3.org/2000/01/rdf-schema#" , "rdfs:" ) , subClass ) ; jgen . writeArrayFieldStart ( "hydra:supportedProperty" ) ; // TODO let defaultValue be an filled list , if needed
Object propertyValue = PropertyUtils . getPropertyOrFieldValue ( currentCallValue , annotatedParameter . getParameterName ( ) ) ; recurseSupportedProperties ( jgen , currentVocab , parameterType , allRootParameters , rootParameter , propertyValue , nextPropertyPathLevel ) ; jgen . writeEndArray ( ) ; jgen . writeEndObject ( ) ; jgen . writeEndObject ( ) ; } }


signature:
public class LinkListSerializer { /** * Gets property or class name in the current context , either without prefix if the current vocab is the given
 * vocabulary , or prefixed otherwise .
 * @ param currentVocab to determine the current vocab
 * @ param propertyOrClassName name to contextualize
 * @ param vocabulary to which the given property belongs
 * @ param vocabularyPrefixWithColon to use if the current vocab does not match the given vocabulary to which the name belongs , should end
 * with colon
 * @ return property name or class name in the currenct context */
private String getPropertyOrClassNameInVocab ( @ Nullable String currentVocab , String propertyOrClassName , String vocabulary , String vocabularyPrefixWithColon ) { } }

implementation: Assert . notNull ( vocabulary ) ; String ret ; if ( vocabulary . equals ( currentVocab ) ) { ret = propertyOrClassName ; } else { ret = vocabularyPrefixWithColon + propertyOrClassName ; } return ret ;


signature: public class LinkListSerializer { private void writeHydraVariableMapping ( JsonGenerator jgen , @ Nullable ActionDescriptor annotatedParameters , Collection < String > variableNames ) throws IOException { } }

implementation:
if ( annotatedParameters != null ) { for ( String variableName : variableNames ) { // TODO : find also @ Input
ActionInputParameter annotatedParameter = annotatedParameters . getActionInputParameter ( variableName ) ; // TODO access @ Input parameter , too
// only unsatisfied parameters become hydra variables
if ( annotatedParameter != null && annotatedParameter . getValue ( ) == null ) { jgen . writeStartObject ( ) ; jgen . writeStringField ( "@type" , "hydra:IriTemplateMapping" ) ; jgen . writeStringField ( "hydra:variable" , annotatedParameter . getParameterName ( ) ) ; jgen . writeBooleanField ( "hydra:required" , annotatedParameter . isRequired ( ) ) ; jgen . writeStringField ( "hydra:property" , getExposedPropertyOrParamName ( annotatedParameter ) ) ; jgen . writeEndObject ( ) ; } } }


signature:
public class LinkListSerializer { /** * Gets exposed property or parameter name .
 * @ param inputParameter for exposure
 * @ return property name */
private String getExposedPropertyOrParamName ( ActionInputParameter inputParameter ) { } }

implementation: final Expose expose = inputParameter . getAnnotation ( Expose . class ) ; String property ; if ( expose != null ) { property = expose . value ( ) ; } else { property = inputParameter . getParameterName ( ) ; } return property ;


signature:
public class LinkListSerializer { /** * Gets exposed property or parameter name for properties with an appropriate setter ( = write ) method .
 * @ param inputParameter for exposure
 * @ return property name */
private String getWritableExposedPropertyOrPropertyName ( PropertyDescriptor inputParameter ) { } }

implementation: final Method writeMethod = inputParameter . getWriteMethod ( ) ; final Expose expose = writeMethod . getAnnotation ( Expose . class ) ; String propertyName ; if ( expose != null ) { propertyName = expose . value ( ) ; } else { propertyName = inputParameter . getName ( ) ; } return propertyName ;


signature:
public class UberUtils { /** * Recursively converts object to nodes of uber data .
 * @ param objectNode
 * to append to
 * @ param object
 * to convert */
public static void toUberData ( AbstractUberNode objectNode , Object object ) { } }

implementation:
Set < String > filtered = FILTER_RESOURCE_SUPPORT ; if ( object == null ) { return ; } try { // TODO : move all returns to else branch of property descriptor handling
if ( object instanceof Resource ) { Resource < ? > resource = ( Resource < ? > ) object ; objectNode . addLinks ( resource . getLinks ( ) ) ; toUberData ( objectNode , resource . getContent ( ) ) ; return ; } else if ( object instanceof Resources ) { Resources < ? > resources = ( Resources < ? > ) object ; // TODO set name using EVO see HypermediaSupportBeanDefinitionRegistrar
objectNode . addLinks ( resources . getLinks ( ) ) ; Collection < ? > content = resources . getContent ( ) ; toUberData ( objectNode , content ) ; return ; } else if ( object instanceof ResourceSupport ) { ResourceSupport resource = ( ResourceSupport ) object ; objectNode . addLinks ( resource . getLinks ( ) ) ; // wrap object attributes below to avoid endless loop
} else if ( object instanceof Collection ) { Collection < ? > collection = ( Collection < ? > ) object ; for ( Object item : collection ) { // TODO name must be repeated for each collection item
UberNode itemNode = new UberNode ( ) ; objectNode . addData ( itemNode ) ; toUberData ( itemNode , item ) ; } return ; } if ( object instanceof Map ) { Map < ? , ? > map = ( Map < ? , ? > ) object ; for ( Entry < ? , ? > entry : map . entrySet ( ) ) { String key = entry . getKey ( ) . toString ( ) ; Object content = entry . getValue ( ) ; Object value = getContentAsScalarValue ( content ) ; UberNode entryNode = new UberNode ( ) ; objectNode . addData ( entryNode ) ; entryNode . setName ( key ) ; if ( value != null ) { entryNode . setValue ( value ) ; } else { toUberData ( entryNode , content ) ; } } } else { Map < String , PropertyDescriptor > propertyDescriptors = PropertyUtils . getPropertyDescriptors ( object ) ; for ( PropertyDescriptor propertyDescriptor : propertyDescriptors . values ( ) ) { String name = propertyDescriptor . getName ( ) ; if ( filtered . contains ( name ) ) { continue ; } UberNode propertyNode = new UberNode ( ) ; Object content = propertyDescriptor . getReadMethod ( ) . invoke ( object ) ; if ( isEmptyCollectionOrMap ( content , propertyDescriptor . getPropertyType ( ) ) ) { continue ; } Object value = getContentAsScalarValue ( content ) ; propertyNode . setName ( name ) ; objectNode . addData ( propertyNode ) ; if ( value != null ) { // for each scalar property of a simple bean , add valuepair nodes to data
propertyNode . setValue ( value ) ; } else { toUberData ( propertyNode , content ) ; } } Field [ ] fields = object . getClass ( ) . getFields ( ) ; for ( Field field : fields ) { String name = field . getName ( ) ; if ( ! propertyDescriptors . containsKey ( name ) ) { Object content = field . get ( object ) ; Class < ? > type = field . getType ( ) ; if ( isEmptyCollectionOrMap ( content , type ) ) { continue ; } UberNode propertyNode = new UberNode ( ) ; Object value = getContentAsScalarValue ( content ) ; propertyNode . setName ( name ) ; objectNode . addData ( propertyNode ) ; if ( value != null ) { // for each scalar property of a simple bean , add valuepair nodes to data
propertyNode . setValue ( value ) ; } else { toUberData ( propertyNode , content ) ; } } } } } catch ( Exception ex ) { throw new RuntimeException ( "failed to transform object " + object , ex ) ; }


signature:
public class UberUtils { /** * Converts single link to uber node .
 * @ param href
 * to use
 * @ param actionDescriptor
 * to use for action and model , never null
 * @ param rels
 * of the link
 * @ return uber link */
public static UberNode toUberLink ( String href , ActionDescriptor actionDescriptor , String ... rels ) { } }

implementation: return toUberLink ( href , actionDescriptor , Arrays . asList ( rels ) ) ;


signature:
public class UberUtils { /** * Converts single link to uber node .
 * @ param href
 * to use
 * @ param actionDescriptor
 * to use for action and model , never null
 * @ param rels
 * of the link
 * @ return uber link */
public static UberNode toUberLink ( String href , ActionDescriptor actionDescriptor , List < String > rels ) { } }

implementation: Assert . notNull ( actionDescriptor , "actionDescriptor must not be null" ) ; UberNode uberLink = new UberNode ( ) ; uberLink . setRel ( rels ) ; PartialUriTemplateComponents partialUriTemplateComponents = new PartialUriTemplate ( href ) . expand ( Collections . < String , Object > emptyMap ( ) ) ; uberLink . setUrl ( partialUriTemplateComponents . toString ( ) ) ; uberLink . setTemplated ( partialUriTemplateComponents . hasVariables ( ) ? Boolean . TRUE : null ) ; uberLink . setModel ( getModelProperty ( href , actionDescriptor ) ) ; if ( actionDescriptor != null ) { RequestMethod requestMethod = RequestMethod . valueOf ( actionDescriptor . getHttpMethod ( ) ) ; uberLink . setAction ( UberAction . forRequestMethod ( requestMethod ) ) ; } return uberLink ;


signature:
public class UberUtils { /** * Renders input fields for bean properties of bean to add or update or patch .
 * @ param uberFields
 * to add to
 * @ param beanType
 * to render
 * @ param annotatedParameters
 * which describes the method
 * @ param annotatedParameter
 * which requires the bean
 * @ param currentCallValue
 * sample call value */
private static void recurseBeanCreationParams ( List < UberField > uberFields , Class < ? > beanType , ActionDescriptor annotatedParameters , ActionInputParameter annotatedParameter , Object currentCallValue , String parentParamName , Set < String > knownFields ) { } }

implementation:
// TODO collection , map and object node creation are only describable by an annotation , not via type reflection
if ( ObjectNode . class . isAssignableFrom ( beanType ) || Map . class . isAssignableFrom ( beanType ) || Collection . class . isAssignableFrom ( beanType ) || beanType . isArray ( ) ) { return ; // use @ Input ( include ) to list parameter names , at least ? Or mix with hdiv ' s form builder ?
} try { Constructor [ ] constructors = beanType . getConstructors ( ) ; // find default ctor
Constructor constructor = PropertyUtils . findDefaultCtor ( constructors ) ; // find ctor with JsonCreator ann
if ( constructor == null ) { constructor = PropertyUtils . findJsonCreator ( constructors , JsonCreator . class ) ; } Assert . notNull ( constructor , "no default constructor or JsonCreator found for type " + beanType . getName ( ) ) ; int parameterCount = constructor . getParameterTypes ( ) . length ; if ( parameterCount > 0 ) { Annotation [ ] [ ] annotationsOnParameters = constructor . getParameterAnnotations ( ) ; Class [ ] parameters = constructor . getParameterTypes ( ) ; int paramIndex = 0 ; for ( Annotation [ ] annotationsOnParameter : annotationsOnParameters ) { for ( Annotation annotation : annotationsOnParameter ) { if ( JsonProperty . class == annotation . annotationType ( ) ) { JsonProperty jsonProperty = ( JsonProperty ) annotation ; // TODO use required attribute of JsonProperty for required fields
String paramName = jsonProperty . value ( ) ; Class parameterType = parameters [ paramIndex ] ; Object propertyValue = PropertyUtils . getPropertyOrFieldValue ( currentCallValue , paramName ) ; MethodParameter methodParameter = new MethodParameter ( constructor , paramIndex ) ; addUberFieldsForMethodParameter ( uberFields , methodParameter , annotatedParameter , annotatedParameters , parentParamName , paramName , parameterType , propertyValue , knownFields ) ; paramIndex ++ ; // increase for each @ JsonProperty
} } } Assert . isTrue ( parameters . length == paramIndex , "not all constructor arguments of @JsonCreator " + constructor . getName ( ) + " are annotated with @JsonProperty" ) ; } Set < String > knownConstructorFields = new HashSet < String > ( uberFields . size ( ) ) ; for ( UberField sirenField : uberFields ) { knownConstructorFields . add ( sirenField . getName ( ) ) ; } // TODO support Option provider by other method args ?
Map < String , PropertyDescriptor > propertyDescriptors = PropertyUtils . getPropertyDescriptors ( beanType ) ; // add input field for every setter
for ( PropertyDescriptor propertyDescriptor : propertyDescriptors . values ( ) ) { final Method writeMethod = propertyDescriptor . getWriteMethod ( ) ; String propertyName = propertyDescriptor . getName ( ) ; if ( writeMethod == null || knownFields . contains ( parentParamName + propertyName ) ) { continue ; } final Class < ? > propertyType = propertyDescriptor . getPropertyType ( ) ; Object propertyValue = PropertyUtils . getPropertyOrFieldValue ( currentCallValue , propertyName ) ; MethodParameter methodParameter = new MethodParameter ( propertyDescriptor . getWriteMethod ( ) , 0 ) ; addUberFieldsForMethodParameter ( uberFields , methodParameter , annotatedParameter , annotatedParameters , parentParamName , propertyName , propertyType , propertyValue , knownConstructorFields ) ; } } catch ( Exception e ) { throw new RuntimeException ( "Failed to write input fields for constructor" , e ) ; }


signature:
public class AffordanceBuilderFactory { /** * Returns { @ link ActionInputParameter } s contained in the method link .
 * @ param annotation to inspect
 * @ param method must not be { @ literal null } .
 * @ param arguments to the method link
 * @ return maps parameter names to parameter info */
private static Map < String , ActionInputParameter > getActionInputParameters ( Class < ? extends Annotation > annotation , Method method , Object ... arguments ) { } }

implementation: Assert . notNull ( method , "MethodInvocation must not be null!" ) ; MethodParameters parameters = new MethodParameters ( method ) ; Map < String , ActionInputParameter > result = new HashMap < String , ActionInputParameter > ( ) ; for ( MethodParameter parameter : parameters . getParametersWith ( annotation ) ) { final int parameterIndex = parameter . getParameterIndex ( ) ; final Object argument ; if ( parameterIndex < arguments . length ) { argument = arguments [ parameterIndex ] ; } else { argument = null ; } ActionInputParameter inputParameter = new SpringActionInputParameter ( parameter , argument ) ; result . put ( inputParameter . getParameterName ( ) , inputParameter ) ; } return result ;


signature:
public class PropertyUtils { /** * TODO move to PropertyUtil and remove current method for propertyDescriptors , cache search results */
public static Object getPropertyOrFieldValue ( Object currentCallValue , String propertyOrFieldName ) { } }

implementation: if ( currentCallValue == null ) { return null ; } Object propertyValue = getBeanPropertyValue ( currentCallValue , propertyOrFieldName ) ; if ( propertyValue == null ) { propertyValue = getFieldValue ( currentCallValue , propertyOrFieldName ) ; } return propertyValue ;


signature:
public class LdContextFactory { /** * Gets vocab for given bean .
 * @ param bean
 * to inspect for vocab
 * @ param mixInClass
 * for bean which might define a vocab or has a context provider
 * @ return explicitly defined vocab or http : / / schema . org */
public String getVocab ( MixinSource mixinSource , Object bean , Class < ? > mixInClass ) { } }

implementation:
if ( proxyUnwrapper != null ) { bean = proxyUnwrapper . unwrapProxy ( bean ) ; } // determine vocab in context
String classVocab = bean == null ? null : vocabFromClassOrPackage ( bean . getClass ( ) ) ; final Vocab mixinVocab = findAnnotation ( mixInClass , Vocab . class ) ; Object nestedContextProviderFromMixin = getNestedContextProviderFromMixin ( mixinSource , bean , mixInClass ) ; String contextProviderVocab = null ; if ( nestedContextProviderFromMixin != null ) { contextProviderVocab = getVocab ( mixinSource , nestedContextProviderFromMixin , null ) ; } String vocab ; if ( mixinVocab != null ) { vocab = mixinVocab . value ( ) ; // wins over class
} else if ( classVocab != null ) { vocab = classVocab ; // wins over context provider
} else if ( contextProviderVocab != null ) { vocab = contextProviderVocab ; // wins over last resort
} else { vocab = HTTP_SCHEMA_ORG ; } return vocab ;