One of my colleague decided to declare some API code like this:
public interface Filter<T> {
/**
* Test whether the given input is valid.
* @param input the input
* @return null for neutral, {@code Boolean.TRUE} for accepted and {@code Boolean.FALSE} for rejected.
*/
Boolean apply(T input);
}
The idea generated a war on the IRC. While some is advocating the Boolean
approach, the others think it bad practice and should use an enum of three elements to represent the indiviual state, like this:
public interface Filter<T> {
Result apply(T input);
enum Result {
ACCEPT, UNKNOWN, DENIED;
}
}
So, in terms of performance, readability, maintainability or, well, if it really matters, less code, what is the best practice in production?
EDIT: Here, ACCEPT, UNKNOWN( or NEUTRAL), REJECT( or DENY) is what @erickson means. If you gpt confused, please refer to his anwser if you get confused.
In respond to the "put on hold", I clarify that my question mainly concerns on: * Is there a clear convention of this?* this is the reason for accepted anwser