コード例 #1
0
 /** Attempt to convert a typed value to a boolean using the supplied type converter. */
 public static boolean toBoolean(TypeConverter typeConverter, TypedValue typedValue) {
   return (Boolean)
       typeConverter.convertValue(
           typedValue.getValue(),
           typedValue.getTypeDescriptor(),
           TypeDescriptor.valueOf(Boolean.class));
 }
コード例 #2
0
 /** Attempt to convert a typed value to a byte using the supplied type converter. */
 public static byte toByte(TypeConverter typeConverter, TypedValue typedValue) {
   return (Byte)
       typeConverter.convertValue(
           typedValue.getValue(),
           typedValue.getTypeDescriptor(),
           TypeDescriptor.valueOf(Byte.class));
 }
コード例 #3
0
 /** Attempt to convert a typed value to an int using the supplied type converter. */
 public static int toInt(TypeConverter typeConverter, TypedValue typedValue) {
   return (Integer)
       typeConverter.convertValue(
           typedValue.getValue(),
           typedValue.getTypeDescriptor(),
           TypeDescriptor.valueOf(Integer.class));
 }
コード例 #4
0
 /** Attempt to convert a typed value to a float using the supplied type converter. */
 public static float toFloat(TypeConverter typeConverter, TypedValue typedValue) {
   return (Float)
       typeConverter.convertValue(
           typedValue.getValue(),
           typedValue.getTypeDescriptor(),
           TypeDescriptor.valueOf(Float.class));
 }
コード例 #5
0
 /** Attempt to convert a typed value to a short using the supplied type converter. */
 public static short toShort(TypeConverter typeConverter, TypedValue typedValue) {
   return (Short)
       typeConverter.convertValue(
           typedValue.getValue(),
           typedValue.getTypeDescriptor(),
           TypeDescriptor.valueOf(Short.class));
 }
コード例 #6
0
 /** Attempt to convert a typed value to a char using the supplied type converter. */
 public static char toChar(TypeConverter typeConverter, TypedValue typedValue) {
   return (Character)
       typeConverter.convertValue(
           typedValue.getValue(),
           typedValue.getTypeDescriptor(),
           TypeDescriptor.valueOf(Character.class));
 }
コード例 #7
0
 /** Attempt to convert a typed value to a long using the supplied type converter. */
 public static long toLong(TypeConverter typeConverter, TypedValue typedValue) {
   return (Long)
       typeConverter.convertValue(
           typedValue.getValue(),
           typedValue.getTypeDescriptor(),
           TypeDescriptor.valueOf(Long.class));
 }
コード例 #8
0
 /** Attempt to convert a typed value to a double using the supplied type converter. */
 public static double toDouble(TypeConverter typeConverter, TypedValue typedValue) {
   return (Double)
       typeConverter.convertValue(
           typedValue.getValue(),
           typedValue.getTypeDescriptor(),
           TypeDescriptor.valueOf(Double.class));
 }
 private boolean canReturnExpectedType(
     AnnotatedMethodFilter filter, Class<?> targetType, TypeConverter typeConverter) {
   if (expectedType == null) {
     return true;
   }
   List<Method> methods =
       filter.filter(Arrays.asList(ReflectionUtils.getAllDeclaredMethods(targetType)));
   for (Method method : methods) {
     if (typeConverter.canConvert(
         TypeDescriptor.valueOf(method.getReturnType()), TypeDescriptor.valueOf(expectedType))) {
       return true;
     }
   }
   return false;
 }