All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.puresoltechnologies.purifinity.server.metrics.halstead.AbstractHalsteadResults Maven / Gradle / Ivy

package com.puresoltechnologies.purifinity.server.metrics.halstead;

import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.DIFFERENT_OPERANDS;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.DIFFERENT_OPERATORS;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.DIFFICULTY;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.ESTIMATED_BUGS;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.HALSTEAD_LENGTH;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.HALSTEAD_VOLUMNE;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.IMPLEMENTATION_EFFORT;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.IMPLEMENTATION_TIME;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.PROGRAM_LENGTH;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.PROGRAM_LEVEL;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.TOTAL_OPERANDS;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.TOTAL_OPERATORS;
import static com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadMetricEvaluatorParameter.VOCABULARY_SIZE;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.puresoltechnologies.purifinity.evaluation.domain.metrics.AbstractMetrics;
import com.puresoltechnologies.purifinity.evaluation.domain.metrics.MetricValue;
import com.puresoltechnologies.versioning.Version;

public abstract class AbstractHalsteadResults extends AbstractMetrics {

    private static final long serialVersionUID = 7911283186514371553L;

    public AbstractHalsteadResults(String evaluatorId,
	    Version evaluatorVersion, Date time) {
	super(evaluatorId, evaluatorVersion, time);
    }

    protected Map> convertToRow(
	    HalsteadMetricResult result) {
	Map> row = new HashMap<>();
	if (result != null) {
	    HalsteadResult halstead = result.getHalsteadResult();
	    row.put(DIFFERENT_OPERATORS.getName(), new MetricValue(
		    halstead.getDifferentOperators(), DIFFERENT_OPERATORS));
	    row.put(DIFFERENT_OPERANDS.getName(), new MetricValue(
		    halstead.getDifferentOperands(), DIFFERENT_OPERANDS));
	    row.put(TOTAL_OPERATORS.getName(), new MetricValue(
		    halstead.getTotalOperators(), TOTAL_OPERATORS));
	    row.put(TOTAL_OPERANDS.getName(),
		    new MetricValue(halstead.getTotalOperands(),
			    TOTAL_OPERANDS));
	    row.put(VOCABULARY_SIZE.getName(), new MetricValue(
		    halstead.getVocabularySize(), VOCABULARY_SIZE));
	    row.put(PROGRAM_LENGTH.getName(),
		    new MetricValue(halstead.getProgramLength(),
			    PROGRAM_LENGTH));
	    row.put(HALSTEAD_LENGTH.getName(),
		    new MetricValue(halstead.getHalsteadLength(),
			    HALSTEAD_LENGTH));
	    row.put(HALSTEAD_VOLUMNE.getName(), new MetricValue(
		    halstead.getHalsteadVolume(), HALSTEAD_VOLUMNE));
	    row.put(DIFFICULTY.getName(),
		    new MetricValue(halstead.getDifficulty(),
			    DIFFICULTY));
	    row.put(PROGRAM_LEVEL.getName(),
		    new MetricValue(halstead.getProgramLevel(),
			    PROGRAM_LEVEL));
	    row.put(IMPLEMENTATION_EFFORT.getName(), new MetricValue(
		    halstead.getImplementationEffort(), IMPLEMENTATION_EFFORT));
	    row.put(IMPLEMENTATION_TIME.getName(), new MetricValue(
		    halstead.getImplementationTime(), IMPLEMENTATION_TIME));
	    row.put(ESTIMATED_BUGS.getName(),
		    new MetricValue(halstead.getEstimatedBugs(),
			    ESTIMATED_BUGS));
	}
	return row;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy