本文整理了Java中org.apache.commons.lang3.BooleanUtils.toBooleanObject()
方法的一些代码示例,展示了BooleanUtils.toBooleanObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BooleanUtils.toBooleanObject()
方法的具体详情如下:
包路径:org.apache.commons.lang3.BooleanUtils
类名称:BooleanUtils
方法名:toBooleanObject
[英]Converts an int to a Boolean using the convention that zerois false.
BooleanUtils.toBoolean(0) = Boolean.FALSE
BooleanUtils.toBoolean(1) = Boolean.TRUE
BooleanUtils.toBoolean(2) = Boolean.TRUE
[中]使用zerois false的约定将int转换为布尔值。
BooleanUtils.toBoolean(0) = Boolean.FALSE
BooleanUtils.toBoolean(1) = Boolean.TRUE
BooleanUtils.toBoolean(2) = Boolean.TRUE
代码示例来源:origin: springside/springside4
/**
* 支持true/false, on/off, y/n, yes/no的转换, str为空或无法分析时返回null
*/
public static Boolean parseGeneralString(String str) {
return BooleanUtils.toBooleanObject(str);
}
代码示例来源:origin: ethereum/ethereumj
private static Boolean interpret(String arg) {
return BooleanUtils.toBooleanObject(arg);
}
代码示例来源:origin: org.apache.commons/commons-lang3
return toBooleanObject(str) == Boolean.TRUE;
代码示例来源:origin: springside/springside4
/**
* 支持true/false,on/off, y/n, yes/no的转换, str为空或无法分析时返回defaultValue
*/
public static Boolean parseGeneralString(String str, Boolean defaultValue) {
return BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(str), defaultValue);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test(expected = IllegalArgumentException.class)
public void test_toBooleanObject_String_String_String_String_nullValue() {
BooleanUtils.toBooleanObject(null, "Y", "N", "U");
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test(expected = IllegalArgumentException.class)
public void test_toBooleanObject_int_int_int_noMatch() {
BooleanUtils.toBooleanObject(9, 6, 7, 8);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test(expected = IllegalArgumentException.class)
public void test_toBooleanObject_String_String_String_String_noMatch() {
BooleanUtils.toBooleanObject("X", "Y", "N", "U");
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test(expected = IllegalArgumentException.class)
public void test_toBooleanObject_Integer_Integer_Integer_Integer_nullValue() {
BooleanUtils.toBooleanObject(null, Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test(expected = IllegalArgumentException.class)
public void test_toBooleanObject_Integer_Integer_Integer_Integer_noMatch() {
BooleanUtils.toBooleanObject(Integer.valueOf(9), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
final Integer six = Integer.valueOf(6);
final Integer seven = Integer.valueOf(7);
final Integer eight = Integer.valueOf(8);
assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(null, null, seven, eight));
assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject(null, six, null, eight));
assertSame(null, BooleanUtils.toBooleanObject(null, six, seven, null));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(6), six, seven, eight));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(7), six, seven, eight));
assertNull(BooleanUtils.toBooleanObject(Integer.valueOf(8), six, seven, eight));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void test_toBooleanObject_String_String_String_String() {
assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(null, null, "N", "U"));
assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject(null, "Y", null, "U"));
assertSame(null, BooleanUtils.toBooleanObject(null, "Y", "N", null));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y", "Y", "N", "U"));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N", "Y", "N", "U"));
assertNull(BooleanUtils.toBooleanObject("U", "Y", "N", "U"));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void test_toBooleanObject_Integer() {
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(1)));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(-1)));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(0)));
assertNull(BooleanUtils.toBooleanObject((Integer) null));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void test_toBooleanObject_int_int_int() {
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(6, 6, 7, 8));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(7, 6, 7, 8));
assertNull(BooleanUtils.toBooleanObject(8, 6, 7, 8));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void test_toBooleanObject_int() {
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(1));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(-1));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(0));
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void test_toBooleanObject_String() {
assertNull(BooleanUtils.toBooleanObject((String) null));
assertNull(BooleanUtils.toBooleanObject(""));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("false"));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("no"));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("off"));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("FALSE"));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("NO"));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("OFF"));
assertNull(BooleanUtils.toBooleanObject("oof"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("true"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("yes"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("on"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TRUE"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("ON"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("YES"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TruE"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TruE"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("y")); // yes
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("t")); // true
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("T"));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("f")); // false
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("F"));
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("n")); // No
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N"));
assertNull(BooleanUtils.toBooleanObject("z"));
代码示例来源:origin: spring-projects/spring-roo
@Override
public Boolean getBooleanProperty(String key, Boolean defaultValue) {
String value = getProperty(key);
if (value == null) {
return defaultValue;
}
return ObjectUtils.defaultIfNull(BooleanUtils.toBooleanObject(value), defaultValue);
}
代码示例来源:origin: org.apache.commons/commons-configuration2
final Boolean b = BooleanUtils.toBooleanObject((String) value);
if (b == null)
代码示例来源:origin: apiman/apiman
public boolean isOverwrite() {
Boolean booleanObject = BooleanUtils.toBooleanObject(System.getProperty(OVERWRITE));
if (booleanObject == null) {
booleanObject = Boolean.FALSE;
}
return booleanObject;
}
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Behaves much like org.apache.commons.lang3.BooleanUtils but returns the defaultValue if
* the input string is null, empty, or unrecognized.
*/
public static boolean toBoolean(String s, boolean defaultValue) {
final Boolean b = BooleanUtils.toBooleanObject(s);
return b == null ? defaultValue : b.booleanValue();
}
代码示例来源:origin: apiman/apiman
private Boolean parseBoolValue(Object object) {
if (object instanceof Boolean) {
return (Boolean) object;
} else if (object instanceof Number) {
Byte num = ((Number) object).byteValue();
return num > 0;
}
return BooleanUtils.toBooleanObject(String.valueOf(object));
}
内容来源于网络,如有侵权,请联系作者删除!