Examples of ConverterFactory


Examples of com.basho.riak.client.api.convert.ConverterFactory

{
   
    @Before
    public void setup()
    {
        ConverterFactory factory = ConverterFactory.getInstance();
        factory.unregisterConverterForClass(Pojo.class);
        //factory.setDefaultConverter(JSONConverter.class);
    }
View Full Code Here

Examples of com.basho.riak.client.api.convert.ConverterFactory

    }
   
    @Test
    public void getDefaultConverter()
    {
        ConverterFactory factory = ConverterFactory.getInstance();
        //TypeReference tr = new TypeReference<Pojo>(){};
        Converter<Pojo> converter = factory.getConverter(Pojo.class);
       
        assertTrue(converter instanceof JSONConverter);
   
        Pojo pojo = new Pojo();
        pojo.foo = "foo_value";
View Full Code Here

Examples of com.basho.riak.client.api.convert.ConverterFactory

    }
   
    @Test
    public void stringConverter()
    {
        ConverterFactory factory = ConverterFactory.getInstance();
        Converter<String> converter = factory.getConverter(String.class);
       
        assertTrue(converter instanceof StringConverter);
    }
View Full Code Here

Examples of com.basho.riak.client.api.convert.ConverterFactory

    }
   
    @Test
    public void riakObjectConverter()
    {
        ConverterFactory factory = ConverterFactory.getInstance();
        Converter<RiakObject> converter = factory.getConverter(RiakObject.class);
       
        assertTrue(converter instanceof PassThroughConverter);
       
        RiakObject o = new RiakObject();
       
View Full Code Here

Examples of com.basho.riak.client.api.convert.ConverterFactory

    }
    
    @Test
    public void registerConverterClass()
    {
        ConverterFactory factory = ConverterFactory.getInstance();
        factory.registerConverterForClass(Pojo.class, new MyConverter());
       
        Converter<Pojo> converter = factory.getConverter(Pojo.class);
       
        assertTrue(converter instanceof MyConverter);
       
    }
View Full Code Here

Examples of com.basho.riak.client.api.convert.ConverterFactory

    }
   
    @Test
    public void registerConverterInstance()
    {
        ConverterFactory factory = ConverterFactory.getInstance();
        MyConverter converter = new MyConverter();
        factory.registerConverterForClass(Pojo.class, converter);
       
        Converter<Pojo> converter2 = factory.getConverter(Pojo.class);
        assertTrue(converter2 instanceof MyConverter);
        assertEquals(converter, converter2);
       
       
    }
View Full Code Here

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

Examples of ma.glasnost.orika.converter.ConverterFactory

        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

Examples of ma.glasnost.orika.converter.ConverterFactory

        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

Examples of ma.glasnost.orika.converter.ConverterFactory

   
    @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
Copyright © 2018 www.massapi.com. 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.