Class BaseCollectionProducer

java.lang.Object
org.exoplatform.services.rest.impl.method.BaseCollectionProducer
All Implemented Interfaces:
TypeProducer
Direct Known Subclasses:
CollectionStringConstructorProducer, CollectionStringProducer, CollectionStringValueOfProducer

public abstract class BaseCollectionProducer extends Object implements TypeProducer
Version:
$Id: $
Author:
Andrey Parfonov
  • Constructor Details

    • BaseCollectionProducer

      protected BaseCollectionProducer(Class<?> collectionClass)
      Constructs BaseCollectionProducer.
      Parameters:
      collectionClass - class of Collections, should be one of List, Set, SortedSet .
  • Method Details

    • createValue

      protected abstract Object createValue(String value) throws Exception
      Create collection's element.
      Parameters:
      value - this String will be used for creation object, usually String will be used as parameter for constructor or static method valueOf
      Returns:
      newly created collection's element
      Throws:
      Exception - if any error occurs
    • createValue

      public Object createValue(String param, javax.ws.rs.core.MultivaluedMap<String,String> values, String defaultValue) throws Exception
      Create Object (it is Collection) and add in it elements. Elements must either:
      • To be a Sting
      • Have a constructor that accepts a single String argument.
      • Have a static method named valueOf that accepts a single String argument.
      If values map does not contains any value for parameter param then defaultValue will be used, in this case Collection will contains single element.
      Specified by:
      createValue in interface TypeProducer
      Parameters:
      param - parameter name, parameter name should be getting from parameter annotation
      values - all value which can be used for construct object, it can be header parameters, path parameters, query parameters, etc
      defaultValue - default value which can be used if in value can't be found required value with name param
      Returns:
      newly created object
      Throws:
      Exception - if any errors occurs