LPS-34937 Use instanceof check instead of catching ClassCastException
LPS-34937 Generated
LPS-34937 Only perform instanceof check on equals methods in public classes (manual changes)