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

com.g2forge.gearbox.browser.operation.WrappedOperationBuilder Maven / Gradle / Ivy

package com.g2forge.gearbox.browser.operation;

import com.g2forge.alexandria.java.function.IConsumer1;
import com.g2forge.alexandria.java.function.IFunction1;

import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public class WrappedOperationBuilder implements IOperationBuilder {
	protected final IFunction1 factory;

	protected final IOperationBuilder operation;

	@Override
	public T execute(IConsumer1 operation) {
		return this.operation.execute(t -> {
			final IOperationWrapper wrapper = factory.apply(t);
			operation.curry(t).wrap(wrapper::pre, wrapper::post).run();
		});
	}

	@Override
	public  V until(int seconds, IFunction1 function) {
		return this.operation.until(seconds, t -> {
			final IOperationWrapper wrapper = factory.apply(t);
			return function.curry(t).wrap(wrapper::pre, wrapper::post);
		}).get();
	}

	@Override
	public IOperationBuilder wrap(IFunction1 factory) {
		return new WrappedOperationBuilder<>(factory, this);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy