Class DynamicVisitor<C>

java.lang.Object
eu.bandm.tools.util.classes.DynamicVisitor<C>

public abstract class DynamicVisitor<C> extends Object
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 Methods with a return type other than void do match, but their result is ignored.
  • Constructor Details

    • DynamicVisitor

      public DynamicVisitor()
  • Method Details

    • visit

      public void visit(C x, boolean total)
      Finds the best-matching visit method for the dynamic type of a given object and invokes it.
      Parameters:
      x - the input object.
      total - if true and x is null or 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 if total is false and no match is found.
      NullPointerException - if total is false and x is null.