groovy - Where to find a NotNull java annotation -
i searched @notnull
java annotation , found 1 javax. tried use ran same issues described here. in short: need set stuff working - don't need (i in plain java/groovy context, no javaee). there alternatives mentioned annotation work standalone, find those?
oval can this.
download jar http://mvnrepository.com/artifact/net.sf.oval/oval/1.31 , @ documentation here http://oval.sourceforge.net/
for example:
import net.sf.oval.constraint.maxlength; import net.sf.oval.constraint.notempty; import net.sf.oval.constraint.notnull; public class request { @notnull @notempty @maxlength(value = 30) private string id; //.....getters setters...... }
above pojo
/** * method returns if valid request or not */ private boolean isvalid(request request) { list<constraintviolation> violations = validator.validate(request); if (violations.size() > 0) { return false; } else { return true; } }
and validation above.
you can find many more examples online.
Comments
Post a Comment