Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Weidig benweidig

View GitHub Profile
@benweidig
benweidig / typecoercers-jsr310-proposal.md
Created Oct 16, 2020
Tapestry Java Time / JSR310 Type Coercer proposal
View typecoercers-jsr310-proposal.md

Java Time API / JSR310 Type Coercers

Date: 2020-10-16
Author: Ben Weidig

Summary

Add JSR310 / Java Time CoercionTuples to Tapestry.

View 2020-05-exceptions-16.java
Either<Integer, String> result = doWork();
result.apply(errorCode -> log.error("Error {} occuring during work", errorCode),
value -> log.info("Success: {}", value));
View 2020-05-exceptions-25.java
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
public class Either<L, R> {
public static <L, R> Either<L, R> left(L value) {
return new Either<>(value, null);
}
View 2020-05-exceptions-24.java
interface FileLoader {
Optional<String> loadContent() throws IOException;
}
View 2020-05-exceptions-23.java
interface FileLoader {
String loadContent() throws FileNotFoundException;
}
View 2020-05-exceptions-22.java
try {
// might throw IOException
doWork();
doMoreWorkRequireingCleanup();
}
catch (IOException e) {
throw new RuntimeExcetpion(e)
}
finally {
View 2020-05-exceptions-21.java
try {
// might throw IllegalArgumentException
doWork();
// might throw ArithmeticException
doMoreWork();
}
catch (IllegalArgumentExcetion e) {
// handle exception
}
View 2020-05-exceptions-20.java
try {
doWork();
}
catch (Exception e) {
// NO-OP
}
View 2020-05-exceptions-19.java
try {
doWork();
}
catch (NullPointerException e) {
log.error("doWork() failed", e);
throw e;
}
View 2020-05-exceptions-18.java
protected Throwable(String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
if (writableStackTrace) {
fillInStackTrace();
}
else {
stackTrace = null;