package aserg.gtf.truckfactor;

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

import aserg.gtf.model.authorship.Developer;

public class TFInfo {
	private int tf;
	private int totalFiles;
	private float coverage;
	private List<Developer> tfDevelopers;
	
	public TFInfo() {
		super();
		this.tfDevelopers = new ArrayList<Developer>();
	}
	public void setTf(int tf) {
		this.tf = tf;
	}
	public void setTotalFiles(int totalFiles) {
		this.totalFiles = totalFiles;
	}
	public void setCoverage(float coverage) {
		this.coverage = coverage;
	}
	public void addDeveloper(Developer dev){
		tfDevelopers.add(dev);
	}
	
	public int getTf() {
		return tf;
	}
	public int getTotalFiles() {
		return totalFiles;
	}
	public float getCoverage() {
		return coverage;
	}
	public List<Developer> getTfDevelopers() {
		return tfDevelopers;
	}
	@Override
	public String toString() {
		String retStr = String.format("TF = %d (coverage = %.2f%%\n", tf, coverage*100);
		retStr += "TF authors (Developer;Files;Percentage):\n";
		for (Developer developer : tfDevelopers) {
			int devFiles = developer.getAuthorshipFiles().size();
			retStr += String.format("%s;%d;%.2f\n",developer.getName(),devFiles,(float)devFiles/totalFiles*100);
		}
		return retStr;
	}
	
}

@@ -922,16 +922,17 @@
 = %25.2f%25%25
+)
 %5Cn%22, tf,
@@ -1235,12 +1235,440 @@
 Str;%0A%09%7D%0A
+%09public String getFormatedInfo(String repository)%7B%0A%09%09String retStr = String.format(%22%25s;TF;%25d%5Cn%22, repository, tf);%0A%09%09retStr += String.format(%22%25s;Coverage;%25.2f%5Cn%22, repository,  coverage*100);%0A%09%09%0A%09%09for (Developer developer : tfDevelopers) %7B%0A%09%09%09int devFiles = developer.getAuthorshipFiles().size();%0A%09%09%09retStr += String.format(%22%25s;%25s;%25.2f%5Cn%22, repository,  developer.getName(),(float)devFiles/totalFiles*100);%0A%09%09%7D%0A%09%09return retStr;%0A%09%7D%0A
 %09%0A%7D%0A

add new format to present the TF result