Package eu.bandm.tools.util.classes
Class DynamicVisitor<C>
java.lang.Object
eu.bandm.tools.util.classes.DynamicVisitor<C>
An abstract base class for reflection-based type case
distinctions. Subclasses should overload the
visit(C, boolean) method with a method void visit(A x) to match
objects of class A. Methods of subclasses will only be
considered as matches for an input if they have -
publicaccess to be retrieved withClass.getMethod(java.lang.String, java.lang.Class<?>...) - the name
visit, and - exactly
one parameter of a subclass of
C.
void do match, but their result
is ignored.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
DynamicVisitor
public DynamicVisitor()
-
-
Method Details
-
visit
Finds the best-matchingvisitmethod for the dynamic type of a given object and invokes it.- Parameters:
x- the input object.total- iftrueandxisnullor no match is found, then nothing is done.- Throws:
IllegalArgumentException- if the matching method throws an exception or cannot be invoked for some reason, or iftotalisfalseand no match is found.NullPointerException- iftotalis false andxisnull.
-