Class AbstractParamValueExtractor<T>

  • Direct Known Subclasses:
    CollectionExtractor, SingleValueExtractor

    abstract class AbstractParamValueExtractor<T>
    extends java.lang.Object
    Abstract base class for implementing multivalued parameter value extractor logic supplied using parameter converters.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractParamValueExtractor​(javax.ws.rs.ext.ParamConverter<T> converter, java.lang.String parameterName, java.lang.String defaultValueString)
      Constructor that initializes common string reader-based parameter extractor data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private T convert​(java.lang.String value)  
      protected T defaultValue()
      Get converted default value.
      protected T fromString​(java.lang.String value)
      Extract parameter value from string using the configured parameter converter.
      java.lang.String getDefaultValueString()
      Get the default string value of the parameter.
      java.lang.String getName()
      Get the name of the parameter this extractor belongs to.
      protected boolean isDefaultValueRegistered()
      Check if there is a default string value registered for the parameter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • paramConverter

        private final javax.ws.rs.ext.ParamConverter<T> paramConverter
      • parameterName

        private final java.lang.String parameterName
      • defaultValueString

        private final java.lang.String defaultValueString
      • convertedDefaultValue

        private final UnsafeValue<T,​java.lang.RuntimeException> convertedDefaultValue
    • Constructor Detail

      • AbstractParamValueExtractor

        protected AbstractParamValueExtractor​(javax.ws.rs.ext.ParamConverter<T> converter,
                                              java.lang.String parameterName,
                                              java.lang.String defaultValueString)
        Constructor that initializes common string reader-based parameter extractor data.

        As part of the initialization, the default value validation is performed based on the presence and value of the ParamConverter.Lazy annotation on the supplied string value reader class.

        Parameters:
        converter - parameter converter.
        parameterName - name of the parameter.
        defaultValueString - default parameter value string.
    • Method Detail

      • getName

        public java.lang.String getName()
        Get the name of the parameter this extractor belongs to.
        Returns:
        parameter name.
      • getDefaultValueString

        public java.lang.String getDefaultValueString()
        Get the default string value of the parameter.
        Returns:
        default parameter string value.
      • fromString

        protected final T fromString​(java.lang.String value)
        Extract parameter value from string using the configured parameter converter. A WebApplicationException thrown from the converter is propagated unchanged. Any other exception throws by the converter is wrapped in a new ExtractorException before rethrowing.
        Parameters:
        value - parameter string value to be converted/extracted.
        Returns:
        extracted value of a given Java type.
        Throws:
        javax.ws.rs.WebApplicationException - in case the underlying parameter converter throws a WebApplicationException. The exception is rethrown without a change.
        ExtractorException - wrapping any other exception thrown by the parameter converter.
      • convert

        private T convert​(java.lang.String value)
      • isDefaultValueRegistered

        protected final boolean isDefaultValueRegistered()
        Check if there is a default string value registered for the parameter.
        Returns:
        true if there is a default parameter string value registered, false otherwise.
      • defaultValue

        protected final T defaultValue()
        Get converted default value. The conversion happens lazily during first call of the method.
        Returns:
        converted default value.