Package org.springframework.core.convert.converter

Examples of org.springframework.core.convert.converter.ConverterRegistry.addConverter()


            }
            else {
                converterRegistry = (ConverterRegistry)existingConversionService;
            }

            converterRegistry.addConverter(new Converter<GrailsApplication, org.codehaus.groovy.grails.commons.GrailsApplication>() {
                @Override
                public org.codehaus.groovy.grails.commons.GrailsApplication convert(GrailsApplication source) {
                    return new LegacyGrailsApplication(source);
                }
            });
View Full Code Here


                @Override
                public org.codehaus.groovy.grails.commons.GrailsApplication convert(GrailsApplication source) {
                    return new LegacyGrailsApplication(source);
                }
            });
            converterRegistry.addConverter(new Converter<ConfigMap.NullSafeNavigator, Object>() {
                @Override
                public Object convert(ConfigMap.NullSafeNavigator source) {
                    return null;
                }
            });
View Full Code Here

  }

  @Test
  public void testSpr7766() throws Exception {
    ConverterRegistry registry = (conversionService);
    registry.addConverter(new ColorConverter());
    List<Color> colors = (List<Color>) conversionService.convert(new String[] { "ffffff", "#000000" }, TypeDescriptor.valueOf(String[].class), new TypeDescriptor(new MethodParameter(getClass().getMethod("handlerMethod", List.class), 0)));
    assertEquals(2, colors.size());
    assertEquals(Color.WHITE, colors.get(0));
    assertEquals(Color.BLACK, colors.get(1));
  }
View Full Code Here

        @Override
        protected ConversionService neo4jConversionService() throws Exception {
            ConverterRegistry converterRegistry = (ConverterRegistry) super.neo4jConversionService();

            converterRegistry.addConverter(new Converter<CustomType, String>() {
                @Override
                public String convert(CustomType source) {
                    return source.value + " encoded using string";
                }
            });
View Full Code Here

                @Override
                public String convert(CustomType source) {
                    return source.value + " encoded using string";
                }
            });
            converterRegistry.addConverter(new Converter<String, CustomType>() {
                @Override
                public CustomType convert(String source) {
                    return new CustomType(source + " decoded using string");
                }
            });
View Full Code Here

                public CustomType convert(String source) {
                    return new CustomType(source + " decoded using string");
                }
            });

            converterRegistry.addConverter(new Converter<CustomType, byte[]>() {
                @Override
                public byte[] convert(CustomType source) {
                    return (source.value + " encoded using byte array").getBytes();
                }
            });
View Full Code Here

                @Override
                public byte[] convert(CustomType source) {
                    return (source.value + " encoded using byte array").getBytes();
                }
            });
            converterRegistry.addConverter(new Converter<byte[], CustomType>() {
                @Override
                public CustomType convert(byte[] source) {
                    return new CustomType(new String(source) + " decoded using byte array");
                }
            });
View Full Code Here

    }

    public void addConverters(ConversionService service) {
        if (service instanceof ConverterRegistry) {
            ConverterRegistry registry = (ConverterRegistry) service;
            registry.addConverter(new DateToStringConverter());
            registry.addConverter(new DateToLongConverter());
            registry.addConverter(new StringToDateConverter());
            registry.addConverter(new NumberToDateConverter());
            registry.addConverter(new EnumToStringConverter());
            registry.addConverter(new EnumToIntegerConverter());
View Full Code Here

    public void addConverters(ConversionService service) {
        if (service instanceof ConverterRegistry) {
            ConverterRegistry registry = (ConverterRegistry) service;
            registry.addConverter(new DateToStringConverter());
            registry.addConverter(new DateToLongConverter());
            registry.addConverter(new StringToDateConverter());
            registry.addConverter(new NumberToDateConverter());
            registry.addConverter(new EnumToStringConverter());
            registry.addConverter(new EnumToIntegerConverter());
            registry.addConverter(new ShapeToStringConverter());
View Full Code Here

    public void addConverters(ConversionService service) {
        if (service instanceof ConverterRegistry) {
            ConverterRegistry registry = (ConverterRegistry) service;
            registry.addConverter(new DateToStringConverter());
            registry.addConverter(new DateToLongConverter());
            registry.addConverter(new StringToDateConverter());
            registry.addConverter(new NumberToDateConverter());
            registry.addConverter(new EnumToStringConverter());
            registry.addConverter(new EnumToIntegerConverter());
            registry.addConverter(new ShapeToStringConverter());
            registry.addConverter(new StringToShapeConverter());
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.