title: Equivalent in java 8 from guava Enums.getIfPresent() that will return java.util.Optional?
body: <p>I have the following code from an old group that is using guava Optional and Enums (getIfPresent).</p>
  
  <pre><code>// getNameAsString returns the string literal but I want to safely convert
  // to an enum and return an java.util.Optional &lt;MessageName&gt;.
  // MessageName is an enum
  Optional&lt;MessageName&gt; msgName = Enums.getIfPresent(MessageName.class, obj.getMessage().getNameAsString());
  </code></pre>
  
  <p>How can I convert this to java 8? What is the equivalent of guava Enums.getIfPresent in java 8 that would return an java.util.Optional?</p>