public MailProtocol(String protocolLabel, String protocol) {
Assert.notNull(protocolLabel, "Protocol label required");
Assert.notNull(protocol, "protocol required");
...
public AbstractInvocableMemberMetadata(String declaredByMetadataId, int modifier, List parameters, List parameterNames, List annotations, String body) {
Assert.hasText(declaredByMetadataId, "Declared by metadata ID required");
...
I think the Spring Roo way is a good hint for Design by Contract / Preconditions as tests in Java, which is not support native in the Java language. The Java asserts can be disabled the spring roo Asserts throws RuntimeExceptions...
Other Java Framework for Design by Contract:
- Oval - http://oval.sourceforge.net/
- Design by Contract Framework for Spring Applications - http://springcontracts.sourceforge.net/home.html
- Spring Roo Assert API - see Spring Roo GIT http://git.springsource.org/roo/roo/blobs/master/support/src/main/java/org/springframework/roo/support/util/Assert.java
- Spring Roo - http://www.springsource.org/roo
- Eiffel and Design by Contract http://www.eiffel.com/developers/design_by_contract_in_detail.html
- Eiffel - http://www.eiffel.com/
- D
- Spec# - http://research.microsoft.com/specsharp/
There is a Groovy extension that supports Design by Contract too - GContracts (http://github.com/andresteingress/gcontracts). It uses Groovy's AST transformations to inject class invariants, pre- and postconditions during compile time. It even has support for assertion inheritance.
AntwortenLöschen