panda.el.opt.logic.Logics Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of panda-core Show documentation
Show all versions of panda-core Show documentation
Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.
package panda.el.opt.logic;
import panda.lang.Objects;
public class Logics {
public static boolean isTrue(Object o) {
if (o == null) {
return false;
}
if (o instanceof Boolean) {
return ((Boolean)o).booleanValue();
}
if (o instanceof Number) {
return ((Number)o).intValue() != 0;
}
return Objects.isNotEmpty(o);
}
public static boolean isFalse(Object o) {
if (o == null) {
return true;
}
if (o instanceof Boolean) {
return !((Boolean)o).booleanValue();
}
if (o instanceof Number) {
return ((Number)o).intValue() == 0;
}
return Objects.isEmpty(o);
}
}