ProductWeightFunction implements ViolationWeightFunction { @Override public double getWeight(Overlap violation, Overlaps overlaps, Model model) { return Arrays.stream(factors) .mapToDouble(factor -> factor.getWeight(violation, overlaps, model)) .reduce(1, (a, b) -> a * b); } ProductWeightFunction(ViolationWeightFunction... factors); @Override double getWeight(Overlap violation, Overlaps overlaps, Model model); @Override String getFormula(Overlap violation, Overlaps overlaps, Model model); @Override String getId();  }
@Test public void multipliesWeights() { Overlap instance = someOverlap(); Overlaps overlaps = new Overlaps(); Model model = () -> asSet(instance.getPattern()); ProductWeightFunction weightFunction = new ProductWeightFunction(w((o, os, m) -> 0.5), w((o, os, m) -> 0.5)); assertThat(weightFunction.getWeight(instance, overlaps, model), is(0.25)); }