Code example for ImmutableMap.Builder

Methods: build

0
   private Builder<String, Integer> builder = ImmutableMap.builder();
   private String name;
 
   public Map<String, Integer> getResult() {
      try { 
         return builder.build();
      } finally { 
         builder = ImmutableMap.<String, Integer> builder();
      } 
   } 
 
   @Override 
   public void endElement(String uri, String localName, String qName) {
      if (equalsOrSuffix(qName, "Name")) {
         name = currentOrNull(currentText);
      } else if (equalsOrSuffix(qName, "UsageCount")) {
         builder.put(name, Integer.valueOf(currentOrNull(currentText)));
      } 
      currentText = new StringBuilder();
   }