/** * Creates a new instance of {@link TypedArgument} by copying the state of another {@link TypedArgument}. * * @param arg the copied argument */ public TypedArgument(TypedArgument<T> arg) { super(arg); this.type = arg.getType(); this.converter = arg.getConverter(); }
/** * Creates the value for the given argument from the given raw value. * * @param value the value * @return the created value */ public static <T> T create(String value, TypedArgument<T> argument) { Objects.requireNonNull(argument); if (value == null) { value = argument.getDefaultValue(); } if (value == null) { return null; } try { if (argument.getConverter() != null) { return Converters.create(value, argument.getConverter()); } else { return Converters.create(argument.getType(), value); } } catch (Exception e) { throw new InvalidValueException(argument, value, e); } }
/** * Creates a new instance of {@link TypedArgument} by copying the state of another {@link TypedArgument}. * * @param arg the copied argument */ public TypedArgument(TypedArgument<T> arg) { super(arg); this.type = arg.getType(); this.converter = arg.getConverter(); }
/** * Creates the value for the given argument from the given raw value. * * @param value the value * @return the created value */ public static <T> T create(String value, TypedArgument<T> argument) { Objects.requireNonNull(argument); if (value == null) { value = argument.getDefaultValue(); } if (value == null) { return null; } try { if (argument.getConverter() != null) { return Converters.create(value, argument.getConverter()); } else { return Converters.create(argument.getType(), value); } } catch (Exception e) { throw new InvalidValueException(argument, value, e); } }