Skip to content

Instantly share code, notes, and snippets.

View rmcdouga's full-sized avatar

Rob McDougall rmcdouga

View GitHub Profile
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
private <T> void setIfNotNull(final Consumer<T> setter, final T value) {
if (value != null) {
setter.accept(value);
}
}
@rmcdouga
rmcdouga / LambdaExceptionUtil.java
Created March 14, 2019 14:27 — forked from jomoespe/LambdaExceptionUtil.java
Utility class to handle checked exceptions from
/**
* Utility class to handle checked exceptions in lambdas.
* <p>
* From <a href="http://stackoverflow.com/questions/27644361/how-can-i-throw-checked-exceptions-from-inside-java-8-streams">How can I throw CHECKED exceptions from inside Java 8 streams?</a>.
* This class helps to handle checked exceptions with lambdas. Example, with Class.forName method, which throws checked exceptions:
* </p>
* <pre>
* Stream.of("java.lang.Object", "java.lang.Integer", "java.lang.String")
* .map(rethrowFunction(Class::forName))
* .collect(Collectors.toList());
@rmcdouga
rmcdouga / BrianTest.java
Last active April 5, 2018 00:08
Combat Results Test
package com.github.rmcdouga.cow.combat_simulator;
import java.util.Random;
import java.util.StringJoiner;
import com.github.rmcdouga.cow.CombatResultsTable;
import com.github.rmcdouga.cow.units.UnitType;
import com.github.rmcdouga.cow.units.UnitTypes;
public class BrianTest {