builder for HashMap

There is no such thing for HashMaps, but you can create an ImmutableMap with a builder: final Map<String, Integer> m = ImmutableMap.<String, Integer>builder(). put(“a”, 1). put(“b”, 2). build(); And if you need a mutable map, you can just feed that to the HashMap constructor. final Map<String, Integer> m = Maps.newHashMap( ImmutableMap.<String, Integer>builder(). put(“a”, 1). put(“b”, … Read more

What are the big improvements between guava and apache equivalent libraries?

First of, as javamonkey79 explained, while Google Guava and Apache Commons do share similar features, they also both have functionality that is absent from their counterpart. Thus, limiting yourself to only one library might be unwise. That being said, if I had to choose, I’d opt to use Guava, keeping Apache Commons around for the … Read more

Interface/enum listing standard mime-type constants

From https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/MediaType.html : staticjava.lang.String APPLICATION_ATOM_XML “application/atom+xml” staticMediaType APPLICATION_ATOM_XML_TYPE “application/atom+xml” staticjava.lang.String APPLICATION_FORM_URLENCODED “application/x-www-form-urlencoded” staticMediaType APPLICATION_FORM_URLENCODED_TYPE “application/x-www-form-urlencoded” staticjava.lang.String APPLICATION_JSON “application/json” staticMediaType APPLICATION_JSON_TYPE “application/json” staticjava.lang.String APPLICATION_OCTET_STREAM “application/octet-stream” staticMediaType APPLICATION_OCTET_STREAM_TYPE “application/octet-stream” staticjava.lang.String APPLICATION_SVG_XML “application/svg+xml” staticMediaType APPLICATION_SVG_XML_TYPE “application/svg+xml” staticjava.lang.String APPLICATION_XHTML_XML “application/xhtml+xml” staticMediaType APPLICATION_XHTML_XML_TYPE “application/xhtml+xml” staticjava.lang.String APPLICATION_XML “application/xml” staticMediaType APPLICATION_XML_TYPE “application/xml” staticjava.lang.String MEDIA_TYPE_WILDCARD The value of a type or subtype wildcard: … Read more

initializing a Guava ImmutableMap

Notice that your error message only contains five K, V pairs, 10 arguments total. This is by design; the ImmutableMap class provides six different of() methods, accepting between zero and five key-value pairings. There is not an of(…) overload accepting a varags parameter because K and V can be different types. You want an ImmutableMap.Builder: … Read more

Google Guava vs. Apache Commons [closed]

In my opinion the better choice is Guava (formerly known as Google collections): it’s more modern (has generics) it absolutely follows the Collections API requirements it’s actively maintained CacheBuilder and it’s predecessor MapMaker are just plain awesome Apache Commons Collections is a good library as well, but it has long failed to provide a generics-enabled … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)