Java 8 streams filtering with priority

You can chain the two pipelines:

return objects.stream()
              .filter(object -> object.getSomething() == Something.SomethingHighPriority)
              .findFirst()
              .orElseGet(() -> objects.stream()
                                      .filter(object -> object.getSomething() == Something.SomethingLowPriority)
                                      .findFirst()
                                      .orElse(null));

An alternative would be to sort the Stream by object.getSomething() in descending order and then return the first element (if it has one of the two required values), but that would take O(NlogN) which is less efficient.