Package ma.glasnost.orika.converter

Examples of ma.glasnost.orika.converter.ConverterFactory


   
    @Test
    public void testDateToString() {
        MapperFactory factory = MappingUtil.getMapperFactory();
       
        ConverterFactory converterFactory = factory.getConverterFactory();
        converterFactory.registerConverter("dateConverter1", new DateToStringConverter("dd/MM/yyyy"));
        converterFactory.registerConverter("dateConverter2", new DateToStringConverter("dd-MM-yyyy"));
       
        factory.registerClassMap(ClassMapBuilder.map(A.class, B.class).fieldMap("date").converter("dateConverter1").add().toClassMap());
        factory.registerClassMap(ClassMapBuilder.map(A.class, C.class).fieldMap("date").converter("dateConverter2").add().toClassMap());
       
        factory.build();
View Full Code Here


        mapperFactory.registerConcreteType(new TypeBuilder<List<Address>>(){}.build(),
                                           new TypeBuilder<ArrayList<Address>>(){}.build());
        mapperFactory.registerConcreteType(new TypeBuilder<List<AddressDTO>>(){}.build(),
                                           new TypeBuilder<ArrayList<AddressDTO>>(){}.build());

        ConverterFactory converterFactory = mapperFactory.getConverterFactory();
        //Add converters...
       
        mapperFactory.registerClassMap(mapperFactory.classMap(ManufacturingFacility.class, ManufacturingFacilityDTS.class )
                                .fieldMap("description" , "manufacturingfacility.description").add()
                                .fieldMap("addresses","addressL").add()
View Full Code Here

        return out.toString();
    }
   
    private Converter<Object, Object> getConverter(FieldMap fieldMap, String converterId) {
        Converter<Object, Object> converter = null;
        ConverterFactory converterFactory = mapperFactory.getConverterFactory();
        if (converterId != null) {
            converter = converterFactory.getConverter(converterId);
        } else {
            converter = converterFactory.getConverter(fieldMap.getSource().getType(), fieldMap.getDestination().getType());
        }
        return converter;
    }
View Full Code Here

   
    @SuppressWarnings("unchecked")
    public <S, D> D convert(S source, Type<S> sourceType, Type<D> destinationType, String converterId) {
       
        Converter<S, D> converter;
        ConverterFactory converterFactory = mapperFactory.getConverterFactory();
        if (converterId == null) {
            final Type<? extends Object> sourceClass = normalizeSourceType(source, sourceType, destinationType);
            converter = (Converter<S, D>) converterFactory.getConverter(sourceClass, destinationType);
        } else {
            converter = (Converter<S, D>) converterFactory.getConverter(converterId);
        }
       
        return converter.convert(source, destinationType);
    }
View Full Code Here

TOP

Related Classes of ma.glasnost.orika.converter.ConverterFactory

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.