determine if an Object is of primitive type
This commit is contained in:
parent
f29c757e18
commit
6e43adc107
|
@ -23,7 +23,7 @@ public class PrimitiveTypeUtil {
|
||||||
WRAPPER_TYPE_MAP.put(Void.class, void.class);
|
WRAPPER_TYPE_MAP.put(Void.class, void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPrimitiveTypeByCommansLang(Object source) {
|
public boolean isPrimitiveTypeByCommonsLang(Object source) {
|
||||||
return ClassUtils.isPrimitiveOrWrapper(source.getClass());
|
return ClassUtils.isPrimitiveOrWrapper(source.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@ public class PrimitiveTypeUtilTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenObjectWhenCheckWithCommonsLangShouldValidate() {
|
public void givenObjectWhenCheckWithCommonsLangShouldValidate() {
|
||||||
assertTrue(primitiveTypeUtil.isPrimitiveTypeByCommansLang(booleanVal));
|
assertTrue(primitiveTypeUtil.isPrimitiveTypeByCommonsLang(booleanVal));
|
||||||
assertTrue(primitiveTypeUtil.isPrimitiveTypeByCommansLang(longWrapper));
|
assertTrue(primitiveTypeUtil.isPrimitiveTypeByCommonsLang(longWrapper));
|
||||||
assertFalse(primitiveTypeUtil.isPrimitiveTypeByCommansLang(nonPrimitiveVal));
|
assertFalse(primitiveTypeUtil.isPrimitiveTypeByCommonsLang(nonPrimitiveVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue