Package org.jdrupes.httpcodec.types
Class ParameterizedValue.ParamValueConverterBase<P extends ParameterizedValue<U>,U>
java.lang.Object
org.jdrupes.httpcodec.types.ParameterizedValue.ParamValueConverterBase<P,U>
- Type Parameters:
P
- the parameterized typeU
- the unparameterized type
- All Implemented Interfaces:
Converter<P>
- Direct Known Subclasses:
MediaRange.MediaRangeConverter
,MediaType.MediaTypeConverter
,ParameterizedValue.ParameterizedValueConverter
- Enclosing class:
- ParameterizedValue<U>
public static class ParameterizedValue.ParamValueConverterBase<P extends ParameterizedValue<U>,U>
extends Object
implements Converter<P>
A base class for converters for parameterized values.
Converts field values such as value; param1=value1; param2=value2
.
-
Constructor Summary
ConstructorDescriptionParamValueConverterBase
(Converter<U> valueConverter, BiFunction<U, Map<String, String>, P> paramValueConstructor) Creates a new converter by extending the given value converter with functionality for handling the parameters.ParamValueConverterBase
(Converter<U> valueConverter, Converter<String> paramValueConverter, BiFunction<U, Map<String, String>, P> paramValueConstructor) Creates a new converter by extending the given value converter with functionality for handling the parameters. -
Method Summary
Modifier and TypeMethodDescriptionasFieldValue
(P value) Returns the representation of this value in a header field.fromFieldValue
(String text) Parses the given text and returns the parsed value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jdrupes.httpcodec.types.Converter
asHeaderField
-
Constructor Details
-
ParamValueConverterBase
public ParamValueConverterBase(Converter<U> valueConverter, BiFunction<U, Map<String, String>, P> paramValueConstructor) Creates a new converter by extending the given value converter with functionality for handling the parameters.Parameter values are used literally (no quoting).
- Parameters:
valueConverter
- the converter for a value (without parameters)paramValueConstructor
- a method that creates the result from an instance of the type and a map of parameters (used byfromFieldValue(String)
).
-
ParamValueConverterBase
public ParamValueConverterBase(Converter<U> valueConverter, Converter<String> paramValueConverter, BiFunction<U, Map<String, String>, P> paramValueConstructor) Creates a new converter by extending the given value converter with functionality for handling the parameters.- Parameters:
valueConverter
- the converter for a value (without parameters)paramValueConverter
- the converter for parameterValuesparamValueConstructor
- a method that creates the result from an instance of the type and a map of parameters (used byfromFieldValue(String)
).
-
-
Method Details
-
asFieldValue
Description copied from interface:Converter
Returns the representation of this value in a header field.- Specified by:
asFieldValue
in interfaceConverter<P extends ParameterizedValue<U>>
- Parameters:
value
- the value to be converted- Returns:
- the representation
-
fromFieldValue
Description copied from interface:Converter
Parses the given text and returns the parsed value.- Specified by:
fromFieldValue
in interfaceConverter<P extends ParameterizedValue<U>>
- Parameters:
text
- the value from the header field- Returns:
- the parsed value
- Throws:
ParseException
- if the value cannot be parsed
-