Wednesday 5 September 2012

Quality-Check for Java

André Rouél and I startet a new OpenSource project to avoid technical errors in Java applications: Quality-Check.

The goal of quality-check is to provide a small Java library for basic runtime code quality checks. It provides similar features to org.springframework.util.Assert or com.google.common.base.Preconditions without the need to include big libraries or frameworks such as Spring or Guava. 
The package quality-check tries to replace these libraries and provide all the basic code quality checks.

Example


/**
 * Sets the given object if it is not null.
 * 
 * @throws IllegalArgumentException
 *         if the given argument is {@code null}
 */
public void setObject(final Object object) {
    if (object != null) {
        throw new IllegalArgumentException("Argument 'object' must not be null.");
    }
    this.object = object;
}


can be replaces by:

/**
 * Sets the given object if it is not null.
 */
@ArgumentsChecked
public void setObject(final Object object) {
    this.object = Check.notNull(object);
}

It is now available in Maven Central so adding it to your project is as simple as putting these five lines into your pom.xml:
<dependency>
<groupid>net.sf.qualitycheck</groupid>
<artifactid>quality-check</artifactid>
<version>0.9</version>
</dependency>

Please take also a look at our webpage or our project at GitHub.

3 comments:

Fabien said...

I use commons-lang. It's widely used and sufficient for me :
https://commons.apache.org/lang/api-2.3/org/apache/commons/lang/Validate.html
You should clarify the differences on your website, and more importantly : put the javadoc online !

Unknown said...

Hi, thank you for pointing this out. We've prepared a comparison table for internal usage, but we should make it available on projects website.

The JavaDoc is already available, but a little bit hidden. Look at http://qualitycheck.sourceforge.net/modules/quality-check/apidocs/index.html to get more insight.

Jie Janet said...

I accidentally viewed your blog and I was so amazed with your work that it touched the deepness of my heart and it made me sentimental. Thanks for posting. Visit my site to buy fake montblanc watches