]
David Lloyd commented on LOGTOOL-109:
-------------------------------------
I disagree with this one. We don't need a proliferation of null check methods; in fact
everyone should be using Assert.checkNullParam from wildfly-common for this.
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.