PossibleConfiguration.java

/*
 * Copyright (C) 2019 uwe
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.sw4j.sample.memory.heap;

/**
 * This class represents either a valid configuration or an error. If the method {@link #hasValues()} returns
 * {@code true} a valid configuration is available and the error text is empty. If the method {@link #hasValues()}
 * returns {@code false} then the error text is filled with a message that should be presented to the user and all
 * values are set to {@code 0}.
 *
 * @author Uwe Plonus &lt;u.plonus@gmail.com&gt;
 */
public class PossibleConfiguration {

    private final boolean hasValues;

    private final int blockSize;

    private final int create;

    private final int shortLifetime;

    private final int mediumLifetime;

    private final int longLifetime;

    private final double longProbability;

    private final double mediumProbability;

    private final String message;

    public PossibleConfiguration(int blockSize, int create, int shortLifetime, int mediumLifetime, int longLifetime,
            double mediumProbability, double longProbability) {
        this.hasValues = true;
        this.blockSize = blockSize;
        this.create = create;
        this.shortLifetime = shortLifetime;
        this.mediumLifetime = mediumLifetime;
        this.longLifetime = longLifetime;
        this.mediumProbability = mediumProbability;
        this.longProbability = longProbability;
        this.message = "";
    }

    public PossibleConfiguration(String message) {
        this.hasValues = false;
        this.blockSize = 0;
        this.create = 0;
        this.shortLifetime = 0;
        this.mediumLifetime = 0;
        this.longLifetime = 0;
        this.mediumProbability = 0.0;
        this.longProbability = 0.0;
        this.message = message;
    }

    public boolean hasValues() {
        return hasValues;
    }

    public int getBlockSize() {
        return blockSize;
    }

    public int getCreate() {
        return create;
    }

    public int getShortLifetime() {
        return shortLifetime;
    }

    public int getMediumLifetime() {
        return mediumLifetime;
    }

    public int getLongLifetime() {
        return longLifetime;
    }

    public double getMediumProbability() {
        return mediumProbability;
    }

    public double getLongProbability() {
        return longProbability;
    }

    public String getMessage() {
        return message;
    }

}