@Test public void testCriterion() throws Exception { LikeCriterion criterion = new LikeCriterion("a", "b"); assertThat(criterion.value(), equalTo("(a=b)")); assertThat(criterion.filter(), notNullValue()); criterion = new LikeCriterion("a", "b", LikeCriterion.MatchMode.START); assertThat(criterion.value(), equalTo("(a=b*)")); assertThat(criterion.filter(), notNullValue()); criterion = new LikeCriterion("a", "b", LikeCriterion.MatchMode.END); assertThat(criterion.value(), equalTo("(a=*b)")); assertThat(criterion.filter(), notNullValue()); criterion = new LikeCriterion("a", "b", LikeCriterion.MatchMode.ANYWHERE); assertThat(criterion.value(), equalTo("(a=*b*)")); assertThat(criterion.filter(), notNullValue()); criterion = new LikeCriterion("a", "b", LikeCriterion.MatchMode.EXACT); assertThat(criterion.value(), equalTo("(a=b)")); assertThat(criterion.filter(), notNullValue()); }
@Override public String value() { StringBuilder builder = new StringBuilder(32); builder.append('(').append(attribute).append('='); switch (mode) { case START: builder.append(value).append('*'); break; case END: builder.append('*').append(value); break; case ANYWHERE: builder.append('*').append(value).append('*'); break; default: builder.append(value); break; } builder.append(')'); return builder.toString(); }
LikeCriterion extends AbstractCriterion { @Override public String value() { StringBuilder builder = new StringBuilder(32); builder.append('(').append(attribute).append('='); switch (mode) { case START: builder.append(value).append('*'); break; case END: builder.append('*').append(value); break; case ANYWHERE: builder.append('*').append(value).append('*'); break; default: builder.append(value); break; } builder.append(')'); return builder.toString(); } }
LikeCriterion extends AbstractCriterion { @Override public String value() { StringBuilder builder = new StringBuilder(32); builder.append('(').append(attribute).append('='); switch (mode) { case START: builder.append(value).append('*'); break; case END: builder.append('*').append(value); break; case ANYWHERE: builder.append('*').append(value).append('*'); break; default: builder.append(value); break; } builder.append(')'); return builder.toString(); } LikeCriterion(String attribute, Object value, MatchMode mode);  LikeCriterion(String attribute, Object value); }
LikeCriterion extends AbstractCriterion { @Override public String value() { StringBuilder builder = new StringBuilder(32); builder.append('(').append(attribute).append('='); switch (mode) { case START: builder.append(value).append('*'); break; case END: builder.append('*').append(value); break; case ANYWHERE: builder.append('*').append(value).append('*'); break; default: builder.append(value); break; } builder.append(')'); return builder.toString(); } LikeCriterion(String attribute, Object value, MatchMode mode);  LikeCriterion(String attribute, Object value); @Override String value(); }
LikeCriterion extends AbstractCriterion { @Override public String value() { StringBuilder builder = new StringBuilder(32); builder.append('(').append(attribute).append('='); switch (mode) { case START: builder.append(value).append('*'); break; case END: builder.append('*').append(value); break; case ANYWHERE: builder.append('*').append(value).append('*'); break; default: builder.append(value); break; } builder.append(')'); return builder.toString(); } LikeCriterion(String attribute, Object value, MatchMode mode);  LikeCriterion(String attribute, Object value); @Override String value();  }