@SuppressWarnings({ "unchecked", "rawtypes" }) public Class<? extends IStringConverter<?>> getConverter(Class forType) { if (forType.equals(Point.class)) return Point.Converter.class; else if (forType.equals(Range.class)) return Range.Converter.class; else if (forType.equals(Function.class)) return Function.Converter.class; else if (forType.equals(PointListList.class)) return PointListList.Converter.class; else if (forType.equals(IntegralPlotSettings.class)) return IntegralPlotSettings.Converter.class; else if (forType.equals(CsvOrientation.class)) return CsvOrientation.CsvOrientationConverter.class; else if (forType.equals(CsvType.class)) return CsvType.CsvTypeConverter.class; else if (forType.equals(DiagramType.class)) return DiagramType.DiagramTypeConverter.class; else if (forType.equals(BarAccumulationStyle.class)) return BarAccumulationStyle.BarAccumulationStyleConverter.class; else if (forType.equals(SortingType.class)) return SortingType.SortingTypeConverter.class; else return null; }
@Override public IStringConverter<?> getConverterInstance(Parameter parameter, Class<?> forType, String optionName) { if (Path.class.equals(forType)) { return new CustomPathConverter(); } return null; }
/** Returns JCommander converter for a given type, or {@code null} if none exists. */ @Nullable @Override @SuppressWarnings("unchecked") public <T> Class<? extends IStringConverter<T>> getConverter(@Nullable Class<T> type) { return (Class<? extends IStringConverter<T>>) CONVERTERS.get(type); }
private <T> T getProperty(String name, T defaultValue, IParameterValidator validator, IStringConverter<T> converter) { String value = properties.getProperty(name); if (value == null && defaultValue != null) { value = defaultValue.toString(); } if (validator != null) { validator.validate(name, value); } return value == null ? null : converter.convert(value); }
@Override @SuppressWarnings("unchecked") public <T> Class<? extends IStringConverter<T>> getConverter(Class<T> forType) { if (forType.equals(Id.class)) { return (Class<IStringConverter<T>>) (Class<?>) IdConverter.class; } return null; }
@Override public Class<? extends IStringConverter<?>> getConverter(Class forType) { if (forType.equals(Level.class)) { return LevelConverter.class; } else { return null; } }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public <T> Class<? extends IStringConverter<T>> getConverter(Class<T> forType) { if (forType.equals(Path.class)) { return (Class) PathConverter.class; } return null; }
public Class<? extends IStringConverter<?>> getConverter(Class forType) { return classConverters.get(forType); }
public AbstractStringConverterBasicTest(final IStringConverter<T> stringConverter) { super(stringConverter); }
public AbstractStringConverterTestWrapper(final IStringConverter<T> stringConverter) { this.stringConverter = stringConverter; }
public IStringConverter<T> getStringConverter() { return stringConverter; }
public Class<? extends IStringConverter<?>> getConverter(Class forType) { return m_classConverters.get(forType); }
private String getProperty(String name, IParameterValidator validator) { return getProperty(name, validator, (IStringConverter<String>)String::toString); }
private <T> T getProperty(String name, IParameterValidator validator, IStringConverter<T> converter) { return getProperty(name, null, validator, converter); }
private <T> T getProperty(String name, T defaultValue, IStringConverter<T> converter) { return getProperty(name, defaultValue, null, converter); }
@Override public Integer getProxyPort() { return getProperty(PropertiesConstants.PROXY_PORT, POSITIVE_INTEGER, (IStringConverter<Integer>)Integer::new); }
public Class<? extends IStringConverter<?>> getConverter(Class forType) { if (forType.equals(HostPort.class)) { return HostPortConverter.class; } else return null; }
@SuppressWarnings("unchecked") public Class<? extends IStringConverter<?>> getConverter(@SuppressWarnings("rawtypes") Class forType) { return m_classConverters.get(forType); }
@Override public <T> Class<? extends IStringConverter<T>> getConverter(Class<T> forType) { if (converts.containsKey(forType)) return (Class<IStringConverter<T>>) converts.get(forType); return null; }
public <T> void register(final Class<T> type, final Class<? extends IStringConverter<? extends T>> converter) { converts.put(type, converter); }
/** * Constructs a new converter. * @param splitter to split value into list of arguments * @param converter to convert list of arguments to target element type */ public DefaultListConverter(IParameterSplitter splitter, IStringConverter<T> converter) { this.splitter = splitter; this.converter = converter; }