@Override @SuppressWarnings("unchecked") public Class<? extends IExternalConverter> convert(String value) { try { return (Class<? extends IExternalConverter>) Class.forName(value); } catch (ClassNotFoundException e) { throw new ValueConversionException("Not a class name or not on class path: " + value, e); } }
@Override public T convert(String input) { try { return Enum.valueOf(enumClass, input.toUpperCase()); } catch (IllegalArgumentException e) { throw new ValueConversionException("Unrecognized value for enum " + enumClass.getSimpleName() + ": '" + input + "'."); } }
/** {@inheritDoc} */ public String convert( String value ) { if ( !pattern.matcher( value ).matches() ) { throw new ValueConversionException( "Value [" + value + "] did not match regex [" + pattern.pattern() + ']' ); } return value; }
/** {@inheritDoc} */ public String convert( String value ) { if ( !pattern.matcher( value ).matches() ) { throw new ValueConversionException( "Value [" + value + "] did not match regex [" + pattern.pattern() + ']' ); } return value; }
@Override public T convert(String input) { try { return Enum.valueOf(enumClass, input.toUpperCase()); } catch (IllegalArgumentException e) { throw new ValueConversionException("Unrecognized value for enum " + enumClass.getSimpleName() + ": '" + input + "'."); } }
public String convert( String value ) { if ( value.equalsIgnoreCase("true") || value.equalsIgnoreCase("t")) { return "true"; } else if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("f")) { return "false"; } else { throw new ValueConversionException(value + " does not match one of T|True|F|False"); } } public final Class<? extends String> valueType() {
public InetAddress convert( String value ) { try { return InetAddress.getByName( value ); } catch ( UnknownHostException e ) { throw new ValueConversionException( message( value ) ); } }
public Date convert( String value ) { ParsePosition position = new ParsePosition( 0 ); Date date = formatter.parse( value, position ); if ( position.getIndex() != value.length() ) throw new ValueConversionException( message( value ) ); return date; }
private void raiseValueConversionFailure( String value ) { String message = message( Locale.getDefault(), "joptsimple.ExceptionMessages", RegexMatcher.class, "message", value, pattern.pattern() ); throw new ValueConversionException( message ); } }
@Override public Date convert( String value ) { ParsePosition position = new ParsePosition( 0 ); Date date = formatter.parse( value, position ); if ( position.getIndex() != value.length() ) throw new ValueConversionException( message( value ) ); return date; }
@Override public Pair<String, String> convert(String input) { int eqPos = input.indexOf('='); if (eqPos == -1) { throw new ValueConversionException("Parameter should be in the form key=value, which the " + "following is not: '" + input + "'."); } String key = input.substring(0, eqPos).trim(); String value = input.substring(eqPos + 1).trim(); return Pair.newPair(key, value); }
@Override public InetAddress convert( String value ) { try { return InetAddress.getByName( value ); } catch ( UnknownHostException e ) { throw new ValueConversionException( message( value ) ); } }
/** {@inheritDoc} */ public Date convert( String value ) { ParsePosition position = new ParsePosition( 0 ); Date date = formatter.parse( value, position ); if ( position.getIndex() != value.length() ) throw new ValueConversionException( message( value ) ); return date; }
/** {@inheritDoc} */ public Date convert( String value ) { ParsePosition position = new ParsePosition( 0 ); Date date = formatter.parse( value, position ); if ( position.getIndex() != value.length() ) throw new ValueConversionException( message( value ) ); return date; }
private void raiseValueConversionFailure( String value ) { String message = message( Locale.getDefault(), "joptsimple.ExceptionMessages", RegexMatcher.class, "message", value, pattern.pattern() ); throw new ValueConversionException( message ); } }
@Override public Pair<String, String> convert(String input) { int eqPos = input.indexOf('='); if (eqPos == -1) { throw new ValueConversionException("Parameter should be in the form key=value, which the " + "following is not: '" + input + "'."); } String key = input.substring(0, eqPos).trim(); String value = input.substring(eqPos + 1).trim(); return Pair.newPair(key, value); }
@Override public E convert( String value ) { for ( E each : valueType().getEnumConstants() ) { if ( each.name().equalsIgnoreCase( value ) ) { return each; } } throw new ValueConversionException( message( value ) ); }
@Override public E convert( String value ) { for ( E each : valueType().getEnumConstants() ) { if ( each.name().equalsIgnoreCase( value ) ) { return each; } } throw new ValueConversionException( message( value ) ); }
@Override public Path convert( String value ) { Path path = Paths.get(value); if ( pathProperties != null ) { for ( PathProperties each : pathProperties ) { if ( !each.accept( path ) ) throw new ValueConversionException( message( each.getMessageKey(), path.toString() ) ); } } return path; }
@Override public Path convert( String value ) { Path path = Paths.get( value ); if ( pathProperties != null ) { for ( PathProperties each : pathProperties ) { if ( !each.accept( path ) ) throw new ValueConversionException( message( each.getMessageKey(), path.toString() ) ); } } return path; }