net.sourceforge.hiveutils.util
Class ClassMatcher

java.lang.Object
  extended by net.sourceforge.hiveutils.util.ClassMatcher

public class ClassMatcher
extends java.lang.Object

Utility class to check if the class of an object is a subclass of one class in a list.

Author:
Jean-Francois Poilpret

Constructor Summary
ClassMatcher()
           
 
Method Summary
 java.lang.Object get(java.lang.Object o)
          Search if an object is an instance of one of the classes added to this ClassMatcher.
 void put(java.lang.Class clazz, java.lang.Object value)
          Add a class to the list, associated with a value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassMatcher

public ClassMatcher()
Method Detail

put

public void put(java.lang.Class clazz,
                java.lang.Object value)
Add a class to the list, associated with a value.

Parameters:
clazz - Class to be added to the list
value - value to be returned (by get() when the passed object is an instance of that class.

get

public java.lang.Object get(java.lang.Object o)
Search if an object is an instance of one of the classes added to this ClassMatcher. For the first class in the list that is a superclass of the passed object, the matching value is returned. If there is no such class in the list, then null is returned.

Parameters:
o - the object to check against the list of classes
Returns:
the value associated with the first class in the list that is a superclass of o