List of usage examples for java.util EnumSet copyOf
public static <E extends Enum<E>> EnumSet<E> copyOf(Collection<E> c)
From source file:org.squashtest.tm.service.internal.chart.ColumnPrototypeModification.java
@SuppressWarnings("unchecked") private Set<EntityType> findTypeToRemove(Entry<Long, List<CustomFieldBinding>> entry) { List<CustomFieldBinding> allBinding = cufBindingDao .findAllByCustomFieldIdOrderByPositionAsc(entry.getKey()); allBinding.removeAll(entry.getValue()); Set<EntityType> remainingType = CollectionUtils.isEmpty(allBinding) ? EnumSet.noneOf(EntityType.class) : EnumSet.copyOf(CollectionUtils.collect(allBinding, TYPE_COLLECTOR)); Set<EntityType> typeToRemove = EnumSet.copyOf(CollectionUtils.collect(entry.getValue(), TYPE_COLLECTOR)); typeToRemove.removeAll(remainingType); return typeToRemove; }
From source file:com.alliander.osgp.webdevicesimulator.domain.entities.Device.java
public String getEventNotifications() { String returnValue = ""; final List<EventNotificationType> events = new ArrayList<EventNotificationType>(); if (this.eventNotifications != null && this.eventNotifications > 0) { for (final EventNotificationType event : EventNotificationType.values()) { if ((this.eventNotifications & (1 << event.ordinal())) != 0) { events.add(event);//from ww w . ja v a 2 s. co m } } if (!events.isEmpty()) { returnValue = Joiner.on(",").join(EnumSet.copyOf(events)); } } return returnValue; }
From source file:com.healthcit.cacure.businessdelegates.LdapUserManager.java
public EnumSet<RoleCode> getCurrentUserRoleCodes() { ArrayList<RoleCode> userRoleCodes = new ArrayList<Role.RoleCode>(); Collection<GrantedAuthority> currentUserRoles1 = SecurityContextHolder.getContext().getAuthentication() .getAuthorities();/*from w w w . j av a2 s.c om*/ for (GrantedAuthority currentUserRoles : currentUserRoles1) { userRoleCodes.add(RoleCode.valueOf(currentUserRoles.getAuthority())); } return EnumSet.copyOf(userRoleCodes); }
From source file:org.janusgraph.diskstorage.configuration.ConfigOption.java
public static EnumSet<Type> getManagedTypes() { return EnumSet.copyOf(managedTypes); }
From source file:com.healthcit.cacure.businessdelegates.UserManager.java
public EnumSet<RoleCode> getCurrentUserRoleCodes() { UserCredentials currentUser = getCurrentUser(); List<Role> currentUserRoles = userManagerDao.getUserRoles(currentUser); ArrayList<RoleCode> userRoleCodes = new ArrayList<Role.RoleCode>(); for (Role userRole : currentUserRoles) { userRoleCodes.add(userRole.getRoleCode()); }//from ww w. jav a 2 s .c om return EnumSet.copyOf(userRoleCodes); }
From source file:org.photovault.imginfo.CreateCopyImageCommand.java
/** Execute the command. /*from w w w . j a va 2 s. co m*/ @throws CommandException If no image suitable for using as a source can be found or if saving the created image does not succeed. */ public void execute() throws CommandException { // Find the image used as source for the new instance PhotoInfoDAO photoDAO = daoFactory.getPhotoInfoDAO(); VolumeDAO volDAO = daoFactory.getVolumeDAO(); photo = photoDAO.findByUUID(photoUuid); Set<ImageOperations> operationsNotApplied = EnumSet.copyOf(operationsToApply); ImageDescriptorBase srcImageDesc = photo.getOriginal(); // Find a suitable image for using as source if the original has not // yet been loaded. if (img == null) { ImageFile srcImageFile = srcImageDesc.getFile(); File src = srcImageFile.findAvailableCopy(); if (src == null && !createFromOriginal) { srcImageDesc = photo.getPreferredImage(EnumSet.noneOf(ImageOperations.class), operationsToApply, maxWidth, maxHeight, Integer.MAX_VALUE, Integer.MAX_VALUE); if (srcImageDesc != null) { srcImageFile = srcImageDesc.getFile(); src = srcImageFile.findAvailableCopy(); operationsNotApplied.removeAll(((CopyImageDescriptor) srcImageDesc).getAppliedOperations()); } } if (src == null) { throw new CommandException("No suitable image file found"); } // Create the image for the instance PhotovaultImageFactory imgFactory = new PhotovaultImageFactory(); try { img = imgFactory.create(src, false, false); } catch (PhotovaultException ex) { throw new CommandException(ex.getMessage()); } } if (operationsNotApplied.contains(ImageOperations.CROP)) { img.setCropBounds(photo.getCropBounds()); img.setRotation(photo.getPrefRotation()); } if (operationsNotApplied.contains(ImageOperations.COLOR_MAP)) { ChannelMapOperation channelMap = photo.getColorChannelMapping(); if (channelMap != null) { img.setColorAdjustment(channelMap); } } if (operationsNotApplied.contains(ImageOperations.COLOR_MAP) && img instanceof RawImage) { RawImage ri = (RawImage) img; ri.setRawSettings(photo.getRawSettings()); } RenderedImage renderedDst = img.getRenderedImage(maxWidth, maxHeight, lowQualityAllowed); // Determine correct file name for the image & save it if (volumeUuid != null) { VolumeBase vol = volDAO.findById(volumeUuid, false); dstFile = vol.getInstanceName(photo, "jpg"); } if (dstFile == null) { throw new CommandException("Either destination file or volume must be specified"); } ImageFileDAO ifDAO = daoFactory.getImageFileDAO(); ImageFile dstImageFile = new ImageFile(); ifDAO.makePersistent(dstImageFile); CopyImageDescriptor dstImage = new CopyImageDescriptor(dstImageFile, "image#0", photo.getOriginal()); ImageDescriptorDAO idDAO = daoFactory.getImageDescriptorDAO(); idDAO.makePersistent(dstImage); if (operationsToApply.contains(ImageOperations.COLOR_MAP)) { dstImage.setColorChannelMapping(photo.getColorChannelMapping()); } if (operationsToApply.contains(ImageOperations.CROP)) { dstImage.setCropArea(photo.getCropBounds()); dstImage.setRotation(photo.getPrefRotation()); } if (operationsToApply.contains(ImageOperations.RAW_CONVERSION)) { dstImage.setRawSettings(photo.getRawSettings()); } dstImage.setWidth(renderedDst.getWidth()); dstImage.setHeight(renderedDst.getHeight()); ((CopyImageDescriptor) dstImageFile.getImages().get("image#0")).setOriginal(photo.getOriginal()); byte[] xpmData = createXMPMetadata(dstImageFile); try { saveImage(dstFile, renderedDst, xpmData); } catch (PhotovaultException ex) { throw new CommandException(ex.getMessage()); } finally { img.dispose(); } /* Check if the resulting image file is already known & create a new one if not */ byte[] hash = ImageFile.calcHash(dstFile); dstImageFile.setHash(hash); /* Store location of created file in database */ if (volume != null) { dstImageFile.addLocation(volume.getFileLocation(dstFile)); } /* Ensure that the photo is initialized in memory as it is used as a detached object after closing our persistence context. */ if (!photo.hasThumbnail()) { log.error("No valid thumbnail available!!!"); } }
From source file:org.lockss.exporter.kbart.TestKbartExporter.java
/** * A callback for the exporter instance. The testing is done here. We * check that the list of values is valid - not null, and with some sensible * values for essential fields title id, issn, eissn. * Then we check that none of the other fields are null. * /*from w w w .j av a2 s . c o m*/ * @param vals list of values from the title for the exporter's fields */ protected void checkTitle(List<String> vals, KbartTitle title) { assertNotNull(vals); assertNotNull(title); // No field should be empty if omitEmptyFields is on if (omitEmptyFields) { for (String s : vals) { assertFalse(StringUtil.isNullString(s)); } } // Should have same num of values as the ordering without the empties, // if omitEmptyFields is on EnumSet<Field> flds = EnumSet.copyOf(filter.getColumnOrdering().getFields()); if (omitEmptyFields) flds.removeAll(filter.getEmptyFields()); assertEquals(showHealthRatings ? flds.size() + 1 : flds.size(), vals.size()); // Check the field values in the order specified in the filter int i = 0; for (Field f : filter.getColumnOrdering().getOrderedFields()) { String s = title.getField(f); if (omitEmptyFields && StringUtil.isNullString(s)) continue; assertEquals(vals.get(i++), s); } }
From source file:org.pentaho.platform.scheduler2.quartz.SchedulerOutputPathResolver.java
private boolean isPermitted(final String path) { try {/*from ww w . j a v a2 s . c o m*/ return getRepository().hasAccess(path, EnumSet.copyOf(permissions)); } catch (Exception e) { logger.warn(e.getMessage(), e); } return false; }
From source file:fr.ritaly.dungeonmaster.ai.CreatureManager.java
/** * Returns the sectors occupied by creatures. * * @return a set of sectors. Never returns null. */// w w w.ja v a 2s . c om public EnumSet<Sector> getOccupiedSectors() { return (creatures != null) ? EnumSet.copyOf(creatures.keySet()) : EnumSet.noneOf(Sector.class); }
From source file:jails.http.HttpHeaders.java
/** * Return the set of allowed {@link HttpMethod HTTP methods}, as specified by the {@code Allow} header. * <p>Returns an empty set when the allowed methods are unspecified. * @return the allowed methods// w ww .ja va 2 s .c o m */ public Set<HttpMethod> getAllow() { String value = getFirst(ALLOW); if (value != null) { List<HttpMethod> allowedMethod = new ArrayList<HttpMethod>(5); String[] tokens = value.split(",\\s*"); for (String token : tokens) { allowedMethod.add(HttpMethod.valueOf(token)); } return EnumSet.copyOf(allowedMethod); } else { return EnumSet.noneOf(HttpMethod.class); } }