{"id":1905,"date":"2013-06-02T22:21:20","date_gmt":"2013-06-02T20:21:20","guid":{"rendered":"http:\/\/www.tutego.de\/blog\/javainsel\/?p=1905"},"modified":"2013-06-02T22:21:20","modified_gmt":"2013-06-02T20:21:20","slug":"na-endlich-sieht-java-8s-optional-typ-besser-aus","status":"publish","type":"post","link":"https:\/\/www.tutego.de\/blog\/javainsel\/2013\/06\/na-endlich-sieht-java-8s-optional-typ-besser-aus\/","title":{"rendered":"Na endlich sieht Java 8&rsquo;s Optional-Typ besser aus"},"content":{"rendered":"<p><a title=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\" href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html<\/a>:<\/p>\n<p><code>static &lt;T&gt; <a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">Optional<\/a>&lt;T&gt;<\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#empty()\">empty<\/a><\/strong>()<\/code><\/p>\n<p>Returns an empty <code>Optional<\/code> instance.<\/p>\n<p><code>boolean<\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#equals(java.lang.Object)\">equals<\/a><\/strong>(<a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/lang\/Object.html\">Object<\/a> obj)<\/code><\/p>\n<p>Indicates whether some other object is &quot;equal to&quot; this Optional.<\/p>\n<p><code><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">T<\/a><\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#get()\">get<\/a><\/strong>()<\/code><\/p>\n<p>If a value is present in this <code>Optional<\/code>, returns the value, otherwise throws <code>NoSuchElementException<\/code>.<\/p>\n<p><code>int<\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#hashCode()\">hashCode<\/a><\/strong>()<\/code><\/p>\n<p>Returns the hash code value of the present value, if any, or 0 (zero) if no value is present.<\/p>\n<p><code>void<\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#ifPresent(java.util.function.Consumer)\">ifPresent<\/a><\/strong>(<a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/function\/Consumer.html\">Consumer<\/a>&lt;? super <a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">T<\/a>&gt; consumer)<\/code><\/p>\n<p>Have the specified consumer accept the value if a value is present, otherwise do nothing.<\/p>\n<p><code>boolean<\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#isPresent()\">isPresent<\/a><\/strong>()<\/code><\/p>\n<p>Return <code>true<\/code> if there is a value present, otherwise <code>false<\/code>.<\/p>\n<p><code>static &lt;T&gt; <a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">Optional<\/a>&lt;T&gt;<\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#of(T)\">of<\/a><\/strong>(T value)<\/code><\/p>\n<p>Return an <code>Optional<\/code> with the specified present value.<\/p>\n<p><code><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">T<\/a><\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#orElse(T)\">orElse<\/a><\/strong>(<a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">T<\/a> other)<\/code><\/p>\n<p>Return the value if present, otherwise return <code>other<\/code>.<\/p>\n<p><code><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">T<\/a><\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#orElseGet(java.util.function.Supplier)\">orElseGet<\/a><\/strong>(<a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/function\/Supplier.html\">Supplier<\/a>&lt;? extends <a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">T<\/a>&gt; other)<\/code><\/p>\n<p>Return the value if present, otherwise invoke <code>other<\/code> and return the result of that invocation.<\/p>\n<p><code>&lt;X extends <a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/lang\/Throwable.html\">Throwable<\/a>&gt;      <br \/><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html\">T<\/a><\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#orElseThrow(java.util.function.Supplier)\">orElseThrow<\/a><\/strong>(<a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/function\/Supplier.html\">Supplier<\/a>&lt;? extends X&gt; exceptionSupplier)<\/code><\/p>\n<p>Return the contained value, if present, otherwise throw an exception to be created by the provided supplier.<\/p>\n<p><code><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/lang\/String.html\">String<\/a><\/code>    <br \/><code><strong><a href=\"http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html#toString()\">toString<\/a><\/strong>()<\/code><\/p>\n<p>Returns a non-empty string representation of this Optional suitable for debugging.<\/p>\n<p>&#160;<\/p>\n<p>Was mir immer noch fehlt: fromNullable(v). Arg, das fehlt.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/download.java.net\/jdk8\/docs\/api\/java\/util\/Optional.html: static &lt;T&gt; Optional&lt;T&gt; empty() Returns an empty Optional instance. boolean equals(Object obj) Indicates whether some other object is &quot;equal to&quot; this Optional. T get() If a value is present in this Optional, returns the value, otherwise throws NoSuchElementException. int hashCode() Returns the hash code value of the present value, if any, or 0 (zero) [&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":[66],"tags":[],"class_list":["post-1905","post","type-post","status-publish","format-standard","hentry","category-java-8"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/1905","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=1905"}],"version-history":[{"count":0,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/1905\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/media?parent=1905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/categories?post=1905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/tags?post=1905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}