title: Java Search for a sub list from a list with many criteria
body: <p>I want to make a search method from a list of Restaurants. The user has a GUI form and complete only the fields that he wants.
  I made a method meetsCriteria to check if this Restaurant exist. It works but not in all cases.</p>
  
  <pre><code>public class RestaurantList {
      private ArrayList&lt;Restaurant&gt; _restaurants = new ArrayList&lt;Restaurant&gt;();
          RestaurantList selRest;
  
          RestaurantList searchRestaurant(String name, String area, String phone, String category)
                  {
                      selRest = new RestaurantList();
                      for (int i=0; i&lt; _restaurants.size(); i++)
                      {
                          if(_restaurants.get(i).meetsCriteria(name, area, phone, category))
                          {
                              selRest.addRestaurant(_restaurants.get(i));
                          }
  
                      }
                      return this.selRest;
                  }
  
  public class Controller {
  
  
      //this is list with all Restaurants
      static RestaurantList restList = new RestaurantList();
      //this is list with the result of the search.
  
      public static RestaurantList selList; // selectedList
  
  
      public void addRestaurant (Restaurant rest)
      {
          restList.addRestaurant(rest);
      }
  
      public  void searchCriteria(String name, String area, String phone, String category)
      {
  
          int size = restList.getRestaurants().size();
          for(int i =0; i&lt;size; i++)
              selList = restList.searchRestaurant(name, area, phone, category);
  
      }  
  }
  
  public class Restaurant {
          private String _name;
      private String _address;
      private String _phoneNum;
          private Area _area;
  
          public boolean meetsCriteria(String name, String area, String phone, String category)
          {
              if( this._name.equals(name) &amp;&amp; this._area.getArea().equals(area) &amp;&amp; this._phoneNum.equals(phone) &amp;&amp; this._category.equals(category) )
              {
                  return true;
  
  
              }
              if ( name.equals("") &amp;&amp; area.equals(this._area.getArea()) &amp;&amp; phone.equals("") &amp;&amp; category.equals("") )
              {
                  return true;
  
  
              }
              if ( name.equals("") &amp;&amp; area.equals(this._area.getArea()) &amp;&amp; phone.equals(this._phoneNum) &amp;&amp; category.equals("") )
              {
                  return true;
  
  
              }
              if (name.equals("") &amp;&amp; area.equals(this._area.getArea()) &amp;&amp; phone.equals("") &amp;&amp; category.equals(this._category) )
              {
                 return true; 
  
  
              }
              if ( area.equals(this._area.getArea()) &amp;&amp; phone.equals("") &amp;&amp; category.equals("") )
              {
                  int index = this._name.indexOf(name);
                  if (index != -1)
                  {
                      return true; 
                  }else return false;
  
  
              }
              if (area.equals(this._area) &amp;&amp; category.equals(this._category) )
              {
                  return true;
              }
              else
              {
              return false;
              }
          }
  }
  </code></pre>