Spring Framework GenericConversionService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework GenericConversionService class.

This code example shows how to use the following methods:addConverter
        private final PropertyConverter propertyConverter;
 
        public GenericNodePropertyFieldAccessor(Neo4jPersistentProperty property,
                                                Neo4jTemplate template) {
            super(template, property);
            GenericConversionService genericConversionService = new GenericConversionService();
            genericConversionService.addConverter(new GenericObjectToObjectConverter());
            this.propertyConverter = new PropertyConverter(genericConversionService,property);
        } 
 
        @Override 
        public Object setValue(final Object entity, final Object newVal, MappingPolicy mappingPolicy) {
            Object value = propertyConverter.serializeIfNotBuiltIn(newVal);
            super.setValue(entity, value, mappingPolicy);
            return newVal;
        } 
 
        @Override 
        public Object doGetValue(final Object entity) {
            Object value = super.doGetValue(entity);
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:convert
 
@Test
public class ConvertTest { 
 
  public void testSpring() { 
    DefaultConversionService conversion = new DefaultConversionService();
    Assert.assertEquals(conversion.convert("4.5", Number.class), new BigDecimal("4.5"));
     
    Assert.assertEquals((boolean)conversion.convert("true", boolean.class), true);
  } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addConverter, GenericConversionService.addConverter
    public void setUp() throws Exception {
        somePatientID = new Identifiable("id1", new AssigningAuthority("1.3"));
        someData = SampleData.createDataHandler();
        docEntry = SampleData.createDocumentEntry(somePatientID);
 
        GenericConversionService conversionService = new GenericConversionService();
        conversionService.addConverter(new DataHandlerToByteArrayConverter());
        conversionService.addConverter(new ByteArrayToStringConverter());
        conversionService.addConverter(new ByteArrayToClinicalDocumentConverter());
        conversionService.addConverter(new ByteArrayToDomConverter());
        Document.setConversionService(conversionService);
    } 
 
    @Test
    public final void constructor() { 
        Document doc = new Document(docEntry, someData);
        assertTrue(someData.equals(doc.getContent(DataHandler.class)));
    } 
     
    @Test
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addConverter, addConverterFactory, GenericConversionService.addConverter
	// TODO: Refactor to extend ConvSFB instead, so we get the default converters  
	@Override 
	public void afterPropertiesSet() throws Exception {
 
		// simple attributes 
		addConverter(new StringToRefConverter());
		addConverter(new RefToStringConverter());
		 
		addConverter(new StringToUuidConverter());
		addConverter(new UuidToStringConverter());
 
		addConverter(new AttrToBooleanConverter());
		addConverter(new BooleanToAttrConverter());
 
		addConverter(new AttrToFloatConverter());
		addConverter(new FloatToAttrConverter());
 
		addConverter(new EnumExclusiveValueToStringConverter(attrDefinitionService));
		addConverter(new EnumAttributeToEnumExclusiveValueConverter(attrDefinitionService));
 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
public class SpringPropertyProxyCreationTests { 
 
    @Test 
    public void defaultConstructorObject() { 
        PropertyProxy result = SpringPropertyProxy.proxyFor(Person.class, false, new GenericConversionService()); 
        assertEquals(SpringPropertyProxy.class, result.getClass()); 
    } 
 
    @Test 
    public void testEnum() { 
        PropertyProxy result = SpringPropertyProxy.proxyFor(MaritalStatus.class, false, new GenericConversionService()); 
        assertEquals(SpringPropertyProxy.class, result.getClass()); 
    } 
 
    @Test 
    public void amfCreatorAnnotatedImmutableObject() { 
        PropertyProxy result = SpringPropertyProxy.proxyFor(ImmutableValueObject.class, false, new GenericConversionService()); 
        assertEquals(SpringPropertyProxy.DelayedWriteSpringPropertyProxy.class, result.getClass()); 
    } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:canConvert, convert
    private String getParameterWithIndex(ParametersParameterAccessor accessor, int index) {
        Object parameter = accessor.getBindableValue(index);
        if (parameter == null) {
            return "null"; 
        } 
        if (conversionService.canConvert(parameter.getClass(), String.class)) {
            return conversionService.convert(parameter, String.class);
        } 
        return parameter.toString();
    } 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addConverter
    protected void configureConverters(ConverterRegistry registry) {
        //default no-op 
    } 
     
    private ConversionService getDefaultConversionService() {
        GenericConversionService conversionService = new GenericConversionService();
        configureConverters(conversionService);
        conversionService.addConverter(new NumberConverter());
        return conversionService;
    } 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addConverter
 
        prePopulateWithNameConverter(); 
    } 
 
    private void prePopulateWithNameConverter() { 
        conversionService.addConverter(new StringToNameConverter());
    } 
 
    @Override 
    public boolean canConvert(Class<?> fromClass, String syntax, Class<?> toClass) {
        return conversionService.canConvert(fromClass, toClass);
    } 
 
    @Override 
    public <T> T convert(Object source, String syntax, Class<T> toClass) {
        return conversionService.convert(source, toClass);
    } 
 
    public final static class NameToStringConverter 
            implements org.springframework.core.convert.converter.Converter<Name, String> {
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:convert
    /** 
     * Test to prove that Jadira Convert can be invoked via Spring 
     */ 
    @Test
    public void testBindingConverter() { 
        assertEquals(new SubjectC("String"), svc.convert("String:String", SubjectC.class));
    } 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:canConvert
	 * @param sourceType 
	 * @param targetType 
	 * @return true if sourceType can be converted into targetType 
	 */ 
	protected boolean canConvert(Class<?> sourceType, Class<?> targetType) {
		return this.conversionService.canConvert(sourceType, targetType);
	} 
 
	/** 
	 * Convert given object into target type 
	 *  
	 * @param source 
	 * @param targetType 
	 * @return 
	 */ 
	protected <T> T convert(Object source, Class<T> targetType) {
		return this.conversionService.convert(source, targetType);
	} 
 
	@Override 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework GenericConversionService Methods: