E - Argument typeR - Return typepublic interface ReflectiveVisitDispatcher<R extends ReflectiveVisitor,E>
Type parameter 'R' is the base class of visitoR class; type parameter 'E' is the base class of visiteE class.
TODO: obsolete ReflectUtil.lookupVisitMethod(java.lang.Class<?>, java.lang.Class<?>, java.lang.String), and use caching in
implementing that method.
| Modifier and Type | Method and Description |
|---|---|
boolean |
invokeVisitor(R visitor,
E visitee,
String visitMethodName)
Implements the
Glossary.VISITOR_PATTERN via
reflection. |
Method |
lookupVisitMethod(Class<? extends R> visitorClass,
Class<? extends E> visiteeClass,
String visitMethodName)
Looks up a visit method.
|
Method |
lookupVisitMethod(Class<? extends R> visitorClass,
Class<? extends E> visiteeClass,
String visitMethodName,
List<Class> additionalParameterTypes)
Looks up a visit method taking additional parameters beyond the
overloaded visitee type.
|
Method lookupVisitMethod(Class<? extends R> visitorClass, Class<? extends E> visiteeClass, String visitMethodName, List<Class> additionalParameterTypes)
visitorClass - class of object whose visit method is to be
invokedvisiteeClass - class of object to be passed as a parameter
to the visit methodvisitMethodName - name of visit methodadditionalParameterTypes - list of additional parameter typesMethod lookupVisitMethod(Class<? extends R> visitorClass, Class<? extends E> visiteeClass, String visitMethodName)
visitorClass - class of object whose visit method is to be invokedvisiteeClass - class of object to be passed as a parameter to the
visit methodvisitMethodName - name of visit methodboolean invokeVisitor(R visitor, E visitee, String visitMethodName)
Glossary.VISITOR_PATTERN via
reflection. The basic technique is taken from a
Javaworld article. For an example of how to use it, see
ReflectVisitorTest.
Visit method lookup follows the same rules as if compile-time resolution for VisitorClass.visit(VisiteeClass) were performed. An ambiguous match due to multiple interface inheritance results in an IllegalArgumentException. A non-match is indicated by returning false.
visitor - object whose visit method is to be invokedvisitee - object to be passed as a parameter to the visit
methodvisitMethodName - name of visit method, e.g. "visit"Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.