diff options
author | Roel Spilker <r.spilker@gmail.com> | 2020-03-06 01:17:07 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2020-03-06 01:17:07 +0100 |
commit | 17e48aab62ab1d62f689fe1ffb69badf4dfe01c4 (patch) | |
tree | 8ebd034a447c4363debf95d218cc4ed92d2af7b4 /website/templates/features/experimental/ExtensionMethod.html | |
parent | a79e67713a83a7c99d4a4b0f86c1120f7713f262 (diff) | |
download | lombok-17e48aab62ab1d62f689fe1ffb69badf4dfe01c4.tar.gz lombok-17e48aab62ab1d62f689fe1ffb69badf4dfe01c4.tar.bz2 lombok-17e48aab62ab1d62f689fe1ffb69badf4dfe01c4.zip |
documentation layout fix
Diffstat (limited to 'website/templates/features/experimental/ExtensionMethod.html')
-rw-r--r-- | website/templates/features/experimental/ExtensionMethod.html | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/website/templates/features/experimental/ExtensionMethod.html b/website/templates/features/experimental/ExtensionMethod.html index f1d8b084..1e20c625 100644 --- a/website/templates/features/experimental/ExtensionMethod.html +++ b/website/templates/features/experimental/ExtensionMethod.html @@ -35,16 +35,18 @@ You can pass any number of classes to the <code>@ExtensionMethod</code> annotation; they will all be searched for extension methods. These extension methods apply for any code that is in the annotated class. </p><p> Lombok does not (currently) have any runtime dependencies which means lombok does not (currently) ship with any useful extension methods so you'll have to make your own. However, here's one that might spark your imagination: <br /> + </p> <pre>public class ObjectExtensions { public static <T> T or(T object, T ifNull) { return object != null ? object : ifNull; } }</pre><br /> + <p> With the above class, if you add <code>@ExtensionMethod(ObjectExtensions.class)</code> to your class definition, you can write:<br /> + </p> <pre>String x = null; System.out.println(x.or("Hello, World!"));</pre><br /> The above code will not fail with a <code>NullPointerException</code>; it will actually output <code>Hello, World!</code> - </p> </@f.overview> <@f.snippets name="experimental/ExtensionMethod" /> |