private static void removeDuplicateContracts ( final Class < ? > type , final Set < Class < ? > > contracts ) { if ( contracts . isEmpty ( ) ) { return ; } // remove interfaces already included in common type (e.g. Number and Serializable) Iterator < Class < ? > > it = contracts . iterator ( ) ; while ( it . hasNext ( ) ) { if ( it . next ( ) . isAssignableFrom ( type ) ) { it . remove ( ) ; } } // remove duplicate interfaces (e.g. List already include Collection and Iterable) it = contracts . iterator ( ) ; while ( it . hasNext ( ) ) { final Class < ? > current = it . next ( ) ; for ( Class < ? > iface : contracts ) { if ( ! current . equals ( iface ) && current . isAssignableFrom ( iface ) ) { it . remove ( ) ; break ; } } } }
After common types resolution we have some base class and set of common interfaces . These interfaces may contain duplicates or be already covered by base class .