|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.semanticweb.elk.util.collections.chains.AbstractChain<T>
T - The type of elements in the chain.public abstract class AbstractChain<T extends ModifiableLink<T>>
This class provides a skeletal implementation of the Chain interface
to minimize the effort required to implement this interface. Essentially, one
has to provide only the implementation of the Link interface.
| Constructor Summary | |
|---|---|
AbstractChain()
|
|
| Method Summary | ||
|---|---|---|
|
find(Matcher<T,S> matcher)
Finds the first element in the chain that satisfies the provided Matcher. |
|
|
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. |
|
static
|
getMapBackedChain(Map<K,T> map,
K key)
Creates a Chain view of the value associated with the given key
in the given Map. |
|
|
remove(Matcher<T,S> matcher)
Removes the first element in the chain that satisfies the provided Matcher. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.semanticweb.elk.util.collections.chains.ModifiableLink |
|---|
next, setNext |
| Constructor Detail |
|---|
public AbstractChain()
| Method Detail |
|---|
public <S extends T> S find(Matcher<T,S> matcher)
ChainMatcher. 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.
find in interface Chain<T extends ModifiableLink<T>>matcher - the object describing an element to search for
Matcher or null if no such element is found
public <S extends T> S getCreate(Matcher<T,S> matcher,
ReferenceFactory<T,S> factory)
ChainMatcher, 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.
getCreate in interface Chain<T extends ModifiableLink<T>>matcher - the object describing the element to search forfactory - the factory for creating references
Matcher if found
in the chain, or the newly created and inserted element object
otherwisepublic <S extends T> S remove(Matcher<T,S> matcher)
ChainMatcher. If such element is found, the chain is modified.
remove in interface Chain<T extends ModifiableLink<T>>matcher - the object describing the element to search for
null if not found
public static <K,T extends ModifiableLink<T>> Chain<T> getMapBackedChain(Map<K,T> map,
K key)
Chain view of the value associated with the given key
in the given Map. The values of the map must be instances of the
type that can be used in the Chain interface. All operations with
the returned Chain, such as addition or removal, will be
reflected accordingly in the corresponding value in the Map.
map - the Map that backs the datakey - the key for which to return the Chain view of the data
Chain view of the data associated with key in map
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||