List of usage examples for java.util EnumMap keySet
public Set<K> keySet()
From source file:org.codehaus.mojo.license.AbstractFileHeaderMojo.java
/** * Checks the results of the mojo execution using the {@link #isFailOnMissingHeader()} and * {@link #isFailOnNotUptodateHeader()}. * * @param result processed files by their status * @throws MojoFailureException if check is not ok (some file with no header or to update) *///from w ww . jav a 2 s.c o m protected void checkResults(EnumMap<FileState, Set<File>> result) throws MojoFailureException { Set<FileState> states = result.keySet(); StringBuilder builder = new StringBuilder(); if (isDryRun() && isFailOnMissingHeader() && states.contains(FileState.add)) { List<File> files = FileUtil.orderFiles(result.get(FileState.add)); builder.append("There are ").append(files.size()).append(" file(s) with no header :"); for (File file : files) { builder.append("\n").append(file); } } if (isDryRun() && isFailOnNotUptodateHeader() && states.contains(FileState.update)) { List<File> files = FileUtil.orderFiles(result.get(FileState.update)); builder.append("\nThere are ").append(files.size()).append(" file(s) with header to update:"); for (File file : files) { builder.append("\n").append(file); } } String message = builder.toString(); if (StringUtils.isNotBlank(message)) { throw new MojoFailureException(builder.toString()); } }
From source file:org.jgrades.config.service.UserPreferencesUpdater.java
private void updateRoleData(EnumMap<JgRole, RoleDetails> updatedRoles, EnumMap<JgRole, RoleDetails> persistRoles) throws IllegalAccessException { if (!persistRoles.containsKey(JgRole.ADMINISTRATOR) && !CollectionUtils.isEqualCollection(updatedRoles.keySet(), persistRoles.keySet())) { throw new UserPreferencesException("Roles cannot be modified by user itself"); }// w ww . j a v a2 s . c om Set<Map.Entry<JgRole, RoleDetails>> entries = updatedRoles.entrySet(); for (Map.Entry<JgRole, RoleDetails> entry : entries) { mapNewValues(entry.getValue().getClass(), updatedRoles.get(entry.getKey()), entry.getValue()); } }