public final T to()

in wicket-util/src/main/java/org/apache/wicket/util/string/StringValue.java [313:367]


	public final <T> T to(final Class<T> type) throws StringValueConversionException
	{
		if (type == null)
		{
			return null;
		}

		if (type == String.class)
		{
			return (T)toString();
		}

		if ((type == Integer.TYPE) || (type == Integer.class))
		{
			return (T)toInteger();
		}

		if ((type == Long.TYPE) || (type == Long.class))
		{
			return (T)toLongObject();
		}

		if ((type == Boolean.TYPE) || (type == Boolean.class))
		{
			return (T)toBooleanObject();
		}

		if ((type == Double.TYPE) || (type == Double.class))
		{
			return (T)toDoubleObject();
		}

		if ((type == Character.TYPE) || (type == Character.class))
		{
			return (T)toCharacter();
		}

		if (type == Instant.class)
		{
			return (T)toInstant();
		}

		if (type == Duration.class)
		{
			return (T)toDuration();
		}

		if (type.isEnum())
		{
			return (T)toEnum((Class)type);
		}

		throw new StringValueConversionException(
			"Cannot convert '" + toString() + "'to type " + type);
	}