FailFast plugin

Adds pre and postcondition checks to your builds.

Лицензия

Лицензия

Группа

Группа

com.nhaarman.failfast
Идентификатор

Идентификатор

plugin
Последняя версия

Последняя версия

0.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

FailFast plugin
Adds pre and postcondition checks to your builds.
Ссылка на сайт

Ссылка на сайт

https://github.com/nhaarman/failfast/
Система контроля версий

Система контроля версий

https://github.com/nhaarman/failfast/

Скачать plugin

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.nhaarman.failfast/plugin/ -->
<dependency>
    <groupId>com.nhaarman.failfast</groupId>
    <artifactId>plugin</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.nhaarman.failfast/plugin/
implementation 'com.nhaarman.failfast:plugin:0.0.1'
// https://jarcasting.com/artifacts/com.nhaarman.failfast/plugin/
implementation ("com.nhaarman.failfast:plugin:0.0.1")
'com.nhaarman.failfast:plugin:jar:0.0.1'
<dependency org="com.nhaarman.failfast" name="plugin" rev="0.0.1">
  <artifact name="plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.nhaarman.failfast', module='plugin', version='0.0.1')
)
libraryDependencies += "com.nhaarman.failfast" % "plugin" % "0.0.1"
[com.nhaarman.failfast/plugin "0.0.1"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
com.android.tools.build : gradle jar 0.12.2
org.aspectj : aspectjtools jar 1.8.1
org.aspectj : aspectjrt jar 1.8.1

Модули Проекта

Данный проект не имеет модулей.

FailFast (Experimental)

![Gitter](https://badges.gitter.im/Join Chat.svg) FailFast provides implicit contract checks to your methods.

IntelliJ and Android Studio provide static inspections for methods and parameters annotated with @NotNull. When a method is called with a null value to a parameter marked as NotNull, a warning is presented.

This is not enforced however, and null can be passed, possibly leading to errors which can be hard to debug. A solution is to check each and every parameter which is annotated as NotNull:

public void myMethod(@NotNull final String message){
	if(message == null) {
		throw new NullPointerException("message == null");
	}

	/* Rest of method */
}

This fast fail method is an excellent way to prevent those hard to debug errors. Unfortunately, it requires you writing a lot of code, and it doesn't get your code any cleaner.

FailFast injects these snippets for you compile time, so you don't have to, and your source code stays clean.

Usage

Just annotate your methods and parameters with the @NotNull annotation, and FailFast will do the rest:

@NotNull
public String concatenate(@NotNull final String first, @NotNull final String second) {
	return first.concat(second);
}

Whenever the concatenate method is called with a null value, FailFast will throw a NullPointerException:

concatenate("Hello", null);

java.lang.NullPointerException: Parameter "second" of method "concatenate" was specified as @NotNull, but null was given.
	at com.myApp.MyActivity.onCreate(MyActivity.java:19)

Setup

buildscript {
  repositories {
    mavenCentral()
  }

  dependencies {
    classpath 'com.nhaarman.failfast:plugin:0.0.1'
  }
}

apply plugin: 'com.android.application'
apply plugin: 'com.nhaarman.failfast'

Supported annotations:

  • org.jetbrains.annotations.NotNull
  • android.support.annotation.NonNull

Contribute

Please do! I'm happy to review and accept pull requests.
Please read Contributing before you do.

Developed By

  • Niek Haarman

Special Thanks

License

Copyright 2014 Niek Haarman

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Версии библиотеки

Версия
0.0.1