From 932e185045e9b44b66150ec11d055502ace26435 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 18 Jul 2009 02:52:43 +0200 Subject: Added SneakyThrows which finishes the documentation for the features pages. --- usage_examples/SneakyThrowsExample_post.jpage | 19 +++++++++++++++++++ usage_examples/SneakyThrowsExample_pre.jpage | 13 +++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 usage_examples/SneakyThrowsExample_post.jpage create mode 100644 usage_examples/SneakyThrowsExample_pre.jpage (limited to 'usage_examples') diff --git a/usage_examples/SneakyThrowsExample_post.jpage b/usage_examples/SneakyThrowsExample_post.jpage new file mode 100644 index 00000000..916d94f0 --- /dev/null +++ b/usage_examples/SneakyThrowsExample_post.jpage @@ -0,0 +1,19 @@ +import lombok.Lombok; + +public class SneakyThrowsExample implements Runnable { + public String utf8ToString(byte[] bytes) { + try { + return new String(bytes, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw Lombok.sneakyThrow(e); + } + } + + public void run() { + try { + throw new Throwable(); + } catch (Throwable t) { + throw Lombok.sneakyThrow(t); + } + } +} diff --git a/usage_examples/SneakyThrowsExample_pre.jpage b/usage_examples/SneakyThrowsExample_pre.jpage new file mode 100644 index 00000000..be6d72d5 --- /dev/null +++ b/usage_examples/SneakyThrowsExample_pre.jpage @@ -0,0 +1,13 @@ +import lombok.SneakyThrows; + +public class SneakyThrowsExample implements Runnable { + @SneakyThrows(UnsupportedEncodingException.class) + public String utf8ToString(byte[] bytes) { + return new String(bytes, "UTF-8"); + } + + @SneakyThrows + public void run() { + throw new Throwable(); + } +} -- cgit