Exemplo n.º 1
0
 public void convert(Object notation, NotationConvertResult<? super T> result)
     throws TypeConversionException {
   if (notation instanceof CharSequence) {
     result.converted(
         (T)
             new EnumFromCharSequenceNotationParser(enumType)
                 .parseNotation(notation.toString().trim()));
   }
 }
Exemplo n.º 2
0
  private static void convertToCharacter(
      Object notation, NotationConvertResult<? super Character> result, Class<?> type)
      throws TypeConversionException {

    String trimmed = notation.toString().trim();
    if (trimmed.length() != 1) {
      throw new TypeConversionException(
          String.format(
              "Cannot coerce string value '%s' with length %d to type %s",
              trimmed, trimmed.length(), type.getSimpleName()));
    }

    result.converted(trimmed.charAt(0));
  }
 public void convert(String notation, NotationConvertResult<? super String> result)
     throws TypeConversionException {
   result.converted(notation);
 }