void (LanguageLevel level) { try { level = MavenImportUtil.adjustLevelAndNotify(myRootModel.getProject(), level); myRootModel.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(level); } catch (IllegalArgumentException e) { //bad value was stored } }