[jboss-jira] [JBoss JIRA] (LOGTOOL-109) Create @NotNull or @RequiresNonNull annotation to allow null checks with custom exception
James Perkins (JIRA)
issues at jboss.org
Wed Jun 8 11:18:00 EDT 2016
[ https://issues.jboss.org/browse/LOGTOOL-109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
James Perkins closed LOGTOOL-109.
---------------------------------
Resolution: Won't Do
I wasn't aware of the wildfly-common assertions.
> Create @NotNull or @RequiresNonNull annotation to allow null checks with custom exception
> -----------------------------------------------------------------------------------------
>
> Key: LOGTOOL-109
> URL: https://issues.jboss.org/browse/LOGTOOL-109
> Project: Log Tool
> Issue Type: Feature Request
> Reporter: James Perkins
>
> Use an {{@NotNull}} or {{@RequiresNonNull}} annotation on a method to generate a {{null}} check and throw, by default, an {{IllegalArgumentException}} if null. Also clean the stack trace.
> {code:java|title=Example Interface}
> @Message(id = 123, value = "Name cannot be null")
> @NotNull(IllegalArgumentException.class)
> void requireNotNull(String name);
> {code}
> {code:java|title=Example Generated Code}
> @Override
> public void requireNotNull(final String name) {
> if (name == null) {
> final IllegalArgumentException result = new IllegalArgumentException(String.format(invalidUser$str(), name));
> final StackTraceElement[] st = result.getStackTrace();
> result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
> }
> }
> {code}
> The {{@Param}} annotation could be used along with {{@Pos}} for formatting possibly.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list