@Test public void testLocateShards() { assertEquals(set("locateForEqual"), test.locateShards(exp(OperatorEnum.EQUAL, "eq"))); assertEquals(set("locateForNotEqual"), test.locateShards(exp(OperatorEnum.NOT_EQUAL, "eq"))); assertEquals(set("locateForGreaterThan"), test.locateShards(exp(OperatorEnum.GREATER_THAN, "eq"))); assertEquals(set("locateForGreaterThanOrEqual"), test.locateShards(exp(OperatorEnum.GREATER_THAN_OR_EQUAL, "eq"))); assertEquals(set("locateForLessThan"), test.locateShards(exp(OperatorEnum.LESS_THAN, "eq"))); assertEquals(set("locateForLessThanOrEqual"), test.locateShards(exp(OperatorEnum.LESS_THAN_OR_EQUAL, "eq"))); assertEquals(set("locateForBetween"), test.locateShards(exp(OperatorEnum.BEWTEEN, "eq"))); assertEquals(set("locateForNotBetween"), test.locateShards(exp(OperatorEnum.NOT_BETWEEN, "eq"))); assertEquals(set("locateForIn"), test.locateShards(exp(OperatorEnum.IN, "eq"))); assertEquals(set("locateForNotIn"), test.locateShards(exp(OperatorEnum.NOT_IN, "eq"))); assertEquals(set("locateForLike"), test.locateShards(exp(OperatorEnum.LIKE, "eq"))); assertEquals(set("locateForNotLike"), test.locateShards(exp(OperatorEnum.NOT_LIKE, "eq"))); assertEquals(set("locateForIsNull"), test.locateShards(exp(OperatorEnum.IS_NULL, "eq"))); assertEquals(set("locateForIsNotNull"), test.locateShards(exp(OperatorEnum.IS_NOT_NULL, "eq"))); }
public Set<String> locateShards(CTX context) { switch (context.getOperator()) { case EQUAL: return locateForEqual(context); case NOT_EQUAL: return locateForNotEqual(context); case GREATER_THAN: return locateForGreaterThan(context); case GREATER_THAN_OR_EQUAL: return locateForGreaterThanOrEqual(context); case LESS_THAN: return locateForLessThan(context); case LESS_THAN_OR_EQUAL: return locateForLessThanOrEqual(context); case BEWTEEN: return locateForBetween(context); case NOT_BETWEEN: return locateForNotBetween(context); case IN: return locateForIn(context); case NOT_IN: return locateForNotIn(context); case LIKE: return locateForLike(context); case NOT_LIKE: return locateForNotLike(context); case IS_NULL: return locateForIsNull(context); case IS_NOT_NULL: return locateForIsNotNull(context); default: throw new IllegalArgumentException("Invalid operator detected: " + context.getOperator()); } }
AbstractConditionShardLocator { public Set<String> locateShards(CTX context) { switch (context.getOperator()) { case EQUAL: return locateForEqual(context); case NOT_EQUAL: return locateForNotEqual(context); case GREATER_THAN: return locateForGreaterThan(context); case GREATER_THAN_OR_EQUAL: return locateForGreaterThanOrEqual(context); case LESS_THAN: return locateForLessThan(context); case LESS_THAN_OR_EQUAL: return locateForLessThanOrEqual(context); case BEWTEEN: return locateForBetween(context); case NOT_BETWEEN: return locateForNotBetween(context); case IN: return locateForIn(context); case NOT_IN: return locateForNotIn(context); case LIKE: return locateForLike(context); case NOT_LIKE: return locateForNotLike(context); case IS_NULL: return locateForIsNull(context); case IS_NOT_NULL: return locateForIsNotNull(context); default: throw new IllegalArgumentException("Invalid operator detected: " + context.getOperator()); } } }
AbstractConditionShardLocator { public Set<String> locateShards(CTX context) { switch (context.getOperator()) { case EQUAL: return locateForEqual(context); case NOT_EQUAL: return locateForNotEqual(context); case GREATER_THAN: return locateForGreaterThan(context); case GREATER_THAN_OR_EQUAL: return locateForGreaterThanOrEqual(context); case LESS_THAN: return locateForLessThan(context); case LESS_THAN_OR_EQUAL: return locateForLessThanOrEqual(context); case BEWTEEN: return locateForBetween(context); case NOT_BETWEEN: return locateForNotBetween(context); case IN: return locateForIn(context); case NOT_IN: return locateForNotIn(context); case LIKE: return locateForLike(context); case NOT_LIKE: return locateForNotLike(context); case IS_NULL: return locateForIsNull(context); case IS_NOT_NULL: return locateForIsNotNull(context); default: throw new IllegalArgumentException("Invalid operator detected: " + context.getOperator()); } }  }
AbstractConditionShardLocator { public Set<String> locateShards(CTX context) { switch (context.getOperator()) { case EQUAL: return locateForEqual(context); case NOT_EQUAL: return locateForNotEqual(context); case GREATER_THAN: return locateForGreaterThan(context); case GREATER_THAN_OR_EQUAL: return locateForGreaterThanOrEqual(context); case LESS_THAN: return locateForLessThan(context); case LESS_THAN_OR_EQUAL: return locateForLessThanOrEqual(context); case BEWTEEN: return locateForBetween(context); case NOT_BETWEEN: return locateForNotBetween(context); case IN: return locateForIn(context); case NOT_IN: return locateForNotIn(context); case LIKE: return locateForLike(context); case NOT_LIKE: return locateForNotLike(context); case IS_NULL: return locateForIsNull(context); case IS_NOT_NULL: return locateForIsNotNull(context); default: throw new IllegalArgumentException("Invalid operator detected: " + context.getOperator()); } }  abstract Set<String> locateForEqual(CTX context); abstract Set<String> locateForNotEqual(CTX ctx); abstract Set<String> locateForGreaterThan(CTX context); abstract Set<String> locateForGreaterThanOrEqual(CTX ctx); abstract Set<String> locateForLessThan(CTX context); abstract Set<String> locateForLessThanOrEqual(CTX ctx); abstract Set<String> locateForBetween(CTX ctx); abstract Set<String> locateForNotBetween(CTX ctx); abstract Set<String> locateForIn(CTX context); abstract Set<String> locateForNotIn(CTX context); abstract Set<String> locateForLike(CTX context); abstract Set<String> locateForNotLike(CTX context); abstract Set<String> locateForIsNull(CTX context); abstract Set<String> locateForIsNotNull(CTX context); Set<String> getAllShards(CTX context); Set<String> locateShards(CTX context); }
AbstractConditionShardLocator { public Set<String> locateShards(CTX context) { switch (context.getOperator()) { case EQUAL: return locateForEqual(context); case NOT_EQUAL: return locateForNotEqual(context); case GREATER_THAN: return locateForGreaterThan(context); case GREATER_THAN_OR_EQUAL: return locateForGreaterThanOrEqual(context); case LESS_THAN: return locateForLessThan(context); case LESS_THAN_OR_EQUAL: return locateForLessThanOrEqual(context); case BEWTEEN: return locateForBetween(context); case NOT_BETWEEN: return locateForNotBetween(context); case IN: return locateForIn(context); case NOT_IN: return locateForNotIn(context); case LIKE: return locateForLike(context); case NOT_LIKE: return locateForNotLike(context); case IS_NULL: return locateForIsNull(context); case IS_NOT_NULL: return locateForIsNotNull(context); default: throw new IllegalArgumentException("Invalid operator detected: " + context.getOperator()); } }  abstract Set<String> locateForEqual(CTX context); abstract Set<String> locateForNotEqual(CTX ctx); abstract Set<String> locateForGreaterThan(CTX context); abstract Set<String> locateForGreaterThanOrEqual(CTX ctx); abstract Set<String> locateForLessThan(CTX context); abstract Set<String> locateForLessThanOrEqual(CTX ctx); abstract Set<String> locateForBetween(CTX ctx); abstract Set<String> locateForNotBetween(CTX ctx); abstract Set<String> locateForIn(CTX context); abstract Set<String> locateForNotIn(CTX context); abstract Set<String> locateForLike(CTX context); abstract Set<String> locateForNotLike(CTX context); abstract Set<String> locateForIsNull(CTX context); abstract Set<String> locateForIsNotNull(CTX context); Set<String> getAllShards(CTX context); Set<String> locateShards(CTX context);  }