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

com.anrisoftware.gsanalysis.synthesis.AbstractSynthesis Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2015 Erwin Müller 
 *
 * This file is part of gsanalysis-synthesis. All rights reserved.
 */
package com.anrisoftware.gsanalysis.synthesis;

import javax.measure.quantity.Quantity;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.anrisoftware.globalpom.measurement.Measure;
import com.anrisoftware.gsanalysis.core.Fraction;
import com.anrisoftware.gsanalysis.core.Gauge;
import com.anrisoftware.gsanalysis.core.Phase;
import com.anrisoftware.gsanalysis.core.Synthesis;

/**
 * Implements the algorithm how to calculate the measure from the Global Scaling
 * continued fraction. It is the inverse function of the analysis.
 *
 * @author Erwin Mueller, [email protected]
 * @since 3.0
 */
public class AbstractSynthesis implements
        Synthesis {

    private static final String MEASURE = "measure";

    private static final String PHASE = "phase";

    private static final String GAUGE = "gauge";

    private static final String FRACTION = "fraction";

    private final Fraction fraction;

    private final Gauge gauge;

    private final Phase phase;

    private Measure measure;

    protected AbstractSynthesis(Fraction fraction, Gauge gauge,
            Phase phase) {
        this.fraction = fraction;
        this.gauge = gauge;
        this.phase = phase;
    }

    @Override
    public Synthesis call() {
        doSynthesis();
        return this;
    }

    private void doSynthesis() {
        double logarithm = fraction.calculateLogarithm(phase.getValue());
        this.measure = gauge.calculateMeasure(logarithm);
    }

    @Override
    public Fraction getFraction() {
        return fraction;
    }

    @Override
    public Gauge getGauge() {
        return gauge;
    }

    @Override
    public Phase getPhase() {
        return phase;
    }

    @Override
    public Measure getMeasure() {
        return measure;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).append(FRACTION, getFraction())
                .append(PHASE, getPhase()).append(MEASURE, getMeasure())
                .append(GAUGE, getGauge()).toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy