Skip to content

Pre-, Post- and Class validation annotations #8

Description

@stijn-dejongh

Outline

Implement the ideas from the Eiffel language regarding design by contract in Java.

Implementation Notes

  • Ideally, these are specified as annotations pointing to RuleSet objects
  • Other than the Eiffel counterpart, these condition statements should be validated on build-time execution, by informing test-cases, rather than crashing the program during runtime processing.
  • Will likely require AOP implementation of sorts

Usage Desisderata

@ValidatedBy(aValid(SomeObject.class).must(notBeNull).must(haveNonNullField(SomeObject::name)).iHaveSpoken())
class SomeObject {

    private String name;
    
    @PreCondition(adheresTo=aValid(SomeObject.class).must(haveNonNullField(SomeObject::name)).iHaveSpoken())
    @PostCondition(adheresTo=aValid(SomeObject.class).must(haveNonNullField(SomeObject::name)).iHaveSpoken())
    public Result doSomething(InputClass input) {
    
    }
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions