package com.github.kospiotr.springcore;

import com.github.kospiotr.springcore.fraud.FraudDetector;
import com.github.kospiotr.springcore.model.Loan;
import com.github.kospiotr.springcore.scoring.ScoringRule;

import java.util.List;

public class ScoreCalculator {

	private FraudDetector fraudDetector;
	private List<ScoringRule> scoringRules;

	public static ScoreCalculator createInstance(FraudDetector fraudDetector, List<ScoringRule> scoringRules) {
		return new ScoreCalculator(fraudDetector, scoringRules);
	}

	public ScoreCalculator() {
		System.out.println("Constructing ScoreCalculator");
	}

	public ScoreCalculator(FraudDetector fraudDetector, List<ScoringRule> scoringRules) {
		System.out.println("Constructing ScoreCalculator with all arguments");
		this.fraudDetector = fraudDetector;
		this.scoringRules = scoringRules;
	}

	public Integer getScore(Loan loan) {
		System.out.println("getScore for: " + loan);
		System.out.println("Using fraudDetector: " + fraudDetector);
		Integer score = scoringRules
				.stream()
				.mapToInt(rule -> rule.getScore(loan))
				.sum();
		return score;
	}

	public FraudDetector getFraudDetector() {
		return fraudDetector;
	}

	public void setFraudDetector(FraudDetector fraudDetector) {
		System.out.println("Injecting fraudDetector=" + fraudDetector);
		this.fraudDetector = fraudDetector;
	}

	public List<ScoringRule> getScoringRules() {
		return scoringRules;
	}

	public void setScoringRules(List<ScoringRule> scoringRules) {
		System.out.println("Injecting scoringRules=" + scoringRules);
		this.scoringRules = scoringRules;
	}

}

@@ -135,18 +135,207 @@
 ore.
-model.Loan
+fraud.PolishFraudDetector;%0Aimport com.github.kospiotr.springcore.model.Loan;%0Aimport com.github.kospiotr.springcore.scoring.AgeScoringRule;%0Aimport com.github.kospiotr.springcore.scoring.JobScoringRule
 ;%0Aim
@@ -416,16 +416,56 @@
 .List;%0A%0A
+import static java.util.Arrays.asList;%0A%0A
 public c
@@ -618,67 +618,8 @@
 nce(
-FraudDetector fraudDetector, List%3CScoringRule%3E scoringRules
 ) %7B%0A
@@ -647,17 +647,27 @@
 culator(
-f
+new PolishF
 raudDete
@@ -674,22 +674,62 @@
 ctor
-, scoringRules
+(), asList(new AgeScoringRule(), new JobScoringRule())
 );%0A%09
@@ -725,37 +725,38 @@
 Rule()));%0A%09%7D%0A%0A%09p
-ublic
+rivate
  ScoreCalculator

Update constructor and factory method