private void checkExtents ( ClassDescriptorDef classDef , String checkLevel ) throws ConstraintException { if ( CHECKLEVEL_NONE . equals ( checkLevel ) ) { return ; } HashMap processedClasses = new HashMap ( ) ; InheritanceHelper helper = new InheritanceHelper ( ) ; ClassDescriptorDef curExtent ; boolean canBeRemoved ; for ( Iterator it = classDef . getExtentClasses ( ) ; it . hasNext ( ) ; ) { curExtent = ( ClassDescriptorDef ) it . next ( ) ; canBeRemoved = false ; if ( classDef . getName ( ) . equals ( curExtent . getName ( ) ) ) { throw new ConstraintException ( "The class " + classDef . getName ( ) + " specifies itself as an extent-class" ) ; } else if ( processedClasses . containsKey ( curExtent ) ) { canBeRemoved = true ; } else { try { if ( ! helper . isSameOrSubTypeOf ( curExtent , classDef . getName ( ) , false ) ) { throw new ConstraintException ( "The class " + classDef . getName ( ) + " specifies an extent-class " + curExtent . getName ( ) + " that is not a sub-type of it" ) ; } // now we check whether we already have an extent for a base-class of this extent-class for ( Iterator processedIt = processedClasses . keySet ( ) . iterator ( ) ; processedIt . hasNext ( ) ; ) { if ( helper . isSameOrSubTypeOf ( curExtent , ( ( ClassDescriptorDef ) processedIt . next ( ) ) . getName ( ) , false ) ) { canBeRemoved = true ; break ; } } } catch ( ClassNotFoundException ex ) { // won't happen because we don't use lookup of the actual classes } } if ( canBeRemoved ) { it . remove ( ) ; } processedClasses . put ( curExtent , null ) ; } }
Checks the extents specifications and removes unnecessary entries .