// Path: src/main/java/me/welkinbai/bsonmapper/exception/BsonMapperConverterException.java
// public class BsonMapperConverterException extends RuntimeException {
// 
//     public BsonMapperConverterException() {
//         super();
//     }
// 
//     public BsonMapperConverterException(String message) {
//         super(message);
//     }
// 
//     public BsonMapperConverterException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public BsonMapperConverterException(Throwable cause) {
//         super(cause);
//     }
// 
// }


import me.welkinbai.bsonmapper.annotations.BsonArrayField;
import me.welkinbai.bsonmapper.exception.BsonMapperConverterException;
import org.bson.BsonArray;
import org.bson.BsonDocument;
import org.bson.BsonReader;
import org.bson.BsonType;
import org.bson.BsonValue;
import org.bson.BsonWriter;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import static me.welkinbai.bsonmapper.MapperLayerCounter.MAPPER_LAYER_COUNTER;
package me.welkinbai.bsonmapper;




/**
 * Created by welkinbai on 2017/3/23.
 */
final class BsonArrayConverter {

    private BsonArrayConverter() {
    }

    static BsonArrayConverter getInstance() {
        return new BsonArrayConverter();
    }

    Object decode(BsonArray bsonArray, Field field, BsonMapperConfig bsonMapperConfig) {
        MAPPER_LAYER_COUNTER.addCount(bsonMapperConfig);
        try {
            Class<?> fieldType = field.getType();
            if (fieldType.isArray()) {
                return handleArrayForBsonArray(bsonArray, field, bsonMapperConfig);
            } else if (Collection.class.isAssignableFrom(fieldType)) {
                return handleCollectionForBsonArray(bsonArray, field, bsonMapperConfig);
            } else {
// Path: src/main/java/me/welkinbai/bsonmapper/exception/BsonMapperConverterException.java
// public class BsonMapperConverterException extends RuntimeException {
// 
//     public BsonMapperConverterException() {
//         super();
//     }
// 
//     public BsonMapperConverterException(String message) {
//         super(message);
//     }
// 
//     public BsonMapperConverterException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public BsonMapperConverterException(Throwable cause) {
//         super(cause);
//     }
// 
// }


// Path: src/main/java/me/welkinbai/bsonmapper/BsonArrayConverter.java
import me.welkinbai.bsonmapper.annotations.BsonArrayField;
import me.welkinbai.bsonmapper.exception.BsonMapperConverterException;
import org.bson.BsonArray;
import org.bson.BsonDocument;
import org.bson.BsonReader;
import org.bson.BsonType;
import org.bson.BsonValue;
import org.bson.BsonWriter;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import static me.welkinbai.bsonmapper.MapperLayerCounter.MAPPER_LAYER_COUNTER;

package me.welkinbai.bsonmapper;




/**
 * Created by welkinbai on 2017/3/23.
 */
final class BsonArrayConverter {

    private BsonArrayConverter() {
    }

    static BsonArrayConverter getInstance() {
        return new BsonArrayConverter();
    }

    Object decode(BsonArray bsonArray, Field field, BsonMapperConfig bsonMapperConfig) {
        MAPPER_LAYER_COUNTER.addCount(bsonMapperConfig);
        try {
            Class<?> fieldType = field.getType();
            if (fieldType.isArray()) {
                return handleArrayForBsonArray(bsonArray, field, bsonMapperConfig);
            } else if (Collection.class.isAssignableFrom(fieldType)) {
                return handleCollectionForBsonArray(bsonArray, field, bsonMapperConfig);
            } else {
                throw new BsonMapperConverterException(