package com.grayben.riskExtractor.htmlScorer.partScorers.tagScorers;

import com.grayben.riskExtractor.htmlScorer.partScorers.Scorer;

import java.util.Map;

/**
 * Created by beng on 17/12/2015.
 */
public abstract class MapScorer<T> extends Scorer<T> {

    Map<T, Integer> scoresMap;

    protected MapScorer(String scoreLabel, Map<T, Integer> scoresMap) {
        super(scoreLabel);
        if(scoresMap == null){
            throw new NullPointerException(
                    "The scores map can not be null"
            );
        }
        if(scoresMap.isEmpty()){
            throw new IllegalArgumentException(
                    "The scores map cannot be empty"
            );
        }
        this.scoresMap = scoresMap;
    }

    @Override
    public int score(T input){
        validateScoreInput(input);
        boolean containsKey = scoresMap.containsKey(input);
        if (containsKey)
            return scoresMap.get(input);
        else
            return 0;
    }

    private void validateScoreInput(T input) {
        if(input == null){
            throw new NullPointerException(
                    "Input cannot be null"
            );
        }
    }
}

@@ -128,16 +128,46 @@
 corer;%0A%0A
+import java.util.Collections;%0A
 import j
@@ -311,16 +311,122 @@
 esMap;%0A%0A
+    public Map%3CT, Integer%3E getScoresMap() %7B%0A        return Collections.unmodifiableMap(scoresMap);%0A    %7D%0A%0A
     prot

Add accessor to unmodifiable copy of scoresMap