title: How to avoid NullPointer exception in Enums
body: <p>I am writing an enum and making sure that the enum don't throw nullpointer exception, as it looks bad for the client who uses this enum. I am using Google enum, still it throws NPE if the input parameter <code>mood is null</code></p>
  <pre><code>import com.google.common.base.Enums;
  public enum KnowYourMoodEnum {
      ANGRY, SAD, HAPPY, FEELING_GOOD;
      
      private static final Set&lt;KnowYourMoodEnum&gt; HAPPY_MOOD_LIST = Sets.newHashSet(HAPPY, FEELING_GOOD);
      private static final Set&lt;KnowYourMoodEnum&gt; UPSET_MOOD_LIST = Sets.newHashSet(ANGRY, SAD);
      
      public static boolean isHappyMood(String mood) {
          return HAPPY_MOOD_LIST.stream()
                  .anyMatch(x -&gt; x.equals(Enums.getIfPresent(KnowYourMoodEnum.class, mood).orNull()));
      }
      
      public static boolean isUpsetMood(String mood) {
          return UPSET_MOOD_LIST.stream()
                  .anyMatch(x -&gt; x.equals(Enums.getIfPresent(KnowYourMoodEnum.class, mood).orNull()));
      }
      
  }
  </code></pre>