/**
 * 
 */
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;

import java.util.Collections;
import java.util.List;

/**
 * @author fayez
 *
 */
public class GenericsGeneratorResultForClass {
	private final String className;
	private final List<GenericsGeneratorResult> classConstraints;
	private final GenericGeneratorResultsForAllMethods methodsAndTheirConstraints;

	public GenericsGeneratorResultForClass(String className) {
		this(className, Collections.emptyList(), new GenericGeneratorResultsForAllMethods());
	}
	/**
	 * @param className
	 * @param classConstraints
	 * @param methodsAndTheirConstraints
	 */
	public GenericsGeneratorResultForClass(String className, List<GenericsGeneratorResult> classConstraints,
			GenericGeneratorResultsForAllMethods methodsAndTheirConstraints) {
		this.className = className;
		this.classConstraints = classConstraints;
		this.methodsAndTheirConstraints = methodsAndTheirConstraints;
	}

	/**
	 * @return the className
	 */
	public String getClassName() {
		return className;
	}

	/**
	 * @return the classConstraints
	 */
	public List<GenericsGeneratorResult> getClassConstraints() {
		return classConstraints;
	}

	/**
	 * @return the methodsAndTheirConstraints
	 */
	public GenericGeneratorResultsForAllMethods getMethodsAndTheirConstraints() {
		return methodsAndTheirConstraints;
	}

	public boolean contains(String id) {
		return methodsAndTheirConstraints.getMethodsAndConstraints().stream().map(mc -> mc.getMethodID())
				.anyMatch(i -> i.equals(id));
	}

	
	
	
	public List<GenericsGeneratorResult> getMethodConstraintsByID(String id) {
		return methodsAndTheirConstraints.getMethodsAndConstraints().stream().filter(mc -> mc.getMethodID().equals(id))
				.findFirst().get().getConstraints();
	}

}
