@Override protected void convertNumberToNumber(BigDecimal n, NotationConvertResult<? super BigDecimal> result) { result.converted(n); } }
public void convert(String notation, NotationConvertResult<? super Boolean> result) throws TypeConversionException { result.converted("true".equals(notation)); } }
@Override protected void convertNumberToNumber(BigDecimal n, NotationConvertResult<? super Float> result) { result.converted(n.floatValue()); } }
@Override protected void convertNumberToNumber(BigDecimal n, NotationConvertResult<? super BigInteger> result) { result.converted(n.toBigIntegerExact()); } }
@Override public void convert(Object notation, NotationConvertResult<? super String> result) throws TypeConversionException { if (notation instanceof CharSequence || notation instanceof Number || notation instanceof Boolean || notation instanceof Character || notation instanceof File) { result.converted(notation.toString()); } }
@Override protected void convertNumberToNumber(BigDecimal n, NotationConvertResult<? super Double> result) { result.converted(n.doubleValue()); } }
@Override protected void convertNumberToNumber(BigDecimal n, NotationConvertResult<? super Integer> result) { result.converted(n.intValueExact()); } }
@Override protected void convertNumberToNumber(BigDecimal n, NotationConvertResult<? super Long> result) { result.converted(n.longValueExact()); } }
@Override protected void convertNumberToNumber(BigDecimal n, NotationConvertResult<? super Short> result) { result.converted(n.shortValueExact()); } }
@Override public void convert(Object notation, NotationConvertResult<? super T> result) throws TypeConversionException { if (typeToken.isInstance(notation)) { result.converted(parseType(typeToken.cast(notation))); } }
@Override protected void convertNumberToNumber(BigDecimal n, NotationConvertResult<? super Byte> result) { result.converted(n.byteValueExact()); } }
public void convert(String notation, NotationConvertResult<? super Character> result) throws TypeConversionException { if (notation.length() != 1) { throw new TypeConversionException(String.format("Cannot convert string value '%s' with length %d to type %s", notation, notation.length(), target.getSimpleName())); } result.converted(notation.charAt(0)); } }
public void convert(Closure notation, NotationConvertResult<? super Spec<T>> result) throws TypeConversionException { Spec<T> spec = Specs.convertClosureToSpec(notation); result.converted(spec); }
public void convert(String notation, NotationConvertResult<? super File> result) throws TypeConversionException { result.converted(fileResolver.resolve(notation)); } }), File.class);
@Override public void convert(CharSequence notation, NotationConvertResult<? super T> result) throws TypeConversionException { try { result.converted(GUtil.toEnum(type, notation)); } catch (IllegalArgumentException e) { throw new TypeConversionException(e.getMessage(), e); } }
@Override public void convert(CharSequence notation, NotationConvertResult<? super T> result) throws TypeConversionException { try { result.converted(GUtil.toEnum(type, notation)); } catch (IllegalArgumentException e) { throw new TypeConversionException(e.getMessage(), e); } }
public void convert(Object notation, NotationConvertResult<? super Object> result) throws TypeConversionException { if (notation instanceof File) { result.converted(notation); return; result.converted(((Path)notation).toFile()); return; result.converted(((FileSystemLocation)notation).getAsFile()); return; URI uri = (URI) notation; if (uri.getScheme().equals("file")) { result.converted(new File(uri.getPath())); } else { result.converted(uri); String notationString = notation.toString(); if (notationString.startsWith("file:")) { result.converted(new File(uriDecode(notationString.substring(5)))); return; result.converted(new File(notationString)); return; result.converted(new URI(notationString)); return; } catch (URISyntaxException e) { result.converted(new File(notationString));
@Override public void convert(Object notation, NotationConvertResult<? super String> result) throws TypeConversionException { if (notation == null) { result.converted(null); } else if (notation instanceof CharSequence || notation instanceof File || notation instanceof Number || notation instanceof Boolean) { result.converted(notation.toString()); } else if (notation instanceof Closure) { final Closure closure = (Closure) notation; final Object called = closure.call(); convert(called, result); } else if (notation instanceof Callable) { final Callable callableNotation = (Callable) notation; final Object called = uncheckedCall(callableNotation); convert(called, result); if (!result.hasResult()) { throw new TypeConversionException("Couldn't convert " + notation); } } } }