@Nullable @NotEmpty and Identifiers (and the like)
Rod Widdowson
rdw at steadingsoftware.com
Tue Apr 17 15:28:00 BST 2012
So here's a question, mostly for Chad.
As I've been working through the IdP unit tests I've been adding the obvious Annotations to code which predates the conventions in
https://wiki.shibboleth.net/confluence/display/DEV/Java+Coding+Conventions being solidified.
A pretty common paradigm is:
class Foo extends AbstractInitializableComponent {
private String thing;
public String getThing() {...}
public void setThing(String newThing) {...}
public void doInitialize() {
...
if (null == thing) {
throw("thing cannot be null of empty");
}
}
'thing' is often the identifier, but not always.
My question is, with what annotation should getThing() be garnished? Strictly speaking it should be @Nullable, but we do add the
test to make sure that after initialization it will never be null or empty. There is obvious code and/or annotations which can be
added to make sure that getThing() will never return null with that in place stage we could make getThing @NonNull @NotEmpty.
But should we or do we just live with getThing() being @Nullable.
Note that I am *NOT* proposing that we add a new annotation.
More information about the dev
mailing list