com.github.sebhoss.contract:contract-guice-ognl

Annotation-based design by contract library.

License

License

Categories

Categories

GUI User Interface Guice Application Layer Libs Dependency Injection
GroupId

GroupId

com.github.sebhoss.contract
ArtifactId

ArtifactId

contract-guice-ognl
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Annotation-based design by contract library.

Download contract-guice-ognl

How to add to project

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

Dependencies

compile (8)

Group / Artifact Type Version
com.github.sebhoss.contract : contract-guice-defaults jar 1.0.0
com.github.sebhoss.contract : contract-ognl jar 1.0.0
com.github.sebhoss.contract : contract-aop jar 1.0.0
com.github.sebhoss.contract : contract-paranamer jar 1.0.0
com.google.inject : guice jar
com.google.inject.extensions : guice-multibindings 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