title: How to return value by ternary condition in a stream?
body: <p>I want to return a value of a stream based on a condition. Take the following as an example only, where I want to map any apple to <code>Food.APPLE</code>:</p>
  
  <pre><code>public enum Food {
      APPLE, APPLE2, APPLE3, BANANA, PINEAPPLE, CUCUMBER;
  
      private static final Food[] APPLES = new Food[] {APPLE, APPLE2, APPLE3};
  
      //java7
      public Food fromValue(String value) {
          for (Food type : Food.values()) {
              if (type.name().equalsIgnoreCase(value)) {
                  return ArrayUtils.contains(APPLES, type) ? APPLE : type;
              }
          }
          return null;
      }
  
      //java8: how to include the array check for APPLES?
      public Food fromValue(String value) {
          return Arrays.stream(Food.values()).
              filter(type -&gt; type.name().equalsIgnoreCase(value))
              .findFirst()
              .orElse(null);
      }
  }
  </code></pre>
  
  <p>How can I include the ternary condition in a stream?</p>