diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-07-16 20:56:35 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-07-16 21:05:48 +0200 |
commit | c09481eb8e1475c9495c6d5a59df7234803b2a95 (patch) | |
tree | 762f8a74ce1a02188144dbde86791e61450db88c /test/transform/resource/before/ExtensionMethodPlain.java | |
parent | 06826342f3be58cfb422f291f89e29be2cfde7f0 (diff) | |
download | lombok-c09481eb8e1475c9495c6d5a59df7234803b2a95.tar.gz lombok-c09481eb8e1475c9495c6d5a59df7234803b2a95.tar.bz2 lombok-c09481eb8e1475c9495c6d5a59df7234803b2a95.zip |
Added tests for @ExtensionMethod
Diffstat (limited to 'test/transform/resource/before/ExtensionMethodPlain.java')
-rw-r--r-- | test/transform/resource/before/ExtensionMethodPlain.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/transform/resource/before/ExtensionMethodPlain.java b/test/transform/resource/before/ExtensionMethodPlain.java new file mode 100644 index 00000000..8c2f369d --- /dev/null +++ b/test/transform/resource/before/ExtensionMethodPlain.java @@ -0,0 +1,23 @@ +import lombok.experimental.ExtensionMethod; + +@ExtensionMethod({java.util.Arrays.class, ExtensionMethodPlain.Extensions.class}) +class ExtensionMethodPlain { + public String test() { + int[] intArray = {5, 3, 8, 2}; + intArray.sort(); + + String iAmNull = null; + return iAmNull.or("hELlO, WORlD!".toTitleCase()); + } + + static class Extensions { + public static <T> T or(T obj, T ifNull) { + return obj != null ? obj : ifNull; + } + + public static String toTitleCase(String in) { + if (in.isEmpty()) return in; + return "" + Character.toTitleCase(in.charAt(0)) + in.substring(1).toLowerCase(); + } + } +} |