Unless you specifically want to check only the first superclass, it would be better to use:
return (action instanceof logic.UserBehavior);
Your method will be better with this:
action.getClass().getSuperClass().name().equals("logic.UserBehavior");
Calling toString() is not a good idea.
Or better yet, as published by Ulrik :
action.getClass().getSuperClass() == logic.UserBehavior.class
Mat
source share