示例#1
0
 /** Tests if Class represents a primitive number or wrapper.<br> */
 public static boolean isNumber(Class clazz) {
   return clazz != null
       && (Byte.TYPE.isAssignableFrom(clazz)
           || Short.TYPE.isAssignableFrom(clazz)
           || Integer.TYPE.isAssignableFrom(clazz)
           || Long.TYPE.isAssignableFrom(clazz)
           || Float.TYPE.isAssignableFrom(clazz)
           || Double.TYPE.isAssignableFrom(clazz)
           || Number.class.isAssignableFrom(clazz));
 }
示例#2
0
 /**
  * 是否数值
  *
  * @param clazz
  * @return
  */
 public static boolean isNumber(Class<?> clazz) {
   return (clazz != null)
       && ((Byte.TYPE.isAssignableFrom(clazz))
           || (Short.TYPE.isAssignableFrom(clazz))
           || (Integer.TYPE.isAssignableFrom(clazz))
           || (Long.TYPE.isAssignableFrom(clazz))
           || (Float.TYPE.isAssignableFrom(clazz))
           || (Double.TYPE.isAssignableFrom(clazz))
           || (Number.class.isAssignableFrom(clazz)));
 }
示例#3
0
 private boolean compare_PrimitiveArray(
     int operation, Class<?> type, Object primarray, Object value2) {
   if (Integer.TYPE.isAssignableFrom(type)) {
     int[] array = (int[]) primarray;
     for (int value1 : array) {
       if (compare_Integer(operation, value1, value2)) {
         return true;
       }
     }
     return false;
   }
   if (Long.TYPE.isAssignableFrom(type)) {
     long[] array = (long[]) primarray;
     for (long value1 : array) {
       if (compare_Long(operation, value1, value2)) {
         return true;
       }
     }
     return false;
   }
   if (Byte.TYPE.isAssignableFrom(type)) {
     byte[] array = (byte[]) primarray;
     for (byte value1 : array) {
       if (compare_Byte(operation, value1, value2)) {
         return true;
       }
     }
     return false;
   }
   if (Short.TYPE.isAssignableFrom(type)) {
     short[] array = (short[]) primarray;
     for (short value1 : array) {
       if (compare_Short(operation, value1, value2)) {
         return true;
       }
     }
     return false;
   }
   if (Character.TYPE.isAssignableFrom(type)) {
     char[] array = (char[]) primarray;
     for (char value1 : array) {
       if (compare_Character(operation, value1, value2)) {
         return true;
       }
     }
     return false;
   }
   if (Float.TYPE.isAssignableFrom(type)) {
     float[] array = (float[]) primarray;
     for (float value1 : array) {
       if (compare_Float(operation, value1, value2)) {
         return true;
       }
     }
     return false;
   }
   if (Double.TYPE.isAssignableFrom(type)) {
     double[] array = (double[]) primarray;
     for (double value1 : array) {
       if (compare_Double(operation, value1, value2)) {
         return true;
       }
     }
     return false;
   }
   if (Boolean.TYPE.isAssignableFrom(type)) {
     boolean[] array = (boolean[]) primarray;
     for (boolean value1 : array) {
       if (compare_Boolean(operation, value1, value2)) {
         return true;
       }
     }
     return false;
   }
   return false;
 }
示例#4
0
 private boolean compare_PrimitiveArray(
     int operation, Class type, Object primarray, Object value2) {
   if (Integer.TYPE.isAssignableFrom(type)) {
     int[] array = (int[]) primarray;
     for (int i = 0, size = array.length; i < size; i++) {
       if (compare_Integer(operation, array[i], value2)) {
         return true;
       }
     }
     return false;
   }
   if (Long.TYPE.isAssignableFrom(type)) {
     long[] array = (long[]) primarray;
     for (int i = 0, size = array.length; i < size; i++) {
       if (compare_Long(operation, array[i], value2)) {
         return true;
       }
     }
     return false;
   }
   if (Byte.TYPE.isAssignableFrom(type)) {
     byte[] array = (byte[]) primarray;
     for (int i = 0, size = array.length; i < size; i++) {
       if (compare_Byte(operation, array[i], value2)) {
         return true;
       }
     }
     return false;
   }
   if (Short.TYPE.isAssignableFrom(type)) {
     short[] array = (short[]) primarray;
     for (int i = 0, size = array.length; i < size; i++) {
       if (compare_Short(operation, array[i], value2)) {
         return true;
       }
     }
     return false;
   }
   if (Character.TYPE.isAssignableFrom(type)) {
     char[] array = (char[]) primarray;
     for (int i = 0, size = array.length; i < size; i++) {
       if (compare_Character(operation, array[i], value2)) {
         return true;
       }
     }
     return false;
   }
   if (Float.TYPE.isAssignableFrom(type)) {
     float[] array = (float[]) primarray;
     for (int i = 0, size = array.length; i < size; i++) {
       if (compare_Float(operation, array[i], value2)) {
         return true;
       }
     }
     return false;
   }
   if (Double.TYPE.isAssignableFrom(type)) {
     double[] array = (double[]) primarray;
     for (int i = 0, size = array.length; i < size; i++) {
       if (compare_Double(operation, array[i], value2)) {
         return true;
       }
     }
     return false;
   }
   if (Boolean.TYPE.isAssignableFrom(type)) {
     boolean[] array = (boolean[]) primarray;
     for (int i = 0, size = array.length; i < size; i++) {
       if (compare_Boolean(operation, array[i], value2)) {
         return true;
       }
     }
     return false;
   }
   return false;
 }
 public Coercer<Byte> accept(final Class<?> clazz) {
   if (Byte.class.isAssignableFrom(clazz) || Byte.TYPE.isAssignableFrom(clazz)) {
     return DefaultCoercibles.BYTE_COERCER;
   }
   return null;
 }
示例#6
0
 private static void assertExpectedPrimitiveArrays(
     String message,
     Object expected,
     Object actual,
     Class expectedInnerType,
     Class actualInnerType) {
   if (Boolean.TYPE.isAssignableFrom(expectedInnerType)) {
     if (Boolean.TYPE.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (boolean[]) expected, (boolean[]) actual);
     } else if (Boolean.class.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (boolean[]) expected, (Boolean[]) actual);
     } else if (!actualInnerType.isPrimitive()) {
       ArrayAssertions.assertEquals(message, (boolean[]) expected, (Object[]) actual);
     } else {
       failNotEquals(message, expected, actual);
     }
   } else if (Byte.TYPE.isAssignableFrom(expectedInnerType)) {
     if (Byte.TYPE.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (byte[]) expected, (byte[]) actual);
     } else if (Byte.class.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (byte[]) expected, (Byte[]) actual);
     } else if (!actualInnerType.isPrimitive()) {
       ArrayAssertions.assertEquals(message, (byte[]) expected, (Object[]) actual);
     } else {
       failNotEquals(message, expected, actual);
     }
   } else if (Short.TYPE.isAssignableFrom(expectedInnerType)) {
     if (Short.TYPE.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (short[]) expected, (short[]) actual);
     } else if (Short.class.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (short[]) expected, (Short[]) actual);
     } else if (!actualInnerType.isPrimitive()) {
       ArrayAssertions.assertEquals(message, (short[]) expected, (Object[]) actual);
     } else {
       failNotEquals(message, expected, actual);
     }
   } else if (Integer.TYPE.isAssignableFrom(expectedInnerType)) {
     if (Integer.TYPE.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (int[]) expected, (int[]) actual);
     } else if (Integer.class.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (int[]) expected, (Integer[]) actual);
     } else if (!actualInnerType.isPrimitive()) {
       ArrayAssertions.assertEquals(message, (int[]) expected, (Object[]) actual);
     } else {
       failNotEquals(message, expected, actual);
     }
   } else if (Long.TYPE.isAssignableFrom(expectedInnerType)) {
     if (Long.TYPE.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (long[]) expected, (long[]) actual);
     } else if (Long.class.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (long[]) expected, (Long[]) actual);
     } else if (!actualInnerType.isPrimitive()) {
       ArrayAssertions.assertEquals(message, (long[]) expected, (Object[]) actual);
     } else {
       failNotEquals(message, expected, actual);
     }
   } else if (Float.TYPE.isAssignableFrom(expectedInnerType)) {
     if (Float.TYPE.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (float[]) expected, (float[]) actual);
     } else if (Float.class.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (float[]) expected, (Float[]) actual);
     } else if (!actualInnerType.isPrimitive()) {
       ArrayAssertions.assertEquals(message, (float[]) expected, (Object[]) actual);
     } else {
       failNotEquals(message, expected, actual);
     }
   } else if (Double.TYPE.isAssignableFrom(expectedInnerType)) {
     if (Double.TYPE.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (double[]) expected, (double[]) actual);
     } else if (Double.class.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (double[]) expected, (Double[]) actual);
     } else if (!actualInnerType.isPrimitive()) {
       ArrayAssertions.assertEquals(message, (double[]) expected, (Object[]) actual);
     } else {
       failNotEquals(message, expected, actual);
     }
   } else if (Character.TYPE.isAssignableFrom(expectedInnerType)) {
     if (Character.TYPE.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (char[]) expected, (char[]) actual);
     } else if (Character.class.isAssignableFrom(actualInnerType)) {
       ArrayAssertions.assertEquals(message, (char[]) expected, (Character[]) actual);
     } else if (!actualInnerType.isPrimitive()) {
       ArrayAssertions.assertEquals(message, (char[]) expected, (Object[]) actual);
     } else {
       failNotEquals(message, expected, actual);
     }
   }
 }