title: Optional query parameters for Android Room
body: <p>I have the following DAO with a query:</p>
  
  <pre><code>@Dao
  public interface BaseballCardDao {
      @Query(
          "SELECT * FROM baseball_cards " +
          "WHERE brand LIKE :brand " +
          "  AND year = :year " +
          "  AND number LIKE :number " +
          "  AND player_name LIKE :playerName " +
          "  AND team LIKE :team"
      )
      LiveData&lt;List&lt;BaseballCard&gt;&gt; getBaseballCards(
          String brand, int year, String number, String playerName, String team
      );
  }
  </code></pre>
  
  <p>The <code>String</code> parameters are "optional" in the sense that I can pass <code>"%%"</code> to match all rows due to the <code>LIKE</code> operator. But I cannot do this with <code>year</code> since it is an <code>int</code>. One solution is to add two different <code>@Query</code> methods, one with the <code>int year</code> parameter and the other without. Is there a more elegant way to create an optional parameter with Room's <code>@Query</code>?</p>