package de.dhbwstuttgart.typecheck;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Speichert die Klassen im aktuellen Projektscope
 */
public class JavaClassRegistry {
    public List<JavaClassName> existingClasses = new ArrayList<>();

    public JavaClassRegistry(List<String> initialNames){
        for(String name : initialNames){
            existingClasses.add(new JavaClassName(name));
        }
    }

    public void add(String className){
        existingClasses.add(new JavaClassName(className));
    }

    public JavaClassName getName(String className) {
        for(JavaClassName name : existingClasses){
            if(name.equals(new JavaClassName(className)))return name;
        }
        throw new TypeNotPresentException(className, new Throwable());
    }

    @Override
    public String toString(){
        return existingClasses.toString();
    }

    public boolean contains(String whole) {
        return existingClasses.contains(new JavaClassName(whole));
    }
}
