List of usage examples for java.util LinkedHashSet isEmpty
boolean isEmpty();
From source file:com.janrain.backplane2.server.Scope.java
public boolean isAuthorizationRequired() { for (BackplaneMessage.Field scopeKey : scopes.keySet()) { LinkedHashSet<String> values = scopes.get(scopeKey); if (scopeKey.getScopeType() == ScopeType.AUTHZ_REQ && values != null && !values.isEmpty()) return true; }//from ww w . j a v a2s . c o m return false; }
From source file:com.ge.predix.acs.service.policy.evaluation.PolicyEvaluationServiceImpl.java
LinkedHashSet<PolicySet> filterPolicySetsByPriority(final String subjectIdentifier, final String uri, final List<PolicySet> allPolicySets, final LinkedHashSet<String> policySetsEvaluationOrder) throws IllegalArgumentException { if (policySetsEvaluationOrder.isEmpty()) { if (allPolicySets.size() > 1) { LOGGER.error(String.format( "Found more than one policy set during policy evaluation and " + "no evaluation order is provided. subjectIdentifier='%s', resourceURI='%s'", subjectIdentifier, uri)); throw new IllegalArgumentException("More than one policy set exists for this zone. " + "Please provide an ordered list of policy set names to consider for this evaluation and " + "resubmit the request."); } else {// w w w. j a va2s.c o m return allPolicySets.stream().collect(Collectors.toCollection(LinkedHashSet::new)); } } Map<String, PolicySet> allPolicySetsMap = allPolicySets.stream() .collect(Collectors.toMap(PolicySet::getName, Function.identity())); LinkedHashSet<PolicySet> filteredPolicySets = new LinkedHashSet<PolicySet>(); for (String policySetId : policySetsEvaluationOrder) { PolicySet policySet = allPolicySetsMap.get(policySetId); if (policySet == null) { LOGGER.error("No existing policy set matches policy set in the evaluation order of the request. " + "Subject: " + subjectIdentifier + ", Resource: " + uri); throw new IllegalArgumentException( "No existing policy set matches policy set in the evaluaion order of the request. " + "Please review the policy evauation order and resubmit the request."); } else { filteredPolicySets.add(policySet); } } return filteredPolicySets; }
From source file:com.janrain.backplane2.server.Scope.java
/** * @return multiple, individual scopes for which authorization is required (one value per returned Scope) *//*from w ww. j a va 2 s . c o m*/ public List<Scope> getAuthReqScopes() { List<Scope> authReqScopes = new ArrayList<Scope>(); for (BackplaneMessage.Field scopeKey : scopes.keySet()) { LinkedHashSet<String> values = scopes.get(scopeKey); if (scopeKey.getScopeType() == ScopeType.AUTHZ_REQ && values != null && !values.isEmpty()) { for (String value : values) { authReqScopes.add(new Scope(scopeKey, value)); } } } return authReqScopes; }
From source file:net.famzangl.minecraft.minebot.ai.command.CommandRegistry.java
public String[] fillTabComplete(MinebotNetHandler minebotNetHandler, String[] serverResponse, String lastSendTabComplete) { String command = getCommandId(lastSendTabComplete); LinkedHashSet<String> res = new LinkedHashSet<String>(); for (String c : commandTable.keySet()) { if (c.startsWith(command)) { res.add("/" + c); }//from w w w . java 2s . co m } if (res.isEmpty()) return serverResponse; res.addAll(Arrays.asList(serverResponse)); return res.toArray(new String[0]); }
From source file:org.objectweb.proactive.extensions.dataspaces.vfs.VFSSpacesMountManagerImpl.java
/** * Removes the/*from w w w.j av a2 s . c o m*/ * @param spacePart * @param spaceRootFOUri */ private void removeSpaceRootUri(DataSpacesURI spacePart, String spaceRootFOUri) { LinkedHashSet<String> allRootUris = accessibleFileObjectUris.get(spacePart); allRootUris.remove(spaceRootFOUri); if (allRootUris.isEmpty()) { accessibleFileObjectUris.remove(spacePart); } else { accessibleFileObjectUris.put(spacePart, allRootUris); } }
From source file:com.spotify.hamcrest.jackson.IsJsonObject.java
@Override protected boolean matchesNode(ObjectNode node, Description mismatchDescription) { LinkedHashSet<String> mismatchedKeys = new LinkedHashSet<>(); for (Map.Entry<String, Matcher<? super JsonNode>> entryMatcher : entryMatchers.entrySet()) { final String key = entryMatcher.getKey(); final Matcher<? super JsonNode> valueMatcher = entryMatcher.getValue(); final JsonNode value = node.path(key); if (!valueMatcher.matches(value)) { mismatchedKeys.add(key);//from w w w. ja v a2 s.c o m } } if (!mismatchedKeys.isEmpty()) { describeMismatches(node, mismatchDescription, mismatchedKeys); return false; } return true; }
From source file:org.fusesource.mop.support.Database.java
public void install(final LinkedHashSet<String> artifiactIds) throws IOException { if (artifiactIds.isEmpty()) { throw new IllegalArgumentException("artifiactIds cannot be empty"); }// w ww . j av a 2s . co m final String mainArtifact = artifiactIds.iterator().next(); assertOpen(); pageFile.tx().execute(new Transaction.Closure<IOException>() { public void execute(Transaction tx) throws IOException { RootEntity root = RootEntity.load(tx); BTreeIndex<String, HashSet<String>> artifacts = root.artifacts.get(tx); BTreeIndex<String, HashSet<String>> artifactIdIndex = root.artifactIdIndex.get(tx); BTreeIndex<String, HashSet<String>> typeIndex = root.typeIndex.get(tx); BTreeIndex<String, HashSet<String>> explicityInstalledArtifacts = root.explicityInstalledArtifacts .get(tx); explicityInstalledArtifacts.put(tx, mainArtifact, new LinkedHashSet<String>(artifiactIds)); for (String id : artifiactIds) { ArtifactId a = ArtifactId.strictParse(id); if (a == null) { throw new IOException("Invalid artifact id: " + id); } HashSet<String> rc = artifacts.get(tx, id); if (rc == null) { rc = new HashSet<String>(); } rc.add(mainArtifact); artifacts.put(tx, id, rc); indexAdd(tx, artifactIdIndex, id, a.getArtifactId()); indexAdd(tx, typeIndex, id, a.getType()); } root.tx_sequence++; root.store(tx); } }); }
From source file:com.redhat.rhn.frontend.action.token.configuration.RankChannelsAction.java
/** * Sets up the rangling widget.//from w w w .j a v a2 s . c om * @param context the request context of the current request * @param form the dynaform related to the current request. * @param set the set holding the channel ids. */ private void setupWidget(RequestContext context, DynaActionForm form, Set<String> set) { LinkedHashSet labelValues = new LinkedHashSet(); populateWidgetLabels(labelValues, context); for (String id : set) { Long ccid = Long.valueOf(id); ConfigChannel channel = ConfigurationFactory.lookupConfigChannelById(ccid); labelValues.add(lv(channel.getName(), channel.getId().toString())); } //set the form variables for the widget to read. form.set(POSSIBLE_CHANNELS, labelValues); if (!labelValues.isEmpty()) { if (form.get(SELECTED_CHANNEL) == null) { String selected = ((LabelValueBean) labelValues.iterator().next()).getValue(); form.set(SELECTED_CHANNEL, selected); } } }
From source file:com.redhat.rhn.frontend.action.configuration.BaseRankChannels.java
/** * Sets up the rangling widget./*from w w w .j av a 2s . c o m*/ * @param context the request context of the current request * @param form the dynaform related to the current request. * @param set the rhnset holding the channel ids. */ protected void setupWidget(RequestContext context, DynaActionForm form, RhnSet set) { User user = context.getCurrentUser(); LinkedHashSet labelValues = new LinkedHashSet(); populateWidgetLabels(labelValues, context); for (Iterator itr = set.getElements().iterator(); itr.hasNext();) { Long ccid = ((RhnSetElement) itr.next()).getElement(); ConfigChannel channel = ConfigurationManager.getInstance().lookupConfigChannel(user, ccid); labelValues.add(lv(channel.getName(), channel.getId().toString())); } //set the form variables for the widget to read. form.set(POSSIBLE_CHANNELS, labelValues); if (!labelValues.isEmpty()) { if (form.get(SELECTED_CHANNEL) == null) { String selected = ((LabelValueBean) labelValues.iterator().next()).getValue(); form.set(SELECTED_CHANNEL, selected); } } }
From source file:com.hp.autonomy.idol.parametricvalues.IdolParametricValuesService.java
@Override public Set<QueryTagInfo> getAllParametricValues(final IdolParametricRequest idolParametricRequest) throws AciErrorException { final Collection<String> fieldNames = new HashSet<>(); fieldNames.addAll(idolParametricRequest.getFieldNames()); if (fieldNames.isEmpty()) { fieldNames.addAll(getTagNames()); }/*from w ww .ja v a 2 s . c om*/ final Set<QueryTagInfo> results; if (fieldNames.isEmpty()) { results = Collections.emptySet(); } else { final AciParameters aciParameters = new AciParameters(TagActions.GetQueryTagValues.name()); aciParameters.add(QueryParams.Combine.name(), CombineParam.Simple); aciParameters.add(QueryParams.Text.name(), idolParametricRequest.getQueryText()); aciParameters.add(QueryParams.FieldText.name(), idolParametricRequest.getFieldText()); aciParameters.add(QueryParams.DatabaseMatch.name(), new Databases(idolParametricRequest.getDatabases())); aciParameters.add(QueryParams.MinDate.name(), formatDate(idolParametricRequest.getMinDate())); aciParameters.add(QueryParams.MaxDate.name(), formatDate(idolParametricRequest.getMaxDate())); aciParameters.add(QueryParams.AnyLanguage.name(), true); aciParameters.add(GetQueryTagValuesParams.DocumentCount.name(), true); aciParameters.add(GetQueryTagValuesParams.MaxValues.name(), MAX_VALUES); aciParameters.add(GetQueryTagValuesParams.FieldName.name(), StringUtils.join(fieldNames.toArray(), ',')); aciParameters.add(GetQueryTagValuesParams.Sort.name(), SortParam.DocumentCount.name()); final GetQueryTagValuesResponseData responseData = contentAciService.executeAction(aciParameters, queryTagValuesResponseProcessor); final List<FlatField> fields = responseData.getField(); results = new LinkedHashSet<>(fields.size()); for (final FlatField field : fields) { final List<JAXBElement<? extends Serializable>> valueElements = field.getValueOrSubvalueOrValues(); final LinkedHashSet<QueryTagCountInfo> values = new LinkedHashSet<>(valueElements.size()); for (final JAXBElement<?> element : valueElements) { if (VALUE_NODE_NAME.equals(element.getName().getLocalPart())) { final TagValue tagValue = (TagValue) element.getValue(); values.add(new QueryTagCountInfo(tagValue.getValue(), tagValue.getCount())); } } final String fieldName = getFieldNameFromPath(field.getName().get(0)); if (!values.isEmpty()) { results.add(new QueryTagInfo(fieldName, values)); } } } return results; }