package de.dhbwstuttgart.strucTypes5.assumptions;

import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarStore;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.Method;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by sebastian on 20.04.17.
 */
public class AssumptionMakerGlobal {

    List<AssumptionAbstract> assumptionAbstractList = new ArrayList<>();
    AssumptionMap assumptionMapGlobal = new AssumptionMap();


    public AssumptionMakerGlobal(ClassOrInterface classOrInterface, TypeVarStore typeVarStore) {
        makeFieldAssumptions(classOrInterface.getFieldDecl() , typeVarStore);
        makeMethodAssumptions(classOrInterface.getMethods() , typeVarStore);
        makeClassAssumption(classOrInterface,typeVarStore);
    }


    // Erstelle Feld Assumptions
    private void makeFieldAssumptions(List<Field> fieldList, TypeVarStore typeVarStore) {
        for (Field f : fieldList) {
          assumptionAbstractList.add(AssumptionFactory.makeFieldAssumption(f,typeVarStore));
        }
    }



    // Erstelle MethodenAussumptions
    private void makeMethodAssumptions(List<Method> methodList, TypeVarStore typeVarStore) {
        for (Method m : methodList) {
            assumptionAbstractList.add(AssumptionFactory.makeMethodAssumption(m,typeVarStore));
        }
    }



    // Erstelle ClassAssumption für diese Klasse
    private void makeClassAssumption(ClassOrInterface cl , TypeVarStore tvs) {
        AssumptionClass assumptionClass = new AssumptionClass();
        assumptionClass.setCl(cl);
        assumptionClass.setTypeVarStore(tvs);
        assumptionAbstractList.add(assumptionClass);
    }

    public List<AssumptionAbstract> getAssumptionAbstractList() {
        return assumptionAbstractList;
    }
}
