Refactor of comparing abstract types

Implemented equals method to compare types.