Kind of a long title, but that is generally the question.
I want to know if you think its a good idea to do the following.
Instead of:
public void buyItem(int itemId, int buyerId) {
if (itemId <= 0) {
throw new IlleglArgumentException("itemId must be positive");
}
if (buyerId <= 0) {
throw new IlleglArgumentException("buyerId must be positive");
}
// buy logic
}
I want to have something like:
@Defensive("isPositive(#itemId, #buyerId)")
public void buyItem(int itemId, int buyerId) {
// buy logic
}
Do you think this is good/terrible/too fancy/too slow ? If you actually think its good I was thinking of using SpEL to implement it, does anyone have something better/lighter/faster in mind ?
Thanks,