TweetQuery { public static String queryOR(final String... conditions) { return Arrays.stream(conditions) .filter(s -> null != s && !s.isEmpty()) .collect(Collectors.collectingAndThen( Collectors.toList(), l -> l.isEmpty() ? null : 1 == l.size() ? l.get(0) : l.stream().collect(Collectors.joining(" OR ", "( ", " )")))); }  String getQuery(); void setQuery(final String... queryConditions); TweetQuery query(final String... queryConditions); String getLang(); void setLang(String lang); TweetQuery lang(String lang); String getLocale(); void setLocale(String locale); TweetQuery locale(String locale); Long getMaxId(); void setMaxId(Long maxId); TweetQuery maxId(Long maxId); Integer getCount(); void setCount(Integer count); TweetQuery count(Integer count); String getSince(); void setSince(String since); TweetQuery since(String since); Long getSinceId(); void setSinceId(Long sinceId); TweetQuery sinceId(Long sinceId); String getUntil(); void setUntil(String until); TweetQuery until(String until); ResultType getResultType(); void setResultType(ResultType resultType); TweetQuery resultType(ResultType resultType); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static String queryOR(final String... conditions); static String queryFrom(final String from); static String queryTo(final String to); static final String QUERY_FILTER_MEDIA; static final String QUERY_FILTER_LINKS; }
@Test public void queryFilterOrWithNullParam() { assertNull(TweetQuery.queryOR((String) null)); }
@Test public void queryFilterOrWithNullParams() { assertNull(TweetQuery.queryOR(null, null, null)); }
@Test public void queryFilterOrWithOneValidString() { assertEquals("@Devoxx", TweetQuery.queryOR("@Devoxx")); }
@Test public void queryFilterOrWithOneValidStringAndNulls() { assertEquals("@Devoxx", TweetQuery.queryOR(null, "@Devoxx", null)); }
@Test public void queryFilterOrWithTwoValidStringAndNulls() { assertEquals("( @Devoxx OR @Java )", TweetQuery.queryOR(null, "@Devoxx", "@Java", null)); }