com.github.sebhoss.contract:contract-spring-jexl

Annotation-based design by contract library.

License

License

GroupId

GroupId

com.github.sebhoss.contract
ArtifactId

ArtifactId

contract-spring-jexl
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Annotation-based design by contract library.

Download contract-spring-jexl

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.sebhoss.contract/contract-spring-jexl/ -->
<dependency>
    <groupId>com.github.sebhoss.contract</groupId>
    <artifactId>contract-spring-jexl</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.sebhoss.contract/contract-spring-jexl/
implementation 'com.github.sebhoss.contract:contract-spring-jexl:1.0.0'
// https://jarcasting.com/artifacts/com.github.sebhoss.contract/contract-spring-jexl/
implementation ("com.github.sebhoss.contract:contract-spring-jexl:1.0.0")
'com.github.sebhoss.contract:contract-spring-jexl:jar:1.0.0'
<dependency org="com.github.sebhoss.contract" name="contract-spring-jexl" rev="1.0.0">
  <artifact name="contract-spring-jexl" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.sebhoss.contract', module='contract-spring-jexl', version='1.0.0')
)
libraryDependencies += "com.github.sebhoss.contract" % "contract-spring-jexl" % "1.0.0"
[com.github.sebhoss.contract/contract-spring-jexl "1.0.0"]

Dependencies

compile (7)

Group / Artifact Type Version
com.github.sebhoss.contract : contract-spring-defaults jar 1.0.0
com.github.sebhoss.contract : contract-jexl jar 1.0.0
com.github.sebhoss.contract : contract-aspect jar 1.0.0
org.springframework : spring-aop jar
org.springframework : spring-aspects jar
com.github.sebhoss : common-annotations jar
ch.qos.cal10n : cal10n-api jar

Project Modules

There are no modules declared in this project.

annotated-contracts

Coverage Status Dependency Status

Design by Contract based on annotations. It allows easy usage of contracts without any need for extra JVM parameters, JVM agents, special classloaders or compilers. Instead it leverages dependency injection to capture method calls which are annotation with a contract. The project is highly flexible and can be extended to support new contract annotations and other contract clause definitions (see below).

Usage

Contracts can only be specified on methods. The following example shows how to do it:

public class ContractExample {

    @Contract(
        preconditions = {
            @Clause(value = "damage > 0", message = "Reported damage must be positive!", exception = IllegalStateException.class),
            @Clause("damage <= 5000")
        },
        postconditions = {
            @Clause("return >= 0"),
            @Clause(value = "return <= 2000", exception = NotEnoughMoneyException.class)
        })
    public double calculateCover(double damage) {
        // .. some calculations
    }

}

The above example shows a method with two pre- and postconditions. The first precondition sets the optional message and exception fields, which are used in case the contract clause was violated. In case the exception message isn’t set, a default no-argument constructor is used, otherwise a constructor with a single String parameter is searched. See the integration matrix below for a framework/language usage guide.

Integration

This library offers several implementations for a variety of other libraries/frameworks. The following configuration matrix shows what is currently supported. Anything missing? Create an issue!:

CDI Guice Spring
JavaScript
JEXL
JUEL
MVEL
OGNL
SpEL
UEL

Development

License

This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See LICENSE or http://www.wtfpl.net/ for more details.

Setup

This projects uses Java, Maven and Git as the main development tools. To build the project yourself just download & install at least Maven 3.0 and call mvn install inside the project folder. Maven should then proceed to clean, build, package and install this project.

Versioning

This project follows the semantic versioning guidelines.

Alternatives

Not what you are looking for? Try one of the alternatives:

Versions

Version
1.0.0