org.semanticweb.elk.util.collections.chains
Interface Chain<T extends ModifiableLink<T>>

Type Parameters:
T - the types of the elements in the chain
All Superinterfaces:
ModifiableLink<T>
All Known Implementing Classes:
AbstractChain

public interface Chain<T extends ModifiableLink<T>>
extends ModifiableLink<T>

A linked list of elements together with helper functions to find, create if not found, and remove elements in the chain.

Author:
"Yevgeny Kazakov"
See Also:
Matcher

Method Summary
<S extends T>
S
find(Matcher<T,S> matcher)
          Finds the first element in the chain that satisfies the provided Matcher.
<S extends T>
S
getCreate(Matcher<T,S> matcher, ReferenceFactory<T,S> factory)
          Finds an element in the chain satisfies the provided Matcher, or if no such element is found, creates a new element using the provided ReferenceFactory and inserts it into the chain.
<S extends T>
S
remove(Matcher<T,S> descriptor)
          Removes the first element in the chain that satisfies the provided Matcher.
 
Methods inherited from interface org.semanticweb.elk.util.collections.chains.ModifiableLink
next, setNext
 

Method Detail

find

<S extends T> S find(Matcher<T,S> matcher)
Finds the first element in the chain that satisfies the provided Matcher. This function does not modify the chain. If the chain is modified during calling of this function, the behavior of the function is not specified.

Parameters:
matcher - the object describing an element to search for
Returns:
the object contained in the chain that satisfies the provided Matcher or null if no such element is found

getCreate

<S extends T> S getCreate(Matcher<T,S> matcher,
                          ReferenceFactory<T,S> factory)
Finds an element in the chain satisfies the provided Matcher, or if no such element is found, creates a new element using the provided ReferenceFactory and inserts it into the chain. In the letter case, the chain is modified.

Parameters:
matcher - the object describing the element to search for
factory - the factory for creating references
Returns:
the object that satisfies the provided Matcher if found in the chain, or the newly created and inserted element object otherwise

remove

<S extends T> S remove(Matcher<T,S> descriptor)
Removes the first element in the chain that satisfies the provided Matcher. If such element is found, the chain is modified.

Parameters:
descriptor - the object describing the element to search for
Returns:
the removed element, if found, or null if not found


Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.