title: Check valid enum values before using enum
body: <p>I'm trying to lookup against an Enum set, knowing that there will often be a non-match which throws an exception: I would like to check the value exists before performing the lookup to avoid the exceptions. My enum looks something like this:</p>
  
  <pre><code>public enum Fruit {
      APPLE("apple"),
      ORANGE("orange");
      ;
      private final String fruitname;
      Fruit(String fruitname) {
          this.fruitname = fruitname;
      }
      public String fruitname() {return fruitname;}
  }
  </code></pre>
  
  <p>and I want to check if, say, "banana" is one of my enum values before attempting to use the relevant enum. I could iterate through the permissible values comparing my string to</p>
  
  <pre><code>Fruit.values()[i].fruitname
  </code></pre>
  
  <p>but I'd like to be able to do something like (pseduo-code):</p>
  
  <pre><code>if (Fruit.values().contains(myStringHere)) {...
  </code></pre>
  
  <p>Is that possible? Should I be using something else entirely (Arrays? Maps?)?</p>
  
  <p>EDIT: in the end I've gone with NawaMan's suggestion, but thanks to everyone for all the helpful input.</p>