List of usage examples for java.util EnumSet noneOf
public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType)
From source file:org.rhq.enterprise.server.perspective.activator.ActivatorHelper.java
public static boolean initResourceActivators(ResourceActivatorsType rawActivators, List<Activator<?>> activators) { if (rawActivators == null) { return false; }// ww w . j a v a 2s . c om // Let our super class init the "common" activators. boolean debugMode = initCommonActivators(rawActivators, activators); List<FacetActivatorType> rawFacetActivators = rawActivators.getFacet(); for (FacetActivatorType rawFacetActivator : rawFacetActivators) { String rawName = rawFacetActivator.getName().toString(); FacetActivator facetActivator = new FacetActivator( ResourceTypeFacet.valueOf(rawName.toUpperCase(Locale.US))); activators.add(facetActivator); } List<ResourcePermissionActivatorType> rawResourcePermissionActivators = rawActivators .getResourcePermission(); for (ResourcePermissionActivatorType rawResourcePermissionActivator : rawResourcePermissionActivators) { String rawName = rawResourcePermissionActivator.getName().toString(); Permission permission = Permission.valueOf(rawName.toUpperCase(Locale.US)); ResourcePermissionActivator resourcePermissionActivator = new ResourcePermissionActivator(permission); activators.add(resourcePermissionActivator); } List<TraitActivatorType> rawTraitActivators = rawActivators.getTrait(); for (TraitActivatorType rawTraitActivator : rawTraitActivators) { String name = rawTraitActivator.getName(); String value = rawTraitActivator.getValue(); TraitActivator traitActivator = new TraitActivator(name, Pattern.compile(value)); activators.add(traitActivator); } List<InventoryActivatorType> rawInventoryActivators = rawActivators.getResourceType(); for (InventoryActivatorType rawInventoryActivator : rawInventoryActivators) { List<ResourceType> rawResourceConditions = rawInventoryActivator.getResource(); List<ResourceConditionSet> resourceConditionSets = new ArrayList<ResourceConditionSet>( rawResourceConditions.size()); for (ResourceType rawResourceCondition : rawResourceConditions) { List<ResourcePermissionActivatorType> rawPermissions = rawResourceCondition.getResourcePermission(); EnumSet<Permission> permissions = EnumSet.noneOf(Permission.class); for (ResourcePermissionActivatorType rawPermission : rawPermissions) { String rawName = rawPermission.getName().toString(); Permission permission = Permission.valueOf(rawName.toUpperCase(Locale.US)); permissions.add(permission); } List<TraitActivatorType> rawTraits = rawResourceCondition.getTrait(); Map<String, Pattern> traits = new HashMap<String, Pattern>(); for (TraitActivatorType rawTraitActivator : rawTraits) { String name = rawTraitActivator.getName(); String value = rawTraitActivator.getValue(); traits.put(name, Pattern.compile(value)); } ResourceConditionSet resourceConditionSet = new ResourceConditionSet( rawResourceCondition.getPlugin(), rawResourceCondition.getType(), permissions, traits); resourceConditionSets.add(resourceConditionSet); } ResourceTypeActivator resourceTypeActivator = new ResourceTypeActivator(resourceConditionSets); activators.add(resourceTypeActivator); } return debugMode; }
From source file:gov.nih.nci.firebird.selenium2.tests.protocol.registration.ReviseReturnedRegistrationFormsTest.java
private void checkFormsAreRevised(FormTypeEnum... forms) { dataSet.reload();//from ww w .j a v a 2 s. c o m registration = dataSet.getInvestigatorRegistration(); EnumSet<FormTypeEnum> revisedFormTypes; if (forms.length == 0) { revisedFormTypes = EnumSet.noneOf(FormTypeEnum.class); } else { revisedFormTypes = EnumSet.copyOf(Arrays.asList(forms)); } checkFormsRevised(revisedFormTypes); EnumSet<FormTypeEnum> notRevisedFormTypes = EnumSet.complementOf(revisedFormTypes); checkFormsNotRevised(notRevisedFormTypes); }
From source file:ws.wamp.jawampa.WampClient.java
/** * Registers a procedure at the router which will afterwards be available * for remote procedure calls from other clients.<br> * The actual registration will only happen after the user subscribes on * the returned Observable. This guarantees that no RPC requests get lost. * Incoming RPC requests will be pushed to the Subscriber via it's * onNext method. The Subscriber can send responses through the methods on * the {@link Request}.<br>//from w w w. j ava 2 s .c om * If the client no longer wants to provide the method it can call * unsubscribe() on the Subscription to unregister the procedure.<br> * If the connection closes onCompleted will be called.<br> * In case of errors during subscription onError will be called. * @param topic The name of the procedure which this client wants to * provide.<br> * Must be valid WAMP URI. * @return An observable that can be used to provide a procedure. */ public Observable<Request> registerProcedure(final String topic) { return this.registerProcedure(topic, EnumSet.noneOf(RegisterFlags.class)); }
From source file:com.janrain.backplane2.server.Token.java
private static Pair<String, EnumSet<TokenSource>> extractToken(String queryString, String requestParam, String authHeader) {/* w w w . j a va 2 s . co m*/ String token = null; EnumSet<TokenSource> foundIn = EnumSet.noneOf(TokenSource.class); if (StringUtils.isNotEmpty(queryString)) { Map<String, String> queryParamsMap = new HashMap<String, String>(); for (String queryParamPair : Arrays.asList(queryString.split("&"))) { String[] nameVal = queryParamPair.split("=", 2); queryParamsMap.put(nameVal[0], nameVal.length > 1 ? nameVal[1] : null); } if (queryParamsMap.containsKey(OAUTH2_ACCESS_TOKEN_PARAM_NAME)) { token = queryParamsMap.get(OAUTH2_ACCESS_TOKEN_PARAM_NAME); foundIn.add(TokenSource.QUERYPARAM); } } if (!foundIn.contains(TokenSource.QUERYPARAM) && requestParam != null) { // query parameter will mask body requestParam extracted by spring with @RequestParameter token = requestParam; foundIn.add(TokenSource.POSTBODY); } int tokenTypeLength = OAUTH2_TOKEN_TYPE_BEARER.length(); if (authHeader != null && authHeader.startsWith(OAUTH2_TOKEN_TYPE_BEARER) && authHeader.length() > tokenTypeLength + 1) { token = authHeader.substring(tokenTypeLength + 1); foundIn.add(TokenSource.AUTHHEADER); } return new Pair<String, EnumSet<TokenSource>>(token, foundIn); }
From source file:com.netflix.genie.server.resources.JobResource.java
/** * Get jobs for given filter criteria.//from www . ja va 2 s . c o m * * @param id id for job * @param name name of job (can be a SQL-style pattern such as HIVE%) * @param userName user who submitted job * @param statuses statuses of jobs to find * @param tags tags for the job * @param clusterName the name of the cluster * @param clusterId the id of the cluster * @param commandName the name of the command run by the job * @param commandId the id of the command run by the job * @param page page number for job * @param limit max number of jobs to return * @param descending Whether the order of the results should be descending or ascending * @param orderBys Fields to order the results by * @return successful response, or one with HTTP error code * @throws GenieException For any error */ @GET @ApiOperation(value = "Find jobs", notes = "Find jobs by the submitted criteria.", response = Job.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "Bad Request"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Job not found"), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid id supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public List<Job> getJobs(@ApiParam(value = "Id of the job.") @QueryParam("id") final String id, @ApiParam(value = "Name of the job.") @QueryParam("name") final String name, @ApiParam(value = "Name of the user who submitted the job.") @QueryParam("userName") final String userName, @ApiParam(value = "Statuses of the jobs to fetch.", allowableValues = "INIT, RUNNING, SUCCEEDED, KILLED, FAILED") @QueryParam("status") final Set<String> statuses, @ApiParam(value = "Tags for the job.") @QueryParam("tag") final Set<String> tags, @ApiParam(value = "Name of the cluster on which the job ran.") @QueryParam("executionClusterName") final String clusterName, @ApiParam(value = "Id of the cluster on which the job ran.") @QueryParam("executionClusterId") final String clusterId, @ApiParam(value = "The page to start on.") @QueryParam("commandName") final String commandName, @ApiParam(value = "Id of the cluster on which the job ran.") @QueryParam("commandId") final String commandId, @ApiParam(value = "The page to start on.") @QueryParam("page") @DefaultValue("0") final int page, @ApiParam(value = "Max number of results per page.") @QueryParam("limit") @DefaultValue("1024") final int limit, @ApiParam(value = "Whether results should be sorted in descending or ascending order. Defaults to descending") @QueryParam("descending") @DefaultValue("true") final boolean descending, @ApiParam(value = "The fields to order the results by. Must not be collection fields. Default is updated.") @QueryParam("orderBy") final Set<String> orderBys) throws GenieException { LOG.info("Called with [id | jobName | userName | statuses | executionClusterName " + "| executionClusterId | page | limit | descending | orderBys]"); LOG.info(id + " | " + name + " | " + userName + " | " + statuses + " | " + tags + " | " + clusterName + " | " + clusterId + " | " + commandName + " | " + commandId + " | " + page + " | " + limit + " | " + descending + " | " + orderBys); Set<JobStatus> enumStatuses = null; if (!statuses.isEmpty()) { enumStatuses = EnumSet.noneOf(JobStatus.class); for (final String status : statuses) { if (StringUtils.isNotBlank(status)) { enumStatuses.add(JobStatus.parse(status)); } } } return this.jobService.getJobs(id, name, userName, enumStatuses, tags, clusterName, clusterId, commandName, commandId, page, limit, descending, orderBys); }
From source file:ru.savvy.jpafilterbuilder.FilterCriteriaBuilder.java
/** * Adds order by expressions to the tail of already existing orders of query * * @param orders/*w w w . j av a2s . co m*/ * @return */ public FilterCriteriaBuilder<T> addOrders(Map<String, Boolean> orders) { for (Map.Entry<String, Boolean> me : orders.entrySet()) { checkFilterValid( new FieldFilter(clearOrderOptions(me.getKey()), "", EnumSet.noneOf(FieldFilter.Option.class)), false); this.orders.put(clearOrderOptions(me.getKey()), me.getValue()); } return this; }
From source file:org.lockss.exporter.kbart.KbartExportFilter.java
/** * An alternative constructor that allows one to specify whether or not to * show columns which are entirely empty. If <code>omitEmptyFields</code> is * true, the <code>emptyFields</code> set is filled with the names of the * empty fields. This is an expensive operation which requires iteration over * potentially all of the titles, so is performed here at construction. * <p>/*w ww.j a v a2 s .c om*/ * Due to this processing, it is not possible to accept an iterator instead of * a list, which would be less memory intensive. * * @param titles the titles to be exported * @param ordering an ordering to impose on the fields of each title * @param omitEmptyFields whether to omit empty field columns from the output */ public KbartExportFilter(List<KbartTitle> titles, ColumnOrdering ordering, boolean omitEmptyFields, boolean omitHeader, boolean excludeNoIdTitles, boolean showHealthRatings) { this.titles = titles; this.columnOrdering = ordering; this.omitEmptyFields = omitEmptyFields; this.omitHeaderRow = omitHeader; this.excludeNoIdTitles = excludeNoIdTitles; this.showHealthRatings = showHealthRatings; // Work out the list of empty fields if necessary this.emptyFields = omitEmptyFields ? findEmptyFields() : EnumSet.noneOf(Field.class); // Create a list of the visible (non-omitted) fields out of the supplied ordering this.visibleColumnOrdering = CustomColumnOrdering.copy(columnOrdering).removeFields(emptyFields); this.rangeFieldsIncludedInDisplay = !CollectionUtil.isDisjoint(visibleColumnOrdering.getFields(), rangeFields); this.idFieldsIncludedInDisplay = !CollectionUtil.isDisjoint(visibleColumnOrdering.getFields(), idFields); }
From source file:org.cosysoft.dcm.tool.FindSCUTool.java
private static EnumSet<QueryOption> queryOptionsOf(FindSCUTool main, CommandLine cl) { EnumSet<QueryOption> queryOptions = EnumSet.noneOf(QueryOption.class); if (cl.hasOption("relational")) queryOptions.add(QueryOption.RELATIONAL); if (cl.hasOption("datetime")) queryOptions.add(QueryOption.DATETIME); if (cl.hasOption("fuzzy")) queryOptions.add(QueryOption.FUZZY); if (cl.hasOption("timezone")) queryOptions.add(QueryOption.TIMEZONE); return queryOptions; }
From source file:forge.game.mana.ManaCostBeingPaid.java
public ManaCostShard getShardToPayByPriority(Iterable<ManaCostShard> payableShards, byte possibleUses) { Set<ManaCostShard> choice = EnumSet.noneOf(ManaCostShard.class); int priority = Integer.MIN_VALUE; for (ManaCostShard toPay : payableShards) { // if m is a better to pay than choice int toPayPriority = getPayPriority(toPay, possibleUses); if (toPayPriority > priority) { priority = toPayPriority;//from w w w. j a va2 s.co m choice.clear(); } if (toPayPriority == priority) { choice.add(toPay); } } if (choice.isEmpty()) { return null; } return Iterables.getFirst(choice, null); }
From source file:nl.mvdr.umvc3replayanalyser.ocr.TesseractOCREngine.java
/** * Matches the given string to a character's name. * /*from ww w. ja v a 2 s .c o m*/ * @param text * text to be matched, should be a Marvel character name * @param possibleCharacters * the characters that text may match, may not be empty * @return the character to whose name the given text is closest * @throws OCRException * in case the matching character cannot be uniquely determined */ private Umvc3Character matchToCharacterName(String text, Set<Umvc3Character> possibleCharacters) throws OCRException { if (log.isDebugEnabled()) { if (possibleCharacters.size() == Umvc3Character.values().length) { log.debug(String.format("Attempting to match %s to the UMvC3 characters", text)); } else { log.debug(String.format("Attempting to match %s to the following characters: %s", text, possibleCharacters)); } } // Compute the minimal Levenshtein distance between the given text and the uppercase character names. int minimalDistance = Integer.MAX_VALUE; Set<Umvc3Character> matchingCharacters = EnumSet.noneOf(Umvc3Character.class); for (Umvc3Character character : possibleCharacters) { int distance = StringUtils.getLevenshteinDistance(character.getName().toUpperCase(), text); if (distance < minimalDistance) { minimalDistance = distance; matchingCharacters.clear(); matchingCharacters.add(character); } else if (distance == minimalDistance) { matchingCharacters.add(character); } } // matchingCharacters is not empty, since there must be at least one character with a distance less than // Integer.MAX_INT. Umvc3Character result; if (1 < matchingCharacters.size()) { // More than one match found. result = handleMultipleMatches(text, minimalDistance, matchingCharacters); } else { // Exactly one match, return it. result = matchingCharacters.iterator().next(); } if (log.isDebugEnabled()) { log.debug(String.format("Match found: %s. levenshtein(%s, %s) = %s", result, result.getName().toUpperCase(), text, "" + minimalDistance)); } return result; }