@Test(expected = IllegalArgumentException.class) public void resolve_startAtWrongArgument() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.START_AT, query, 10f); Assert.fail(); }
@Override public <V> Query resolve(FilterType filterType, Query target, V... filterArguments) { if (filterArguments.length == 0) throw new IllegalArgumentException(MISSING_FILTER_ARGUMENTS); switch (filterType) { case LIMIT_FIRST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToFirst((Integer) filterArguments[0]); case LIMIT_LAST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToLast((Integer) filterArguments[0]); case START_AT: if (filterArguments[0] instanceof Double) { return target.startAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.startAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.startAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case END_AT: if (filterArguments[0] instanceof Double) { return target.endAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.endAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.endAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case EQUAL_TO: if (filterArguments[0] instanceof Double) { return target.equalTo((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.equalTo((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.equalTo((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } default: throw new IllegalStateException(); } }
ResolverQueryFilter implements FilterResolver<Query, Query> { @Override public <V> Query resolve(FilterType filterType, Query target, V... filterArguments) { if (filterArguments.length == 0) throw new IllegalArgumentException(MISSING_FILTER_ARGUMENTS); switch (filterType) { case LIMIT_FIRST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToFirst((Integer) filterArguments[0]); case LIMIT_LAST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToLast((Integer) filterArguments[0]); case START_AT: if (filterArguments[0] instanceof Double) { return target.startAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.startAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.startAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case END_AT: if (filterArguments[0] instanceof Double) { return target.endAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.endAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.endAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case EQUAL_TO: if (filterArguments[0] instanceof Double) { return target.equalTo((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.equalTo((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.equalTo((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } default: throw new IllegalStateException(); } } }
ResolverQueryFilter implements FilterResolver<Query, Query> { @Override public <V> Query resolve(FilterType filterType, Query target, V... filterArguments) { if (filterArguments.length == 0) throw new IllegalArgumentException(MISSING_FILTER_ARGUMENTS); switch (filterType) { case LIMIT_FIRST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToFirst((Integer) filterArguments[0]); case LIMIT_LAST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToLast((Integer) filterArguments[0]); case START_AT: if (filterArguments[0] instanceof Double) { return target.startAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.startAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.startAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case END_AT: if (filterArguments[0] instanceof Double) { return target.endAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.endAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.endAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case EQUAL_TO: if (filterArguments[0] instanceof Double) { return target.equalTo((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.equalTo((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.equalTo((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } default: throw new IllegalStateException(); } }  }
ResolverQueryFilter implements FilterResolver<Query, Query> { @Override public <V> Query resolve(FilterType filterType, Query target, V... filterArguments) { if (filterArguments.length == 0) throw new IllegalArgumentException(MISSING_FILTER_ARGUMENTS); switch (filterType) { case LIMIT_FIRST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToFirst((Integer) filterArguments[0]); case LIMIT_LAST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToLast((Integer) filterArguments[0]); case START_AT: if (filterArguments[0] instanceof Double) { return target.startAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.startAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.startAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case END_AT: if (filterArguments[0] instanceof Double) { return target.endAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.endAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.endAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case EQUAL_TO: if (filterArguments[0] instanceof Double) { return target.equalTo((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.equalTo((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.equalTo((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } default: throw new IllegalStateException(); } }  @Override Query resolve(FilterType filterType, Query target, V... filterArguments); }
ResolverQueryFilter implements FilterResolver<Query, Query> { @Override public <V> Query resolve(FilterType filterType, Query target, V... filterArguments) { if (filterArguments.length == 0) throw new IllegalArgumentException(MISSING_FILTER_ARGUMENTS); switch (filterType) { case LIMIT_FIRST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToFirst((Integer) filterArguments[0]); case LIMIT_LAST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToLast((Integer) filterArguments[0]); case START_AT: if (filterArguments[0] instanceof Double) { return target.startAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.startAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.startAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case END_AT: if (filterArguments[0] instanceof Double) { return target.endAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.endAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.endAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case EQUAL_TO: if (filterArguments[0] instanceof Double) { return target.equalTo((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.equalTo((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.equalTo((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } default: throw new IllegalStateException(); } }  @Override Query resolve(FilterType filterType, Query target, V... filterArguments);  }