Guava ImmutableMultimap.Builder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava ImmutableMultimap.Builder class.

This code example shows how to use the following methods:build, put
   @Override 
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      checkArgument(input instanceof ResourceLimit, "this binder is only valid for ResourceLimit");
      ResourceLimit limit = (ResourceLimit) input;
      Builder<String, String> builder = ImmutableMultimap.<String, String> builder();
      builder.put("resourcetype", limit.getResourceType().getCode() + "");
      builder.put("account", limit.getAccount());
      builder.put("domainid", limit.getDomainId());
      builder.put("max", limit.getMax() + "");
      return (R) request.toBuilder().replaceQueryParams(builder.build()).build();
   } 
} 

8
CodeRank
This code example shows how to use the following methods:build, put, putAll
   public static <K, V> Multimap<K, V> replaceValue(Multimap<K, V> fromMultimap, final K key, final V value) {
      checkNotNull(fromMultimap, "input multimap");
      checkNotNull(key, "key");
      checkNotNull(value, "value");
      return ImmutableMultimap.<K, V>builder()
                              .putAll(withoutKey(fromMultimap, key))
                              .put(key, value).build();
   } 
    
   public static <K, V> Multimap<K, V> replaceEntries(Multimap<K, V> fromMultimap, Multimap<K, V> updates) {
      checkNotNull(fromMultimap, "input multimap");
      checkNotNull(updates, "updates");
      return ImmutableMultimap.<K, V>builder()
                              .putAll(withoutKeys(fromMultimap, updates.keySet()))
                              .putAll(updates).build();
   } 
    
   public static <K, V> Multimap<K, V> withoutKey(Multimap<K, V> fromMultimap, K key) {
      return Multimaps.<K, V> filterKeys(fromMultimap, Predicates.not(Predicates.equalTo(key)));
   } 

8
CodeRank
This code example shows how to use the following methods:build, put
   @Override 
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      checkArgument(input instanceof SnapshotPolicySchedule, "this binder is only valid for SnapshotPolicySchedule");
      SnapshotPolicySchedule schedule = SnapshotPolicySchedule.class.cast(input);
      Builder<String, String> builder = ImmutableMultimap.<String, String> builder();
      builder.put("intervaltype", schedule.getInterval().toString());
      builder.put("schedule", schedule.getTime().toString());
      return (R) request.toBuilder().replaceQueryParams(builder.build()).build();
   } 
} 

8
CodeRank
This code example shows how to use the following methods:build, put
   @Override 
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      checkArgument(input instanceof TemplateMetadata, "this binder is only valid for TemplateMetadata");
      TemplateMetadata metadata = (TemplateMetadata) input;
      Builder<String, String> builder = ImmutableMultimap.<String, String>builder();
      builder.put("name", metadata.getName());
      builder.put("ostypeid", metadata.getOsTypeId());
      builder.put("displaytext", metadata.getDisplayText());
      if (metadata.getSnapshotId() != null) {
	      builder.put("snapshotid", metadata.getSnapshotId());
      } 
      if (metadata.getVolumeId() != null) {
	      builder.put("volumeid", metadata.getVolumeId());
      } 
      if (metadata.getVirtualMachineId() != null) {
	      builder.put("virtualmachineid", metadata.getVirtualMachineId());
      } 
      if (metadata.isPasswordEnabled() != null) {
	      builder.put("passwordenabled", metadata.isPasswordEnabled().toString());
      } 

7
CodeRank
This code example shows how to use the following methods:build, put
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      checkArgument(checkNotNull(input, "input") instanceof UserIdGroupPair,
            "this binder is only valid for UserIdGroupPair!"); 
      UserIdGroupPair pair = (UserIdGroupPair) input;
      Builder<String, String> builder = ImmutableMultimap.builder();
      builder.put("SourceSecurityGroupOwnerId", pair.getUserId());
      builder.put("SourceSecurityGroupName", pair.getGroupName());
      return (R) request.toBuilder().replaceFormParams(builder.build()).build();
   } 
} 

8
CodeRank
This code example shows how to use the following methods:build, put
   @SuppressWarnings("unchecked") 
   @Override 
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      String encodedJson = base64().encode(checkNotNull(input, "json").toString().getBytes(UTF_8));
      Builder<String, String> builder = ImmutableMultimap.builder();
      builder.put("Storage.S3.UploadPolicy", encodedJson);
      String signature = signer.sign(encodedJson);
      builder.put("Storage.S3.UploadPolicySignature", signature);
      return (R) request.toBuilder().replaceFormParams(builder.build()).build();
   } 
} 

8
CodeRank
This code example shows how to use the following methods:build, put
 
      request = metadataPrefixer.bindToRequest(request, md.getUserMetadata());
 
      Builder<String, String> headers = ImmutableMultimap.builder();
      if (md.getCacheControl() != null) {
         headers.put(HttpHeaders.CACHE_CONTROL, md.getCacheControl());
      } 
 
      if (md.getContentMetadata().getContentDisposition() != null) {
         headers.put("Content-Disposition", md.getContentMetadata().getContentDisposition());
      } 
 
      if (md.getContentMetadata().getContentEncoding() != null) {
         headers.put("Content-Encoding", md.getContentMetadata().getContentEncoding());
      } 
      if (md.getContentMetadata().getContentType() != null) {
         headers.put(HttpHeaders.CONTENT_TYPE, md.getContentMetadata().getContentType());
      } else { 
         headers.put(HttpHeaders.CONTENT_TYPE, "binary/octet-stream");
      } 

7
CodeRank
This code example shows how to use the following methods:build
 
   private final Builder<IdAndName, String> regions = ImmutableMultimap.<IdAndName, String> builder();
 
   @Override 
   public Multimap<IdAndName, String> getResult() {
      return regions.build();
   } 
 
   @Override 
   public void startElement(String url, String name, String qName, Attributes attrs) {
      if (equalsOrSuffix(qName, "Region")) {
         Map<String, String> attributes = cleanseAttributes(attrs);
         IdAndName region = IdAndName.create(attributes.get("RegionID"), attributes.get("RegionName"));
         regions.putAll(region, Splitter.on(';').split(attributes.get("TerritoryName")));
      } 
   } 
} 
6
CodeRank
This code example shows how to use the following methods:build, put
 */ 
@GwtCompatible(emulated = true) 
public class ImmutableMultimapTest extends TestCase {
 
  public void testBuilder_withImmutableEntry() { 
    ImmutableMultimap<String, Integer> multimap = new Builder<String, Integer>()
        .put(Maps.immutableEntry("one", 1))
        .build();
    assertEquals(Arrays.asList(1), multimap.get("one"));
  } 
 
  public void testBuilder_withImmutableEntryAndNullContents() { 
    Builder<String, Integer> builder = new Builder<String, Integer>();
    try { 
      builder.put(Maps.immutableEntry("one", (Integer) null));
      fail();
    } catch (NullPointerException expected) {
    } 
    try { 
      builder.put(Maps.immutableEntry((String) null, 1));
5
CodeRank
This code example shows how to use the following methods:build
   private SignRequest filter;
 
   @Test
   void testCreateStringToSign() throws IOException {
      String expects = Strings2.toStringAndClose(getClass().getResourceAsStream("/hashstring.txt"));
      HttpRequest request = newRequest(preconstructedHeaders().build());
      String toSign = filter.createStringToSign(request);
      assertEquals(toSign, expects);
   } 
 
   @Test
   void testSignString() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
      HttpRequest request = newRequest(preconstructedHeaders().build());
      String toSign = filter.createStringToSign(request);
      String signature = filter.signString(toSign);
      assertEquals(signature, EXPECTED_SIGNATURE);
   } 
 
   @Test
   void testFilter() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
5
CodeRank
See Code Examples for Guava ImmutableMultimap.Builder Methods: