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

co.unruly.control.Unit Maven / Gradle / Ivy

There is a newer version: 4.4.8
Show newest version
package co.unruly.control;

import java.util.function.Consumer;
import java.util.function.Function;

/**
 * Unit type, which contains only one possible value.
 * 

* This exists to offer a bridge between void and regular functions, providing * convenience methods to convert between them. */ public enum Unit { UNIT; public static Function functify(Consumer toVoid) { return x -> { toVoid.accept(x); return Unit.UNIT; }; } public static Consumer voidify(Function function) { return function::apply; } public static Unit noOp(T __) { return UNIT; } public static void noOpConsumer(T __) { // do nothing } }





© 2015 - 2026 Weber Informatics LLC | Privacy Policy