Package org.mongolink.domain.converter

Examples of org.mongolink.domain.converter.Converter


    @Test
    public void canGetConverterForBasicType() {
        final MapperContext context = new MapperContext();

        Converter converter = context.converterFor(String.class);

        assertThat(converter, notNullValue());
    }
View Full Code Here


    public void canGetConverterForComponent() {
        final MapperContext context = new MapperContext();
        final CommentMapping mapping = new CommentMapping();
        mapping.buildMapper(context);

        final Converter converter = context.converterFor(Comment.class);

        assertThat(converter, notNullValue());
        assertThat(converter, instanceOf(ComponentMapper.class));
    }
View Full Code Here

    protected String getField() {
        return field;
    }

    protected Object getDBValue(Object value) {
        final Converter converter = Converter.forType(value.getClass());
        return converter.toDbValue(value);
    }
View Full Code Here

    public void populate(Object instance, DBObject from) {
        try {
            Field field = Fields.find(instance.getClass(), name());
            field.setAccessible(true);
            ParameterizedType elementType = (ParameterizedType) field.getGenericType();
            Converter childMapper = context().converterFor((Class<?>) elementType.getActualTypeArguments()[0]);
            BasicDBList list = (BasicDBList) from.get(name());
            if (list != null) {
                Collection collection = (Collection) field.get(instance);
                for (Object o : list) {
                    //noinspection unchecked
                    collection.add(childMapper.fromDbValue(o));
                }
            }
            field.setAccessible(false);
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
View Full Code Here

TOP

Related Classes of org.mongolink.domain.converter.Converter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.