/*
 *  Copyright (c) 2017 Otávio Santana and others
 *   All rights reserved. This program and the accompanying materials
 *   are made available under the terms of the Eclipse Public License v1.0
 *   and Apache License v2.0 which accompanies this distribution.
 *   The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 *   and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
 *
 *   You may elect to redistribute this code under either of these licenses.
 *
 *   Contributors:
 *
 *   Otavio Santana
 */
package org.jnosql.artemis.document;


import org.jnosql.diana.api.document.DocumentCollectionManagerAsync;

import javax.enterprise.inject.Vetoed;
import javax.inject.Inject;
import java.util.Objects;

/**
 * The default implementation of {@link DocumentTemplateAsyncProducer}
 */
class DefaultDocumentTemplateAsyncProducer implements DocumentTemplateAsyncProducer {


    @Inject
    private DocumentEntityConverter converter;

    @Override
    public DocumentTemplateAsync get(DocumentCollectionManagerAsync collectionManager) throws NullPointerException {
        Objects.requireNonNull(collectionManager, "collectionManager is required");
        return new ProducerAbstractDocumentTemplateAsync(converter, collectionManager);
    }

    @Vetoed
    static class ProducerAbstractDocumentTemplateAsync extends AbstractDocumentTemplateAsync {

        private DocumentEntityConverter converter;

        private DocumentCollectionManagerAsync manager;

        ProducerAbstractDocumentTemplateAsync(DocumentEntityConverter converter, DocumentCollectionManagerAsync manager) {
            this.converter = converter;
            this.manager = manager;
        }

        ProducerAbstractDocumentTemplateAsync() {
        }

        @Override
        protected DocumentEntityConverter getConverter() {
            return converter;
        }

        @Override
        protected DocumentCollectionManagerAsync getManager() {
            return manager;
        }
    }
}

@@ -635,59 +635,169 @@
 sql.
-diana.api.document.DocumentCollectionManagerAsync;%0A
+artemis.reflection.ClassRepresentations;%0Aimport org.jnosql.diana.api.document.DocumentCollectionManagerAsync;%0A%0Aimport javax.enterprise.context.ApplicationScoped;
 %0Aimp
@@ -966,16 +966,35 @@
 er%7D%0A */%0A
+@ApplicationScoped%0A
 class De
@@ -1129,24 +1129,92 @@
 converter;%0A%0A
+    @Inject%0A    private ClassRepresentations classRepresentations;%0A%0A
     @Overrid
@@ -1501,16 +1501,38 @@
 nManager
+, classRepresentations
 );%0A    %7D
@@ -1746,24 +1746,84 @@
 c manager;%0A%0A
+        private ClassRepresentations classRepresentations;%0A%0A
         Prod
@@ -1894,47 +1894,182 @@
 ter,
- DocumentCollectionManagerAsync manager
+%0A                                              DocumentCollectionManagerAsync manager,%0A                                              ClassRepresentations classRepresentations
 ) %7B%0A
@@ -2136,32 +2136,94 @@
 ager = manager;%0A
+            this.classRepresentations = classRepresentations;%0A
         %7D%0A%0A     
@@ -2515,16 +2515,153 @@
        %7D
+%0A%0A        @Override%0A        protected ClassRepresentations getClassRepresentations() %7B%0A            return classRepresentations;%0A        %7D
 %0A    %7D%0A%7D

implements the abstract document