com.andyln.Mixja Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mixja Show documentation
Show all versions of mixja Show documentation
Java library implementing Mixtures - Setup objects without needing private methods or using double brace initialization anti-pattern.
The newest version!
package com.andyln;
import java.util.concurrent.Callable;
import java.util.function.Supplier;
public class Mixja {
private Mixja() {
}
/**
* Creates an object that may require additional put/add/set/etc. Java Lambda used to setup and return this object.
*
* @param supplier Any Supplier
* @param - Element returned by Supplier
* @return Return value of Supplier
*/
public static E mix(Supplier supplier) {
return supplier.get();
}
/**
* eix = checked (e)xception may be thrown m(ix). The performance of try-catch is why this method is standalone.
*
* @param callable Any Callable
* @param - Element returned by Callable
* @return Return value of Callable
*/
public static E eix(Callable callable) {
try {
return callable.call();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}