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

io.imunity.vaadin.elements.wizard.WizardStepPreparer Maven / Gradle / Ivy

/*
 * Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

package io.imunity.vaadin.elements.wizard;

import java.util.function.BiConsumer;

public class WizardStepPreparer
{
	private final Class currentStepClass;
	private final Class nextStepClass;
	final BiConsumer preparer;

	public WizardStepPreparer(Class currentStepClass, Class nextStepClass, BiConsumer preparer)
	{
		this.currentStepClass = currentStepClass;
		this.nextStepClass = nextStepClass;
		this.preparer = preparer;
	}

	boolean isApplicable(WizardStep currentStep, WizardStep nextStep)
	{
		return currentStep.getClass().isAssignableFrom(currentStepClass) && nextStep.getClass().isAssignableFrom(nextStepClass);
	}

	@SuppressWarnings("unchecked")
	void prepare(WizardStep currentStep, WizardStep nextStep)
	{
		preparer.accept((WS1)currentStep, (WS2)nextStep);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy