@Test public void testReplaceFilter() throws Exception { PaginationFilter<Object> objectFilter = new TestObjectFilter(); PaginationFilter<Object> objectFilterHandle = objectFilter.replaceFilter("myFilter", "+0400"); Assert.assertEquals("filter was not updated.", "myFilter", objectFilter.getFilter()); Assert.assertEquals("timezoneOffset was not updated.", "+0400", objectFilter.getTimeZoneOffset()); Assert.assertEquals("The returned object should have the same hash.", objectFilter.hashCode(), objectFilterHandle.hashCode()); objectFilter.replaceFilter("mySecondFilter", ""); Assert.assertEquals("filter was not updated.", "mySecondFilter", objectFilter.getFilter()); Assert.assertEquals("timezoneOffset changed.", "+0400", objectFilter.getTimeZoneOffset()); objectFilter.replaceFilter(null, null); Assert.assertEquals("filter was not reset.", "", objectFilter.getFilter()); Assert.assertEquals("timezoneOffset was not reset.", "+0000", objectFilter.getTimeZoneOffset()); }
public PaginationFilter<T> replaceFilter(final String filter, final String timeZoneOffset) { this.filter = filter == null ? "" : filter; if (timeZoneOffset == null) { this.timeZoneOffset = "+0000"; } else { this.timeZoneOffset = timeZoneOffset.isEmpty() ? this.timeZoneOffset : timeZoneOffset; } return this; }
PaginationFilter implements Predicate<T> { public PaginationFilter<T> replaceFilter(final String filter, final String timeZoneOffset) { this.filter = filter == null ? "" : filter; if (timeZoneOffset == null) { this.timeZoneOffset = "+0000"; } else { this.timeZoneOffset = timeZoneOffset.isEmpty() ? this.timeZoneOffset : timeZoneOffset; } return this; } }
PaginationFilter implements Predicate<T> { public PaginationFilter<T> replaceFilter(final String filter, final String timeZoneOffset) { this.filter = filter == null ? "" : filter; if (timeZoneOffset == null) { this.timeZoneOffset = "+0000"; } else { this.timeZoneOffset = timeZoneOffset.isEmpty() ? this.timeZoneOffset : timeZoneOffset; } return this; }  }
PaginationFilter implements Predicate<T> { public PaginationFilter<T> replaceFilter(final String filter, final String timeZoneOffset) { this.filter = filter == null ? "" : filter; if (timeZoneOffset == null) { this.timeZoneOffset = "+0000"; } else { this.timeZoneOffset = timeZoneOffset.isEmpty() ? this.timeZoneOffset : timeZoneOffset; } return this; }  PaginationFilter<T> replaceFilter(final String filter, final String timeZoneOffset); final boolean test(T object, Class<V> enumType); }
PaginationFilter implements Predicate<T> { public PaginationFilter<T> replaceFilter(final String filter, final String timeZoneOffset) { this.filter = filter == null ? "" : filter; if (timeZoneOffset == null) { this.timeZoneOffset = "+0000"; } else { this.timeZoneOffset = timeZoneOffset.isEmpty() ? this.timeZoneOffset : timeZoneOffset; } return this; }  PaginationFilter<T> replaceFilter(final String filter, final String timeZoneOffset); final boolean test(T object, Class<V> enumType);  }