diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2021-04-16 06:40:35 +0200 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2021-04-16 06:40:35 +0200 |
commit | 415e303ac283df8d694b311f4f8df08f6e79cf0e (patch) | |
tree | 99c4e502fdb90db2e8e1e27ebf855b236ac41b59 /src/core/lombok/experimental | |
parent | 2e212de523407c8d9f4471fea573c6c70164513b (diff) | |
download | lombok-415e303ac283df8d694b311f4f8df08f6e79cf0e.tar.gz lombok-415e303ac283df8d694b311f4f8df08f6e79cf0e.tar.bz2 lombok-415e303ac283df8d694b311f4f8df08f6e79cf0e.zip |
[pr 2702] finishing the `@StandardException` feature.
* rewritten how it works a bit: Now compatible with parent exceptions that don't have the Throwable variants.
* rewritten how it works a bit: You can now provide the full constructor only; the rest will forward to it.
* fixing up style.
* rewrite the docs.
Diffstat (limited to 'src/core/lombok/experimental')
-rw-r--r-- | src/core/lombok/experimental/StandardException.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/core/lombok/experimental/StandardException.java b/src/core/lombok/experimental/StandardException.java index 9f8a4e65..b04ac2ee 100644 --- a/src/core/lombok/experimental/StandardException.java +++ b/src/core/lombok/experimental/StandardException.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2017 The Project Lombok Authors. + * Copyright (C) 2021 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,9 +26,25 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import lombok.AccessLevel; + /** + * Put on any class that extends some {@code java.lang.Throwable} type to add the 4 common exception constructors. + * + * Specifically, all 4 constructors derived from the combinatorial explosion of {@code String message} and {@code Throwable cause}. + * You may write any or all of these 4 constructors by hand; lombok will only generate the missing ones. + * <p> + * All but the full {@code (String message, Throwable cause)} constructor are implemented as a {@code this(msg, cause)} call; it is therefore + * possibly to write code to run on construction by writing just the {@code (String message, Throwable cause)} constructor. */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.SOURCE) public @interface StandardException { + /** + * Sets the access level of the generated constuctors. By default, generated constructors are {@code public}. + * Note: This does nothing if you write your own constructors (we won't change their access levels). + * + * @return The constructors will be generated with this access modifier. + */ + AccessLevel access() default lombok.AccessLevel.PUBLIC; } |