mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
c72bc8c721
commit
18daa4b431
@ -357,8 +357,13 @@ public class BooleanUtil {
|
|||||||
if (ArrayUtil.isEmpty(array)) {
|
if (ArrayUtil.isEmpty(array)) {
|
||||||
throw new IllegalArgumentException("The Array must not be empty !");
|
throw new IllegalArgumentException("The Array must not be empty !");
|
||||||
}
|
}
|
||||||
final boolean[] primitive = Convert.convert(boolean[].class, array);
|
|
||||||
return and(primitive);
|
for (final Boolean b : array) {
|
||||||
|
if(isFalse(b)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -408,8 +413,13 @@ public class BooleanUtil {
|
|||||||
if (ArrayUtil.isEmpty(array)) {
|
if (ArrayUtil.isEmpty(array)) {
|
||||||
throw new IllegalArgumentException("The Array must not be empty !");
|
throw new IllegalArgumentException("The Array must not be empty !");
|
||||||
}
|
}
|
||||||
final boolean[] primitive = Convert.convert(boolean[].class, array);
|
|
||||||
return or(primitive);
|
for (final Boolean b : array) {
|
||||||
|
if(isTrue(b)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1228,7 +1228,8 @@ public class PrimitiveArrayUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 包装类数组转为原始类型数组
|
* 包装类数组转为原始类型数组<br>
|
||||||
|
* {@code null} 按照 {@code false} 对待
|
||||||
*
|
*
|
||||||
* @param values 包装类型数组
|
* @param values 包装类型数组
|
||||||
* @return 原始类型数组
|
* @return 原始类型数组
|
||||||
|
@ -23,20 +23,67 @@ public class BooleanUtilTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void andTest(){
|
public void andTest() {
|
||||||
Assert.assertFalse(BooleanUtil.and(true,false));
|
Assert.assertFalse(BooleanUtil.and(true, false));
|
||||||
Assert.assertFalse(BooleanUtil.andOfWrap(true,false));
|
Assert.assertFalse(BooleanUtil.andOfWrap(true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void orTest(){
|
public void orTest() {
|
||||||
Assert.assertTrue(BooleanUtil.or(true,false));
|
Assert.assertTrue(BooleanUtil.or(true, false));
|
||||||
Assert.assertTrue(BooleanUtil.orOfWrap(true,false));
|
Assert.assertTrue(BooleanUtil.orOfWrap(true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void xorTest(){
|
public void xorTest() {
|
||||||
Assert.assertTrue(BooleanUtil.xor(true,false));
|
Assert.assertTrue(BooleanUtil.xor(true, false));
|
||||||
Assert.assertTrue(BooleanUtil.xorOfWrap(true,false));
|
Assert.assertTrue(BooleanUtil.xorOfWrap(true, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
@Test
|
||||||
|
public void isTrueIsFalseTest() {
|
||||||
|
Assert.assertFalse(BooleanUtil.isTrue(null));
|
||||||
|
Assert.assertFalse(BooleanUtil.isFalse(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void orOfWrapTest() {
|
||||||
|
Assert.assertFalse(BooleanUtil.orOfWrap(Boolean.FALSE, null));
|
||||||
|
Assert.assertTrue(BooleanUtil.orOfWrap(Boolean.TRUE, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
@Test
|
||||||
|
public void negateTest() {
|
||||||
|
Assert.assertFalse(BooleanUtil.negate(Boolean.TRUE));
|
||||||
|
Assert.assertTrue(BooleanUtil.negate(Boolean.FALSE));
|
||||||
|
|
||||||
|
Assert.assertFalse(BooleanUtil.negate(Boolean.TRUE.booleanValue()));
|
||||||
|
Assert.assertTrue(BooleanUtil.negate(Boolean.FALSE.booleanValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toStringTest() {
|
||||||
|
Assert.assertEquals("true", BooleanUtil.toStringTrueFalse(true));
|
||||||
|
Assert.assertEquals("false", BooleanUtil.toStringTrueFalse(false));
|
||||||
|
|
||||||
|
Assert.assertEquals("yes", BooleanUtil.toStringYesNo(true));
|
||||||
|
Assert.assertEquals("no", BooleanUtil.toStringYesNo(false));
|
||||||
|
|
||||||
|
Assert.assertEquals("on", BooleanUtil.toStringOnOff(true));
|
||||||
|
Assert.assertEquals("off", BooleanUtil.toStringOnOff(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
@Test
|
||||||
|
public void toBooleanObjectTest(){
|
||||||
|
Assert.assertTrue(BooleanUtil.toBooleanObject("yes"));
|
||||||
|
Assert.assertTrue(BooleanUtil.toBooleanObject("真"));
|
||||||
|
Assert.assertTrue(BooleanUtil.toBooleanObject("是"));
|
||||||
|
Assert.assertTrue(BooleanUtil.toBooleanObject("√"));
|
||||||
|
|
||||||
|
Assert.assertNull(BooleanUtil.toBooleanObject(null));
|
||||||
|
Assert.assertNull(BooleanUtil.toBooleanObject("不识别"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user