package br.uem.din.metrics.concernDrivenMetrics.concernCohesion;

import java.util.Collection;
import java.util.HashSet;

import br.uem.din.architectureEvolution.representation.Component;
import br.uem.din.architectureEvolution.representation.Concern;
import br.uem.din.architectureEvolution.representation.Interface;
import br.uem.din.architectureEvolution.representation.Operation;

public class LCCComponentResult {

	private final HashSet<Concern> allConcerns = new HashSet<Concern>();
	private final Component component;

	public LCCComponentResult(Component component){
		this.component = component;
		addConcerns(component.getConcerns());
		for (Interface i : component.getImplementedInterfaces()) {
			addConcerns(i.getConcerns());
			
			for (Operation method : i.getOperations()) {
				addConcerns(method.getConcerns());
			}
		}
	}
	
	private void addConcerns(Collection<Concern> concerns) {
		allConcerns.addAll(concerns);
	}
	
	public int numberOfConcerns(){
		return allConcerns.size();
	}
	
	@Override
	public String toString() {
		return component.getName() + ": " + numberOfConcerns();
	}
}
