Class AbstractCollectionFormInjector<T>

  • Type Parameters:
    T - The type of collection that will be created.
    All Implemented Interfaces:
    ValueInjector
    Direct Known Subclasses:
    ListFormInjector, MapFormInjector

    public abstract class AbstractCollectionFormInjector<T>
    extends PrefixedFormInjector
    Abstract implementation of NestedFormInjector that can inject collections.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class collectionType  
      private java.util.regex.Pattern pattern  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractCollectionFormInjector​(java.lang.Class collectionType, java.lang.Class genericType, java.lang.String prefix, java.util.regex.Pattern pattern, ResteasyProviderFactory factory)
      Creates an injector to inject a collection.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void addTo​(T collection, java.lang.String key, java.lang.Object value)
      Adds the item to the collection.
      protected abstract T createInstance​(java.lang.Class collectionType)
      Creates an instance of the collection type.
      private java.util.Set<java.lang.String> findMatchingPrefixesWithNoneEmptyValues​(javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> parameters)
      Finds all field names that follow the pattern.
      java.lang.Object inject​(HttpRequest request, HttpResponse response)
      Inject inside the context of an HTTP request.
      • Methods inherited from class java.lang.Object

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

      • collectionType

        private final java.lang.Class collectionType
      • pattern

        private final java.util.regex.Pattern pattern
    • Constructor Detail

      • AbstractCollectionFormInjector

        protected AbstractCollectionFormInjector​(java.lang.Class collectionType,
                                                 java.lang.Class genericType,
                                                 java.lang.String prefix,
                                                 java.util.regex.Pattern pattern,
                                                 ResteasyProviderFactory factory)
        Creates an injector to inject a collection.
        Parameters:
        collectionType - The type of collection to return.
        genericType - The type of elements in the collection.
        pattern - The pattern that a field name should follow to be a part of this collection. The first group in the pattern must be the index.
    • Method Detail

      • inject

        public java.lang.Object inject​(HttpRequest request,
                                       HttpResponse response)
        Inject inside the context of an HTTP request. Wraps the request in a Creates a collection instance and fills it with content by using the super implementation.
        Specified by:
        inject in interface ValueInjector
        Overrides:
        inject in class PrefixedFormInjector
        Returns:
      • findMatchingPrefixesWithNoneEmptyValues

        private java.util.Set<java.lang.String> findMatchingPrefixesWithNoneEmptyValues​(javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> parameters)
        Finds all field names that follow the pattern.
      • createInstance

        protected abstract T createInstance​(java.lang.Class collectionType)
        Creates an instance of the collection type.
      • addTo

        protected abstract void addTo​(T collection,
                                      java.lang.String key,
                                      java.lang.Object value)
        Adds the item to the collection.