Created
May 17, 2018 11:59
-
-
Save soverby/a68072f0dec35f80dba306439244302a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date; | |
import java.util.Optional; | |
public class FunctionWithCheckedException { | |
@FunctionalInterface | |
public interface SomeAppropriateSemantic<T, R> { | |
public R semantic(T t) throws CustomException; | |
}; | |
public void method() { | |
SomeAppropriateSemantic<String, Date> function = string -> | |
new Date(Optional.ofNullable(string).orElseThrow(CustomException::new)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment