/* (non-Javadoc)
@see com.abubusoft.kripton.BinderContext#serializeCollection(java.util.Collection, java.lang.Class)
540653
@Override
	public <E> String serializeCollection(Collection<E> collection, Class<E> objectClazz) {
		if (collection == null)
			return null;

		SegmentedStringWriter source = new SegmentedStringWriter(buffer.get());
		try (SerializerWrapper serializer = createSerializer(source)) {
			mapperFor(objectClazz).serializeCollection(this, serializer, collection);
		} catch (Exception e) {
			e.printStackTrace();
			throw new KriptonRuntimeException(e);
		}
		return source.getAndClear();
	}
1235872
@SneakyThrows
    public static <T extends Collection> T toCollection(final Object obj, final Class<T> clazz) {
        val results = toCollection(obj);
        if (clazz.isInterface()) {
            throw new IllegalArgumentException("Cannot accept an interface " + clazz.getSimpleName() + " to create a new object instance");
        }
        val col = clazz.getDeclaredConstructor().newInstance();
        col.addAll(results);
        return col;
    }
928641
public <T> JSONAPIDocument<List<T>> readDocumentCollection(byte[] data, Class<T> clazz) {
		return readDocumentCollection(new ByteArrayInputStream(data), clazz);
	}
932831
public void setCollection(String collection) throws PageException {
	try {
	    this.collection = pageContext.getConfig().getSearchEngine(pageContext).getCollectionByName(collection.toLowerCase().trim());
	}
	catch (SearchException e) {
	    throw Caster.toPageException(e);
	}

    }
801418
public static void writeCollection(XMLOutput xmlOutput, Collection<? extends XMLWriteable> collection) throws IOException {
        for (XMLWriteable obj : collection) {
            obj.writeXML(xmlOutput);
        }
    }
964755
@Deprecated
	public <T> byte[] writeObjectCollection(Iterable<T> objects) throws JsonProcessingException, IllegalAccessException {
		try {
			return writeDocumentCollection(new JSONAPIDocument<>(objects));
		} catch (DocumentSerializationException e) {
			if (e.getCause() instanceof JsonProcessingException) {
				throw (JsonProcessingException) e.getCause();
			} else if (e.getCause() instanceof  IllegalAccessException) {
				throw (IllegalAccessException) e.getCause();
			}
			throw new RuntimeException(e.getCause());
		}
	}
743965
public static Function<Object, Collection<?>> COLLECTION(final Class<? extends Collection> collectionType) {
      return as(new CollectionConverterImpl<>(collectionType, null));
   }
85427
public boolean registerCollection(CollectionSchema.MessageFactory factory)
    {
        return null == collectionMapping.putIfAbsent(factory.typeClass()
                .getName(), factory);
    }
921964
def serialize(self, serializable: Optional[Union[SerializableType, List[SerializableType]]]) \
            -> PrimitiveJsonType:
        
        if serializable is None:
            # Implements #17
            return None
        elif isinstance(serializable, List):
            return [self.serialize(item) for item in serializable]
        else:
            serialized = self._create_serialized_container()

            for mapping in self._property_mappings:
                if mapping.object_property_getter is not None and mapping.serialized_property_setter is not None:
                    value = mapping.object_property_getter(serializable)
                    if not (mapping.optional and value is None):
                        if isinstance(value, type(mapping.collection_factory([]))):
                            value = list(mapping.collection_iter(value))
                        encoded_value = self._serialize_property_value(value, mapping.serializer_cls)
                        mapping.serialized_property_setter(serialized, encoded_value)

            return serialized
416073
public static Collection<Object> getCollectionProperties(Collection<?> collection,String name)
   throws Exception
   {
	   if(collection == null)
				throw new IllegalArgumentException("collection, name");
	   
	   ArrayList<Object> list = new ArrayList<Object>(collection.size());
	   
	   for (Object bean : collection)
		{
		   list.add(getNestedProperty(bean, name));
		}
	   
	   return list;
   }
1057847
@Override
    public String serialize(Collection<String> c, SerializationContext context) {
        StringBuilder sb = new StringBuilder();
        for (String s : c) {
            sb.append(s);
            sb.append(SEPARATOR);
        }
        sb.setLength(sb.length() - SEPARATOR.length());
        return sb.toString();
    }
1251802
public static <T> List<T> toList(final Collection<T> collection) {

        if (isEmpty(collection)) {
            return new ArrayList<T>(0);
        } else {
            return new ArrayList<T>(collection);
        }
    }
181837
public static <T> Collection<T> immutableCollectionCopy(Collection<T> collection) {
      if (collection == null) return null;
      if (collection.isEmpty()) return Collections.emptySet();
      if (collection.size() == 1) return Collections.singleton(collection.iterator().next());

      Collection<? extends T> copy = ObjectDuplicator.duplicateCollection(collection);
      if (copy == null)
         copy = attemptCopyConstructor(collection, Collection.class);
      if (copy == null)
         copy = new ArrayList<>(collection);

      return new ImmutableCollectionWrapper<>(copy);
   }
794524
public function serializeCollection($collection, TransformerAbstract $transformer = null, $resourceKey = null)
    {
        return $this->getFractalService()
            ->collection($collection, $transformer, $resourceKey);
    }
100047
function serialize (layersCollection, dataviewsCollection) {
  // Named map templates include both http, cartodb and torque layers
  // so we need to iterate through all the layers in the collection to
  // get the indexes rights. Templates are not aware of Google Maps
  // base layers, so we have to ignore them to get indexes right.
  var layers = layersCollection.filter(function (layer) {
    return !LayerTypes.isGoogleMapsBaseLayer(layer);
  });

  return {
    buffersize: {
      mvt: 0
    },
    styles: _getStylesFromLayers(layers)
  };
}
325240
public BioCCollection readCollection()
      throws XMLStreamException {
    if (collection != null) {
      BioCCollection thisCollection = collection;
      collection = null;
      return thisCollection;
    }
    return null;
  }
194438
public static Collection toCollection(String input, Class<?> collectionClass, Class<?> genericClass,
            String mediaType)
    {

        try
        {
            if (MediaType.APPLICATION_XML.equals(mediaType))
            {
                Collection c = (Collection) collectionClass.newInstance();
                if (input.startsWith("<?xml"))
                {
                    input = input.substring(input.indexOf(">") + 1, input.length());
                }

                input = input.replaceAll("<" + genericClass.getSimpleName().toLowerCase() + "s>", "");

                while (!input.equals(""))
                {
                    int i = input.indexOf("</" + genericClass.getSimpleName().toLowerCase() + ">");
                    String s = input.substring(0, i + 3 + genericClass.getSimpleName().length());
                    input = input.substring(i + 3 + genericClass.getSimpleName().length(), input.length());
                    Object o = JAXBUtils.toObject(StreamUtils.toInputStream(s), genericClass, mediaType);
                    c.add(o);
                }
                return c;

            }
            else if (MediaType.APPLICATION_JSON.equals(mediaType))
            {
                
                    return  JAXBUtils.mapper.readValue(input, JAXBUtils.mapper.getTypeFactory()
                                        .constructCollectionType((Class<? extends Collection>) collectionClass, genericClass));
               
                
            }
            return null;
        }
        catch (InstantiationException e)
        {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        }
        catch (IllegalAccessException e)
        {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        } catch (JsonParseException e) {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        } catch (JsonMappingException e) {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        } catch (IOException e) {
            log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null");
            return null;
        }
    }