{"id":3592,"date":"2017-02-01T11:13:44","date_gmt":"2017-02-01T09:13:44","guid":{"rendered":"http:\/\/www.tutego.de\/blog\/javainsel\/?p=3592"},"modified":"2017-02-01T11:13:44","modified_gmt":"2017-02-01T09:13:44","slug":"google-guava-steigt-endlich-auf-java-8-um","status":"publish","type":"post","link":"https:\/\/www.tutego.de\/blog\/javainsel\/2017\/02\/google-guava-steigt-endlich-auf-java-8-um\/","title":{"rendered":"Google Guava steigt (endlich) auf Java 8 um"},"content":{"rendered":"<p>Die News unter\u00a0<a href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21\">https:\/\/github.com\/google\/guava\/wiki\/Release21<\/a>:<\/p>\n<h2>Significant API additions and changes<\/h2>\n<h3><a id=\"user-content-commonbase\" class=\"anchor\" href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21#commonbase\"><\/a>common.base<\/h3>\n<ul>\n<li><code>Function<\/code>, <code>Predicate<\/code> and <code>Supplier<\/code>: changed to extend the new <code>java.util.function<\/code>interfaces with the same names.<\/li>\n<li><code>Optional<\/code>: added <code>toJavaUtil<\/code> and <code>fromJavaUtil<\/code> methods for easy conversion between Guava&#8217;s <code>Optional<\/code> and <code>java.util.Optional<\/code>.<\/li>\n<li><code>Objects<\/code>: removed deprecated <code>firstNonNull<\/code> and <code>toStringHelper<\/code> methods (both found on <code>MoreObjects<\/code> since Guava 18.0).<\/li>\n<\/ul>\n<h3><a id=\"user-content-commoncache\" class=\"anchor\" href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21#commoncache\"><\/a>common.cache<\/h3>\n<p>New default methods on <code>ConcurrentMap<\/code> that were added in Java 8 are now implemented and safe to use for <code>Cache.asMap()<\/code> views.<\/p>\n<h3><a id=\"user-content-commoncollect\" class=\"anchor\" href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21#commoncollect\"><\/a>common.collect<\/h3>\n<p>Many APIs in collect now have better implementations of many of the <code>default<\/code> methods added to <code>Collection<\/code> and <code>Map<\/code> types in Java 8.<\/p>\n<h4><a id=\"user-content-new-classes\" class=\"anchor\" href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21#new-classes\"><\/a>New classes<\/h4>\n<ul>\n<li><code>Comparators<\/code>: With the addition of many useful methods to the <code>Comparator<\/code> type in Java 8, <code>Ordering<\/code> now provides little benefit. <code>Comparators<\/code> is a new location for methods on <code>Ordering<\/code>that still don&#8217;t have a good equivalent in the JDK.<\/li>\n<li><code>Streams<\/code>: Utility class for working with <code>java.util.stream.Stream<\/code>. Includes methods for creating streams (such as <code>stream(Iterable)<\/code>, <code>stream(Optional)<\/code> and <code>concat(Stream...)<\/code>) and methods that do things with streams (such as <code>findLast(Stream)<\/code>).<\/li>\n<li><code>MoreCollectors<\/code>: Factories for <code>java.util.stream.Collector<\/code> objects; note that <code>Collector<\/code>s for Guava&#8217;s collection types are generally found on those types themselves rather than here.<\/li>\n<li><code>Interners.InternerBuilder<\/code>: Builder for <code>Interner<\/code> instances, with options similar to those found on <code>MapMaker<\/code>. Created with <code>Interners.newBuilder()<\/code>.<\/li>\n<\/ul>\n<h4><a id=\"user-content-removed-classes\" class=\"anchor\" href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21#removed-classes\"><\/a>Removed classes<\/h4>\n<ul>\n<li><code>MapConstraint<\/code> and <code>MapConstraints<\/code>: deprecated since 19.0.<\/li>\n<\/ul>\n<h4><a id=\"user-content-changes\" class=\"anchor\" href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21#changes\"><\/a>Changes<\/h4>\n<ul>\n<li><code>FluentIterable<\/code>: added <code>stream()<\/code> method.<\/li>\n<li><code>ForwardingBlockingDeque<\/code>: deprecated; moved to <code>util.concurrent<\/code>.<\/li>\n<li><code>Immutable*<\/code> types: added methods to all named <code>toImmutable[Type]()<\/code> (e.g. <code>ImmutableList.toImmutableList()<\/code>) which return a <code>Collector<\/code> for collecting a <code>Stream<\/code> into an immutable collection\/map object. As with most methods that create <code>Collector<\/code>s, these are generally intended to be used as static imports.<\/li>\n<li><code>Multimap<\/code>: added <code>forEach(BiConsumer)<\/code> method.<\/li>\n<li><code>Multimaps<\/code>: added <code>toMultimap<\/code> and <code>flatteningToMultimap<\/code> methods returning <code>Collector<\/code>objects that collect to a <code>Multimap<\/code>.<\/li>\n<li><code>Multiset<\/code>: added <code>forEachEntry(ObjIntConsumer)<\/code> method.<\/li>\n<li><code>Maps<\/code>: added <code>toImmutableEnumMap<\/code> methods returning <code>Collector<\/code> objects that collect to an <code>ImmutableMap<\/code> with <code>enum<\/code> keys.<\/li>\n<li><code>Sets<\/code>: added <code>toImmutableEnumSet<\/code> method returning a <code>Collector<\/code> that collects to an <code>ImmutableSet<\/code> of <code>enum<\/code>s.<\/li>\n<li><code>Tables<\/code>: added <code>toTable<\/code> methods returning <code>Collector<\/code> objects that collect to a <code>Table<\/code>.<\/li>\n<li><code>RangeSet<\/code>: added default <code>addAll(Iterable&lt;Range&gt;)<\/code>, <code>removeAll(Iterable&lt;Range&gt;)<\/code> and <code>enclosesAll(Iterable&lt;Range&gt;)<\/code> methods.<\/li>\n<li><code>ImmutableRangeSet<\/code>: added <code>copyOf(Iterable&lt;Range&gt;)<\/code>, <code>unionOf(Iterable&lt;Range&gt;)<\/code>, <code>union(RangeSet)<\/code>, <code>intersection(RangeSet)<\/code> and <code>difference(RangeSet)<\/code> methods.<\/li>\n<li><code>TreeRangeSet<\/code>: added <code>create(Iterable&lt;Range&gt;)<\/code> method.<\/li>\n<li>A number of rarely-used methods on concrete implementations of Guava collection types that aren&#8217;t present on the interface they implement have been deprecated. These include: <code>ArrayListMultimap.trimToSize()<\/code>, <code>TreeMultimap.keyComparator()<\/code>, and <code>TreeBasedTable.row\/columnComparator()<\/code>.<\/li>\n<\/ul>\n<h3><a id=\"user-content-commonio\" class=\"anchor\" href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21#commonio\"><\/a>common.io<\/h3>\n<ul>\n<li><code>MoreFiles<\/code>: New class which contains methods similar to those in <code>Files<\/code>, but for use with <code>java.nio.file.Path<\/code> objects.<\/li>\n<li>This includes <code>deleteRecursively<\/code> and <code>deleteDirectoryContents<\/code> methods which are secure against race conditions that Java previously had no way of dealing with provided that the <code>FileSystem<\/code> supports <code>SecureDirectoryStream<\/code> (modern Linux versions do; Windows [NTFS at least] does not). For security, these will throw an exception if <code>SecureDirectoryStream<\/code> is not supported unless <code>RecursiveDeleteOption.ALLOW_INSECURE<\/code> is passed when calling the method.<\/li>\n<\/ul>\n<h3><a id=\"user-content-commonprimitives\" class=\"anchor\" href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21#commonprimitives\"><\/a>common.primitives<\/h3>\n<ul>\n<li>Most classes: added <code>constrainToRange([type] value, [type] min, [type] max)<\/code> methods which constrain the given value to the closed range defined by the <code>min<\/code> and <code>max<\/code> values. They return the value itself if it&#8217;s within the range, the <code>min<\/code> if it&#8217;s below the range and the <code>max<\/code> if it&#8217;s above the range.<\/li>\n<\/ul>\n<h3><a id=\"user-content-commonutilconcurrent\" class=\"anchor\" href=\"https:\/\/github.com\/google\/guava\/wiki\/Release21#commonutilconcurrent\"><\/a>common.util.concurrent<\/h3>\n<ul>\n<li><code>ForwardingBlockingDeque<\/code>: added; moved from <code>common.collect<\/code> because <code>BlockingDeque<\/code> is a concurrent type rather than a standard collection (it&#8217;s defined in <code>java.util.concurrent<\/code>).<\/li>\n<li><code>AtomicLongMap<\/code>: added a number of methods such as <code>accumulateAndGet(K, LongBinaryOperator)<\/code> that take advantage of new Java functional types.<\/li>\n<li><code>Monitor<\/code>: added <code>newGuard(BooleanSupplier)<\/code>.<\/li>\n<li><code>MoreExecutors<\/code>: removed <code>sameThreadExecutor()<\/code>; deprecated since 18.0 in favor of <code>directExecutor()<\/code> (preferable) or <code>newDirectExecutorService()<\/code>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Die News unter\u00a0https:\/\/github.com\/google\/guava\/wiki\/Release21: Significant API additions and changes common.base Function, Predicate and Supplier: changed to extend the new java.util.functioninterfaces with the same names. Optional: added toJavaUtil and fromJavaUtil methods for easy conversion between Guava&#8217;s Optional and java.util.Optional. Objects: removed deprecated firstNonNull and toStringHelper methods (both found on MoreObjects since Guava 18.0). common.cache New default methods [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[1,67,4],"tags":[],"class_list":["post-3592","post","type-post","status-publish","format-standard","hentry","category-allgemein","category-guavagoogle-core-libraries","category-open-source"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/3592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/comments?post=3592"}],"version-history":[{"count":2,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/3592\/revisions"}],"predecessor-version":[{"id":3594,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/3592\/revisions\/3594"}],"wp:attachment":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/media?parent=3592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/categories?post=3592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/tags?post=3592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}