@Test public void testSelect() { for (RouteRuleGroupModel routeRuleGroup : newRouteRuleGroups()) { routeRuleGroupDao.insertOrUpdate(routeRuleGroup); RouteRuleGroupModel filter = new RouteRuleGroupModel(); filter.setGroupId(routeRuleGroup.getGroupId()); Assert.assertEquals(1, routeRuleGroupDao.select(filter).size()); Assert.assertEquals(1, routeRuleGroupDao.select(Lists.newArrayList(routeRuleGroupDao.select(filter).get(0).getId())).size()); } }
public List<RouteRuleGroupModel> select(RouteRuleGroupModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, Long> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId()); conditions.put("route_rule_id=?", filter.getRouteRuleId()); conditions.put("group_id=?", filter.getGroupId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (conditions.get(key) == null) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); }
RouteRuleGroupDao { public List<RouteRuleGroupModel> select(RouteRuleGroupModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, Long> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId()); conditions.put("route_rule_id=?", filter.getRouteRuleId()); conditions.put("group_id=?", filter.getGroupId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (conditions.get(key) == null) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); } }
RouteRuleGroupDao { public List<RouteRuleGroupModel> select(RouteRuleGroupModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, Long> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId()); conditions.put("route_rule_id=?", filter.getRouteRuleId()); conditions.put("group_id=?", filter.getGroupId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (conditions.get(key) == null) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); }  }
RouteRuleGroupDao { public List<RouteRuleGroupModel> select(RouteRuleGroupModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, Long> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId()); conditions.put("route_rule_id=?", filter.getRouteRuleId()); conditions.put("group_id=?", filter.getGroupId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (conditions.get(key) == null) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); }  List<RouteRuleGroupModel> query(); RouteRuleGroupModel generateGroup(RouteRuleGroupModel routeRuleGroup); List<RouteRuleGroupModel> select(RouteRuleGroupModel filter); List<RouteRuleGroupModel> select(List<Long> groupIds); }
RouteRuleGroupDao { public List<RouteRuleGroupModel> select(RouteRuleGroupModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, Long> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId()); conditions.put("route_rule_id=?", filter.getRouteRuleId()); conditions.put("group_id=?", filter.getGroupId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (conditions.get(key) == null) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); }  List<RouteRuleGroupModel> query(); RouteRuleGroupModel generateGroup(RouteRuleGroupModel routeRuleGroup); List<RouteRuleGroupModel> select(RouteRuleGroupModel filter); List<RouteRuleGroupModel> select(List<Long> groupIds); static final RouteRuleGroupDao INSTANCE; }