package de.dhbwstuttgart.strucTypes4.syntaxtree;

import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarStore;

import java.util.List;
import java.util.Map;

/**
 * Created by sebastian on 08.04.17.
 */
public class ExprNew extends  ExpressionAbstract {


    String classType;
    // key Value
    Map<String,String> generics;
    List<ExpressionAbstract> args;

    public ExprNew(String classType, Map<String,String> generics, List<ExpressionAbstract> args) {
        this.classType = classType;
        this.generics = generics;
        this.args = args;
    }


    public String getClassType() {
        return classType;
    }

    public void setClassType(String classType) {
        this.classType = classType;
    }

    public Map<String,String> getGenerics() {
        return generics;
    }

    public void setGenerics(Map<String,String> generics) {
        this.generics = generics;
    }

    public List<ExpressionAbstract> getArgs() {
        return args;
    }

    public void setArgs(List<ExpressionAbstract> args) {
        this.args = args;
    }


    public String toString() {
        return String.format("new %s< %s >( %s )"  , classType.toString(), generics.toString() , args.toString());
    }

    @Override
    public String toCodeTyped(TypeVarStore typeVarStore) {
        return String.format("[new %s< %s >( %s )] : %s "  , classType.toString(), generics.toString() , args.toString() , typeVarStore.getTypeVarByTPH(getTypePlaceHolder()));
    }

    @Override
    public String toCodeTPH() {
        return String.format("[new %s< %s >( %s )]"  , classType.toString(), generics.toString() , args.toString());
    }




}
