Giter Site home page Giter Site logo

bspec-java's Introduction

bspec-java

Build Status

A Java library for structuring business rules.

Requirements

bspec-java can be included in any Java or Android application.

Installation

Add the following line to the dependencies section of your build.gradle file:

compile 'com.github.gchudnov.bspec:bspec:0.9.0'

Usage

The essential part of the library is a specification -- an object with the following properties:

  • it can be combined with other specification-objects using .and(), .or() and .not() methods to form a composite specification and express more complex rules.
  • it implements isSatisfiedBy method -- a predicate that determines whether a candidate object does or does not satisfy some criteria.

To create a composable specification, extend CompositeSpecification and define the isSatisfiedBy method to check for some condition.

API

.and(otherSpec): Specification<T>

the and of a set of specifications is true if and only if all of its operands are true.

spec = spec1.and(spec2);

.or(otherSpec): Specification<T>

the or of a set of specifications is true if and only if one or more of its operands is true

spec = spec1.or(spec2);

.not(): Specification<T>

not negates the specification

spec = spec1.not();

.isSatisfiedBy(final T candidate): boolean

checks whether some candidate object satisfies the specification.

  boolean result = spec.isSatisfiedBy(obj);
  
  // `result` true|false value

For the details of usage, take a look at the examples section in the project.

Contact

[Grigoriy Chudnov] (mailto:[email protected])

License

Distributed under the The MIT License (MIT).

bspec-java's People

Contributors

gchudnov avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.