List of usage examples for com.google.common.collect Multimap containsKey
boolean containsKey(@Nullable Object key);
From source file:adwords.axis.v201506.migration.MigrateToExtensionSettings.java
/** * Gets the site links from a feed./*from w w w .j a v a 2s .co m*/ * * @return a map of feed item ID to SiteLinkFromFeed */ private static Map<Long, SiteLinkFromFeed> getSiteLinksFromFeed(AdWordsServices adWordsServices, AdWordsSession session, Feed feed) throws Exception { // Retrieve the feed's attribute mapping. Multimap<Long, Integer> feedMappings = getFeedMapping(adWordsServices, session, feed, PLACEHOLDER_SITELINKS); Map<Long, SiteLinkFromFeed> feedItems = Maps.newHashMap(); for (FeedItem feedItem : getFeedItems(adWordsServices, session, feed)) { SiteLinkFromFeed siteLinkFromFeed = new SiteLinkFromFeed(); for (FeedItemAttributeValue attributeValue : feedItem.getAttributeValues()) { // Skip this attribute if it hasn't been mapped to a field. if (!feedMappings.containsKey(attributeValue.getFeedAttributeId())) { continue; } for (Integer fieldId : feedMappings.get(attributeValue.getFeedAttributeId())) { switch (fieldId) { case PLACEHOLDER_FIELD_SITELINK_LINK_TEXT: siteLinkFromFeed.text = attributeValue.getStringValue(); break; case PLACEHOLDER_FIELD_SITELINK_URL: siteLinkFromFeed.url = attributeValue.getStringValue(); break; case PLACEHOLDER_FIELD_FINAL_URLS: siteLinkFromFeed.finalUrls = attributeValue.getStringValues(); break; case PLACEHOLDER_FIELD_FINAL_MOBILE_URLS: siteLinkFromFeed.finalMobileUrls = attributeValue.getStringValues(); break; case PLACEHOLDER_FIELD_TRACKING_URL_TEMPLATE: siteLinkFromFeed.trackingUrlTemplate = attributeValue.getStringValue(); break; case PLACEHOLDER_FIELD_LINE_2_TEXT: siteLinkFromFeed.line2 = attributeValue.getStringValue(); break; case PLACEHOLDER_FIELD_LINE_3_TEXT: siteLinkFromFeed.line3 = attributeValue.getStringValue(); break; default: // Ignore attributes that do not map to a predefined placeholder field. break; } } } siteLinkFromFeed.scheduling = feedItem.getScheduling(); feedItems.put(feedItem.getFeedItemId(), siteLinkFromFeed); } return feedItems; }
From source file:com.google.googlejavaformat.java.RemoveUnusedImports.java
private static boolean isUnused(JCCompilationUnit unit, Set<String> usedNames, Multimap<String, Range<Integer>> usedInJavadoc, JCImport importTree, String simpleName) { String qualifier = ((JCFieldAccess) importTree.getQualifiedIdentifier()).getExpression().toString(); if (qualifier.equals("java.lang")) { return true; }/*from w w w .j a va 2 s . com*/ if (unit.getPackageName() != null && unit.getPackageName().toString().equals(qualifier)) { return true; } if (importTree.getQualifiedIdentifier() instanceof JCFieldAccess && ((JCFieldAccess) importTree.getQualifiedIdentifier()).getIdentifier().contentEquals("*")) { return false; } if (usedNames.contains(simpleName)) { return false; } if (usedInJavadoc.containsKey(simpleName)) { return false; } return true; }
From source file:com.eucalyptus.util.dns.DnsResolvers.java
@SuppressWarnings("unchecked") private static void addRRset(Name name, final Message response, Record[] records, final int section) { final Multimap<RequestType, Record> rrsets = LinkedHashMultimap.create(); for (Record r : records) { RequestType type = RequestType.typeOf(r.getType()); rrsets.get(type).addAll(Collections2.filter(Arrays.asList(records), type)); }/*w ww.jav a 2s . co m*/ Predicate<Record> checkNewRecord = new Predicate<Record>() { @Override public boolean apply(Record input) { for (int s = 1; s <= section; s++) { if (response.findRecord(input, s)) { return false; } } return true; } }; if (rrsets.containsKey(RequestType.CNAME)) { for (Record cnames : Iterables.filter(rrsets.removeAll(RequestType.CNAME), checkNewRecord)) { response.addRecord(cnames, section); } } for (Record sectionRecord : Iterables.filter(rrsets.values(), checkNewRecord)) { response.addRecord(sectionRecord, section); } }
From source file:org.ow2.proactive.scheduler.authentication.ManageUsers.java
private static void deleteAccount(UserInfo userInfo, String loginFilePath, String groupFilePath, Properties props, Multimap<String, String> groupsMap) throws ManageUsersException { if (!userInfo.isLoginSet()) { warnWithMessage(PROVIDED_USERNAME + IS_EMPTY_SKIPPING); return;//ww w . ja v a2 s . c om } if (!props.containsKey(userInfo.getLogin())) { warnWithMessage(USER_HEADER + userInfo.getLogin() + DOES_NOT_EXIST_IN_LOGIN_FILE + loginFilePath); } if (!groupsMap.containsKey(userInfo.getLogin())) { warnWithMessage(USER_HEADER + userInfo.getLogin() + DOES_NOT_EXIST_IN_GROUP_FILE + groupFilePath); } props.remove(userInfo.getLogin()); groupsMap.removeAll(userInfo.getLogin()); System.out.println("Deleted user " + userInfo.getLogin()); }
From source file:com.qcadoo.mes.workPlans.pdf.document.operation.grouping.container.util.OrderIdOperationNumberOperationComponentIdMap.java
public boolean containsKey(Long orderId, String operationNumber) { Multimap<String, Long> innerMap = map.get(orderId); return !isEmpty(innerMap) && innerMap.containsKey(operationNumber); }
From source file:org.jclouds.aws.s3.filters.AWSRequestAuthorizeSignatureV4.java
@Override protected HttpRequest signForAuthorizationHeader(HttpRequest request) { /*//ww w . j a va2 s. co m * Only add the Authorization header if the query string doesn't already contain * the 'X-Amz-Signature' parameter, otherwise S3 will fail the request complaining about * duplicate authentication methods. The 'Signature' parameter will be added for signed URLs * with expiration. */ Multimap<String, String> queryMap = queryParser().apply(request.getEndpoint().getQuery()); if (queryMap.containsKey(AMZ_SIGNATURE_PARAM) || queryMap.containsKey(TEMPORARY_SIGNATURE_PARAM)) { return request; } return super.signForAuthorizationHeader(request); }
From source file:org.eclipse.xtend.core.jvmmodel.SyntheticNameClashResolver.java
protected boolean collides(JvmIdentifiableElement element, String currentName, Multimap<String, JvmIdentifiableElement> scope) { if (scope.containsKey(currentName)) { if (element instanceof JvmOperation) { for (JvmIdentifiableElement other : scope.get(currentName)) { if (!(other instanceof JvmOperation) || ((JvmOperation) element).getParameters() .size() == ((JvmOperation) other).getParameters().size()) return true; }/*w ww . ja v a 2 s . c o m*/ return false; } return true; } return false; }
From source file:to.lean.tools.gmail.importer.gmail.GmailSyncer.java
/** * Synchronizes the given list of messages with Gmail. When this operation * completes, all of the messages will appear in Gmail with the same labels * (folers) that they have in the local store. The message state, including * read/unread, will also be synchronized, but might not match exactly if * the message is already in Gmail.// w w w . jav a2 s. c om * * <p>Note that some errors can prevent some messages from being uploaded. * In this case, the failure policy dictates what happens. * * @param messages the list of messages to synchronize. These messages may * or may not already exist in Gmail. * @throws IOException if something goes wrong with the connection */ public void sync(List<LocalMessage> messages) throws IOException { Preconditions.checkState(initialized, "GmailSyncer.init() must be called first"); Multimap<LocalMessage, Message> map = mailbox.mapMessageIds(messages); messages.stream().filter(message -> !map.containsKey(message)).forEach(message -> { try { Message gmailMessage = mailbox.uploadMessage(message); map.put(message, gmailMessage); } catch (GoogleJsonResponseException e) { // Message couldn't be uploaded, but we know why } }); mailbox.fetchExistingLabels(map.values()); mailbox.syncLocalLabelsToGmail(map); }
From source file:org.jclouds.openstack.keystone.v2_0.handlers.RetryOnRenew.java
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { boolean retry = false; // default try {//from w w w .ja v a 2s .c o m switch (response.getStatusCode()) { case 401: // Do not retry on 401 from authentication request Multimap<String, String> headers = command.getCurrentRequest().getHeaders(); if (headers != null && headers.containsKey("X-Auth-User") && headers.containsKey("X-Auth-Key") && !headers.containsKey("X-Auth-Token")) { retry = false; } else { byte[] content = closeClientButKeepContentStream(response); //TODO: what is the error when the session token expires?? if (content != null && new String(content).contains("lease renew")) { logger.debug("invalidating authentication token"); authenticationResponseCache.invalidateAll(); retry = true; } else { retry = false; } } break; } return retry; } finally { releasePayload(response); } }
From source file:org.jclouds.openstack.keystone.v1_1.handlers.RetryOnRenew.java
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { boolean retry = false; // default try {//from ww w .j ava 2s. c om switch (response.getStatusCode()) { case 401: // Do not retry on 401 from authentication request Multimap<String, String> headers = command.getCurrentRequest().getHeaders(); if (headers != null && headers.containsKey(AuthHeaders.AUTH_USER) && headers.containsKey(AuthHeaders.AUTH_KEY) && !headers.containsKey(AuthHeaders.AUTH_TOKEN)) { retry = false; } else { byte[] content = closeClientButKeepContentStream(response); if (content != null && new String(content).contains("lease renew")) { logger.debug("invalidating authentication token"); authenticationResponseCache.invalidateAll(); retry = true; } else { retry = false; } } break; } return retry; } finally { releasePayload(response); } }