Java truthy check library (75 lines of code) that will make your code cleaner and safer. Replace all your != null
check statements with is.t(myObject)
:
Boolean isItCleanCode = null;
if (isItCleanCode != null && isItCleanCode) {
//... is it?
}
if (is.t(isItCleanCode)) {
//... probably
}
is.t
will return true
in a following cases:
Boolean | true
String | != ""
Number (Integer, Long, BigDecimal, etc) | != 0
Collection / Map | not empty
File | exists
TruthyCastableI
interface will allow you to make any class checkable by is.t
.
<dependency>
<groupId>io.thedocs</groupId>
<artifactId>soyuz-is</artifactId>
<version>1.0</version>
</dependency>
repositories {
mavenCentral()
}
dependencies {
compile 'io.thedocs:soyuz-is:1.0'
}
import io.thedocs.soyuz.is;
This library depends on com.google.code.findbugs:jsr305
(javax.annotation.Nullable
)
- soyuz-to - simple way to convert
X
data type toY
- soyuz-loge - slf4j wrapper which makes your logs cleaner and easier to read / find
- soyuz-validator - bean fluent validator based on builder pattern
MIT