@Test public void testStringTreeSet() throws Exception { TreeSet<String> mySet = new TreeSet<>(Arrays.asList("C", "B", "A")); assertEquals(mySet, new ParameterValue("C", "A", "B", "A").toCollection(TreeSet.class, String.class, null)); }
@SuppressWarnings("unchecked") public <X extends Collection<T>, T> X toCollection(Class<? extends Collection> collectionClass, Class<T> classOfT, String pattern) { if (collectionClass == null || classOfT == null) { return null; } try { Constructor<?> constructor = collectionClass.getConstructor(); X collection = (X) constructor.newInstance(); ParameterValue parameterValue = newParameterValuePlaceHolder(); List<String> list = toList(); for (String value : list) { parameterValue.values[0] = value; T t = (T) parameterValue.toObject(classOfT, pattern); collection.add(t); } return collection; } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new PippoRuntimeException(e, "Failed to create collection"); } }
ParameterValue implements Serializable { @SuppressWarnings("unchecked") public <X extends Collection<T>, T> X toCollection(Class<? extends Collection> collectionClass, Class<T> classOfT, String pattern) { if (collectionClass == null || classOfT == null) { return null; } try { Constructor<?> constructor = collectionClass.getConstructor(); X collection = (X) constructor.newInstance(); ParameterValue parameterValue = newParameterValuePlaceHolder(); List<String> list = toList(); for (String value : list) { parameterValue.values[0] = value; T t = (T) parameterValue.toObject(classOfT, pattern); collection.add(t); } return collection; } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new PippoRuntimeException(e, "Failed to create collection"); } } }
ParameterValue implements Serializable { @SuppressWarnings("unchecked") public <X extends Collection<T>, T> X toCollection(Class<? extends Collection> collectionClass, Class<T> classOfT, String pattern) { if (collectionClass == null || classOfT == null) { return null; } try { Constructor<?> constructor = collectionClass.getConstructor(); X collection = (X) constructor.newInstance(); ParameterValue parameterValue = newParameterValuePlaceHolder(); List<String> list = toList(); for (String value : list) { parameterValue.values[0] = value; T t = (T) parameterValue.toObject(classOfT, pattern); collection.add(t); } return collection; } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new PippoRuntimeException(e, "Failed to create collection"); } } ParameterValue(final String... values);  ParameterValue(final Locale locale, final String... values); }
ParameterValue implements Serializable { @SuppressWarnings("unchecked") public <X extends Collection<T>, T> X toCollection(Class<? extends Collection> collectionClass, Class<T> classOfT, String pattern) { if (collectionClass == null || classOfT == null) { return null; } try { Constructor<?> constructor = collectionClass.getConstructor(); X collection = (X) constructor.newInstance(); ParameterValue parameterValue = newParameterValuePlaceHolder(); List<String> list = toList(); for (String value : list) { parameterValue.values[0] = value; T t = (T) parameterValue.toObject(classOfT, pattern); collection.add(t); } return collection; } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new PippoRuntimeException(e, "Failed to create collection"); } } ParameterValue(final String... values);  ParameterValue(final Locale locale, final String... values); boolean toBoolean(); boolean toBoolean(boolean defaultValue); byte toByte(); byte toByte(byte defaultValue); short toShort(); short toShort(short defaultValue); int toInt(); int toInt(int defaultValue); long toLong(); long toLong(long defaultValue); float toFloat(); float toFloat(float defaultValue); double toDouble(); double toDouble(double defaultValue); BigDecimal toBigDecimal(); BigDecimal toBigDecimal(BigDecimal defaultValue); UUID toUUID(); UUID toUUID(UUID defaultValue); Character toCharacter(); Character toCharacter(Character defaultValue); @Override String toString(); String toString(String defaultValue); T toEnum(Class<T> classOfT); T toEnum(Class<T> classOfT, T defaultValue); T toEnum(Class<T> classOfT, T defaultValue, boolean caseSensitive); Set<String> toSet(); Set<String> toSet(Set<String> defaultValue); Set<T> toSet(Class<T> classOfT); Set<T> toSet(Class<T> classOfT, String pattern); List<String> toList(); List<String> toList(List<String> defaultValue); List<T> toList(Class<T> classOfT); List<T> toList(Class<T> classOfT, String pattern); Date toDate(String pattern); Date toDate(Date defaultValue, String pattern); java.sql.Date toSqlDate(); java.sql.Date toSqlDate(java.sql.Date defaultValue); Time toSqlTime(); Time toSqlTime(Time defaultValue); Timestamp toSqlTimestamp(); Timestamp toSqlTimestamp(Timestamp defaultValue); T to(Class<T> classOfT); @SuppressWarnings("unchecked") T to(Class<T> classOfT, String pattern); T convert(Class<C> converterClass, String pattern); @SuppressWarnings("unchecked") X toCollection(Class<? extends Collection> collectionClass, Class<T> classOfT, String pattern); boolean isNull(); boolean isEmpty(); boolean isMultiValued(); String[] getValues(); }
ParameterValue implements Serializable { @SuppressWarnings("unchecked") public <X extends Collection<T>, T> X toCollection(Class<? extends Collection> collectionClass, Class<T> classOfT, String pattern) { if (collectionClass == null || classOfT == null) { return null; } try { Constructor<?> constructor = collectionClass.getConstructor(); X collection = (X) constructor.newInstance(); ParameterValue parameterValue = newParameterValuePlaceHolder(); List<String> list = toList(); for (String value : list) { parameterValue.values[0] = value; T t = (T) parameterValue.toObject(classOfT, pattern); collection.add(t); } return collection; } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new PippoRuntimeException(e, "Failed to create collection"); } } ParameterValue(final String... values);  ParameterValue(final Locale locale, final String... values); boolean toBoolean(); boolean toBoolean(boolean defaultValue); byte toByte(); byte toByte(byte defaultValue); short toShort(); short toShort(short defaultValue); int toInt(); int toInt(int defaultValue); long toLong(); long toLong(long defaultValue); float toFloat(); float toFloat(float defaultValue); double toDouble(); double toDouble(double defaultValue); BigDecimal toBigDecimal(); BigDecimal toBigDecimal(BigDecimal defaultValue); UUID toUUID(); UUID toUUID(UUID defaultValue); Character toCharacter(); Character toCharacter(Character defaultValue); @Override String toString(); String toString(String defaultValue); T toEnum(Class<T> classOfT); T toEnum(Class<T> classOfT, T defaultValue); T toEnum(Class<T> classOfT, T defaultValue, boolean caseSensitive); Set<String> toSet(); Set<String> toSet(Set<String> defaultValue); Set<T> toSet(Class<T> classOfT); Set<T> toSet(Class<T> classOfT, String pattern); List<String> toList(); List<String> toList(List<String> defaultValue); List<T> toList(Class<T> classOfT); List<T> toList(Class<T> classOfT, String pattern); Date toDate(String pattern); Date toDate(Date defaultValue, String pattern); java.sql.Date toSqlDate(); java.sql.Date toSqlDate(java.sql.Date defaultValue); Time toSqlTime(); Time toSqlTime(Time defaultValue); Timestamp toSqlTimestamp(); Timestamp toSqlTimestamp(Timestamp defaultValue); T to(Class<T> classOfT); @SuppressWarnings("unchecked") T to(Class<T> classOfT, String pattern); T convert(Class<C> converterClass, String pattern); @SuppressWarnings("unchecked") X toCollection(Class<? extends Collection> collectionClass, Class<T> classOfT, String pattern); boolean isNull(); boolean isEmpty(); boolean isMultiValued(); String[] getValues();  }