@Test public void testPluggablePredicator() throws JsonProcessingException { String predicatorClass = "org.apache.griffin.core.util.PredicatorMock"; HashMap<String, Object> map = new HashMap<>(); map.put("class", predicatorClass); SegmentPredicate segmentPredicate = new SegmentPredicate("custom", null); segmentPredicate.setConfigMap(map); Predicator predicator = PredicatorFactory.newPredicateInstance(segmentPredicate); assertNotNull(predicator); assertTrue(predicator instanceof PredicatorMock); }
public static Predicator newPredicateInstance(SegmentPredicate segPredicate) { Predicator predicate; switch (segPredicate.getType()) { case "file.exist": predicate = new FileExistPredicator(segPredicate); break; case "custom": predicate = getPredicateBean(segPredicate); break; default: throw new GriffinException.NotFoundException(PREDICATE_TYPE_NOT_FOUND); } return predicate; }
PredicatorFactory { public static Predicator newPredicateInstance(SegmentPredicate segPredicate) { Predicator predicate; switch (segPredicate.getType()) { case "file.exist": predicate = new FileExistPredicator(segPredicate); break; case "custom": predicate = getPredicateBean(segPredicate); break; default: throw new GriffinException.NotFoundException(PREDICATE_TYPE_NOT_FOUND); } return predicate; } }
PredicatorFactory { public static Predicator newPredicateInstance(SegmentPredicate segPredicate) { Predicator predicate; switch (segPredicate.getType()) { case "file.exist": predicate = new FileExistPredicator(segPredicate); break; case "custom": predicate = getPredicateBean(segPredicate); break; default: throw new GriffinException.NotFoundException(PREDICATE_TYPE_NOT_FOUND); } return predicate; }  }
PredicatorFactory { public static Predicator newPredicateInstance(SegmentPredicate segPredicate) { Predicator predicate; switch (segPredicate.getType()) { case "file.exist": predicate = new FileExistPredicator(segPredicate); break; case "custom": predicate = getPredicateBean(segPredicate); break; default: throw new GriffinException.NotFoundException(PREDICATE_TYPE_NOT_FOUND); } return predicate; }  static Predicator newPredicateInstance(SegmentPredicate segPredicate); }
PredicatorFactory { public static Predicator newPredicateInstance(SegmentPredicate segPredicate) { Predicator predicate; switch (segPredicate.getType()) { case "file.exist": predicate = new FileExistPredicator(segPredicate); break; case "custom": predicate = getPredicateBean(segPredicate); break; default: throw new GriffinException.NotFoundException(PREDICATE_TYPE_NOT_FOUND); } return predicate; }  static Predicator newPredicateInstance(SegmentPredicate segPredicate);  }