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

net.sourceforge.plantuml.project.solver.SolverImpl Maven / Gradle / Ivy

There is a newer version: 1.2024.8
Show newest version
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.project.solver;

import net.sourceforge.plantuml.project.Load;
import net.sourceforge.plantuml.project.LoadPlanable;
import net.sourceforge.plantuml.project.core.TaskAttribute;
import net.sourceforge.plantuml.project.time.Day;

public class SolverImpl extends AbstractSolver implements Solver {
    // ::remove folder when __HAXE__

	private final LoadPlanable loadPlanable;

	public SolverImpl(LoadPlanable loadPlanable) {
		this.loadPlanable = loadPlanable;
	}

	@Override
	protected Day computeEnd() {
		Day current = (Day) values.get(TaskAttribute.START);
		int fullLoad = ((Load) values.get(TaskAttribute.LOAD)).getFullLoad();
		int cpt = 0;
		while (fullLoad > 0) {
			fullLoad -= loadPlanable.getLoadAt(current);
			current = current.increment();
			cpt++;
			if (cpt > 100000)
				throw new IllegalStateException();

		}
		return current.decrement();
	}

	@Override
	protected Day computeStart() {
		Day current = (Day) values.get(TaskAttribute.END);
		int fullLoad = ((Load) values.get(TaskAttribute.LOAD)).getFullLoad();
		int cpt = 0;
		while (fullLoad > 0) {
			fullLoad -= loadPlanable.getLoadAt(current);
			current = current.decrement();
			if (current.getMillis() <= 0)
				return current;

			cpt++;
			if (cpt > 100000)
				throw new IllegalStateException();

		}
		return current.increment();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy