Search in sources :

Example 1 with CollectionNestedPojoModel

use of org.bson.codecs.pojo.entities.CollectionNestedPojoModel in project mongo-java-driver by mongodb.

the class PojoTestCase method getCollectionNestedPojoModel.

private static CollectionNestedPojoModel getCollectionNestedPojoModel(final boolean useNulls) {
    List<SimpleModel> listSimple;
    Set<SimpleModel> setSimple;
    Map<String, SimpleModel> mapSimple;
    if (useNulls) {
        listSimple = null;
        setSimple = null;
        mapSimple = null;
    } else {
        SimpleModel simpleModel = getSimpleModel();
        listSimple = singletonList(simpleModel);
        setSimple = new HashSet<SimpleModel>(listSimple);
        mapSimple = new HashMap<String, SimpleModel>();
        mapSimple.put("s", simpleModel);
    }
    List<List<SimpleModel>> listListSimple = singletonList(listSimple);
    Set<Set<SimpleModel>> setSetSimple = new HashSet<Set<SimpleModel>>(singletonList(setSimple));
    Map<String, Map<String, SimpleModel>> mapMapSimple = new HashMap<String, Map<String, SimpleModel>>();
    mapMapSimple.put("ms", mapSimple);
    Map<String, List<SimpleModel>> mapListSimple = new HashMap<String, List<SimpleModel>>();
    mapListSimple.put("ls", listSimple);
    Map<String, List<Map<String, SimpleModel>>> mapListMapSimple = new HashMap<String, List<Map<String, SimpleModel>>>();
    mapListMapSimple.put("lm", singletonList(mapSimple));
    Map<String, Set<SimpleModel>> mapSetSimple = new HashMap<String, Set<SimpleModel>>();
    mapSetSimple.put("s", setSimple);
    List<Map<String, SimpleModel>> listMapSimple = singletonList(mapSimple);
    List<Map<String, List<SimpleModel>>> listMapListSimple = singletonList(mapListSimple);
    List<Map<String, Set<SimpleModel>>> listMapSetSimple = singletonList(mapSetSimple);
    return new CollectionNestedPojoModel(listSimple, listListSimple, setSimple, setSetSimple, mapSimple, mapMapSimple, mapListSimple, mapListMapSimple, mapSetSimple, listMapSimple, listMapListSimple, listMapSetSimple);
}
Also used : SimpleModel(org.bson.codecs.pojo.entities.SimpleModel) Set(java.util.Set) HashSet(java.util.HashSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) CollectionNestedPojoModel(org.bson.codecs.pojo.entities.CollectionNestedPojoModel) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CollectionNestedPojoModel (org.bson.codecs.pojo.entities.CollectionNestedPojoModel)1 SimpleModel (org.bson.codecs.pojo.entities.SimpleModel)1