private void checkModifications ( ClassDescriptorDef classDef , String checkLevel ) throws ConstraintException { if ( CHECKLEVEL_NONE . equals ( checkLevel ) ) { return ; } HashMap features = new HashMap ( ) ; FeatureDescriptorDef def ; for ( Iterator it = classDef . getFields ( ) ; it . hasNext ( ) ; ) { def = ( FeatureDescriptorDef ) it . next ( ) ; features . put ( def . getName ( ) , def ) ; } for ( Iterator it = classDef . getReferences ( ) ; it . hasNext ( ) ; ) { def = ( FeatureDescriptorDef ) it . next ( ) ; features . put ( def . getName ( ) , def ) ; } for ( Iterator it = classDef . getCollections ( ) ; it . hasNext ( ) ; ) { def = ( FeatureDescriptorDef ) it . next ( ) ; features . put ( def . getName ( ) , def ) ; } // now checking the modifications Properties mods ; String modName ; String propName ; for ( Iterator it = classDef . getModificationNames ( ) ; it . hasNext ( ) ; ) { modName = ( String ) it . next ( ) ; if ( ! features . containsKey ( modName ) ) { throw new ConstraintException ( "Class " + classDef . getName ( ) + " contains a modification for an unknown feature " + modName ) ; } def = ( FeatureDescriptorDef ) features . get ( modName ) ; if ( def . getOriginal ( ) == null ) { throw new ConstraintException ( "Class " + classDef . getName ( ) + " contains a modification for a feature " + modName + " that is not inherited but defined in the same class" ) ; } // checking modification mods = classDef . getModification ( modName ) ; for ( Iterator propIt = mods . keySet ( ) . iterator ( ) ; propIt . hasNext ( ) ; ) { propName = ( String ) propIt . next ( ) ; if ( ! PropertyHelper . isPropertyAllowed ( def . getClass ( ) , propName ) ) { throw new ConstraintException ( "The modification of attribute " + propName + " in class " + classDef . getName ( ) + " is not applicable to the feature " + modName ) ; } } } }
Checks that the modified features exist .