|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjfun.util.typing.TypedSuite
public abstract class TypedSuite
Abstract class for implementing a suite of typed elements. When an object is matched against this suite, the most restrictive sub-type is picked. Ambiguity is reported when more than one types match.
The match result is cached for better performance.
Constructor Summary | |
---|---|
protected |
TypedSuite()
|
Method Summary | |
---|---|
protected abstract java.lang.Object |
ambiguity(java.lang.Object arg,
java.lang.Object candidate1,
java.lang.Object candidate2)
This method is called when ambiguity is detected. |
protected java.lang.Object |
getCandidate(java.lang.Object arg)
The main entry of TypedSuite. |
protected abstract java.util.List |
getCandidates()
Provides the candidate elements in the suite. |
protected abstract java.lang.Class |
getType(java.lang.Object candidate)
Get the type of a candidate object. |
protected abstract java.lang.Object |
not_found(java.lang.Object arg)
This method is called when no matching element is found. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected TypedSuite()
Method Detail |
---|
protected abstract java.util.List getCandidates()
protected abstract java.lang.Class getType(java.lang.Object candidate)
candidate
- the candidate object.
protected abstract java.lang.Object not_found(java.lang.Object arg)
arg
- the object to match.
protected abstract java.lang.Object ambiguity(java.lang.Object arg, java.lang.Object candidate1, java.lang.Object candidate2)
arg
- the object to match.candidate1
- the first candidate that matches.candidate2
- the second condidate that matches.
protected java.lang.Object getCandidate(java.lang.Object arg)
The internal cache is consulted first, if an matching entry is found, it is returned.
When no entry is found in cache, the candidates are investigated one by one.
not_found(Object)
is called if no matching element is found;
ambiguity(Object, Object, Object)
is called if ambiguity is detected.
The result is finally cached in the internal cache.
arg
- the object to be matched.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |