blob: d3e2540b57ab532f4cf4ce7e5cf4ae397d1c9453 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*
@VaadinApache2LicenseForJavaFiles@
*/
package com.vaadin.data.util.converter;
import java.util.Locale;
/**
* A converter that wraps another {@link Converter} and reverses source and
* target types.
*
* @param <SOURCE>
* The source type
* @param <TARGET>
* The target type
*
* @author Vaadin Ltd
* @version
* @VERSION@
* @since 7.0
*/
public class ReverseConverter<SOURCE, TARGET> implements
Converter<SOURCE, TARGET> {
private Converter<TARGET, SOURCE> realConverter;
/**
* Creates a converter from source to target based on a converter that
* converts from target to source.
*
* @param converter
* The converter to use in a reverse fashion
*/
public ReverseConverter(Converter<TARGET, SOURCE> converter) {
this.realConverter = converter;
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java
* .lang.Object, java.util.Locale)
*/
public SOURCE convertFromTargetToSource(TARGET value, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return realConverter.convertFromSourceToTarget(value, locale);
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java
* .lang.Object, java.util.Locale)
*/
public TARGET convertFromSourceToTarget(SOURCE value, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return realConverter.convertFromTargetToSource(value, locale);
}
/*
* (non-Javadoc)
*
* @see com.vaadin.data.util.converter.Converter#getSourceType()
*/
public Class<SOURCE> getSourceType() {
return realConverter.getTargetType();
}
/*
* (non-Javadoc)
*
* @see com.vaadin.data.util.converter.Converter#getTargetType()
*/
public Class<TARGET> getTargetType() {
return realConverter.getSourceType();
}
}
|