title: Best practice for java stream().filter()
body: <p>I'm working on a java spring application and want to filter and get specific item in mongodb database, but it is quite messy my code and would like to know how to improve my code when working with stream filter</p>
  
  <pre><code>public String getPrimaryTechnology(String id){
      Article article = articleRepository.findById(id).get();
  
      List&lt;AWS_entity&gt; aws_entitiesList =  article.getAws().getEntities();
  
      Predicate&lt;AWS_entity&gt; priority1 = aws -&gt; article.getTitle().contains(aws.getName()) 
              &amp;&amp; aws.getCategory().equals("TITLE");
  
      Predicate&lt;AWS_entity&gt; priority2 = aws -&gt; article.getTitle().contains(aws.getName()) 
              &amp;&amp; aws.getCategory().equals("COMMERCIAL_ITEM"));
  
      Predicate&lt;AWS_entity&gt; priority3 = aws -&gt; article.getTitle().contains(aws.getName())
              &amp;&amp; (aws.getCategory().equals("ORGANIZATION") || aws.getCategory().equals("OTHER"));
  
  
      Optional&lt;AWS_entity&gt; aws_entity = Optional.ofNullable(aws_entitiesList
              .stream()
              .sorted(Comparator.comparing(AWS_entity::getCount).reversed())
              .filter(priority1)
              .findFirst()
              .orElse(aws_entitiesList.stream()
                      .filter(priority2)
                      .findFirst()
                      .orElse(aws_entitiesList.stream()
                              .filter(priority3)
                              .findFirst().orElse(null)
                      )
              ))
      ;
  
      if(!aws_entity.isPresent())
          return "none identified";
      else return aws_entity.get().getName();
  }
  </code></pre>