1
|
/**
|
2
|
* Copyright (C) 2017 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.vaadin.util.converter;
|
10
|
|
11
|
import java.util.Locale;
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import com.vaadin.data.util.converter.Converter;
|
15
|
|
16
|
/**
|
17
|
* @author freimeier
|
18
|
* @date 21.11.2017
|
19
|
*
|
20
|
*/
|
21
|
abstract class UuidTitleStringConverter implements Converter<String, UUID> {
|
22
|
|
23
|
private static final long serialVersionUID = -8596384308607670542L;
|
24
|
|
25
|
/* (non-Javadoc)
|
26
|
* @see com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang.Object, java.lang.Class, java.util.Locale)
|
27
|
*/
|
28
|
@Override
|
29
|
public abstract String convertToPresentation(UUID value, Class<? extends String> targetType, Locale locale)
|
30
|
throws ConversionException;
|
31
|
|
32
|
/* (non-Javadoc)
|
33
|
* @see com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, java.lang.Class, java.util.Locale)
|
34
|
*/
|
35
|
@Override
|
36
|
public UUID convertToModel(String value, Class<? extends UUID> targetType, Locale locale) throws ConversionException {
|
37
|
/*
|
38
|
* This converter is only used to convert UUIDs into a human readable form.
|
39
|
* The title string might not be unique and therefore can't reliably be converted to an UUID again.
|
40
|
*/
|
41
|
throw new ConversionException("Title string might not be unique and therefore can't be converted to an UUID!");
|
42
|
}
|
43
|
|
44
|
/* (non-Javadoc)
|
45
|
* @see com.vaadin.data.util.converter.Converter#getModelType()
|
46
|
*/
|
47
|
@Override
|
48
|
public Class<UUID> getModelType() {
|
49
|
return UUID.class;
|
50
|
}
|
51
|
|
52
|
/* (non-Javadoc)
|
53
|
* @see com.vaadin.data.util.converter.Converter#getPresentationType()
|
54
|
*/
|
55
|
@Override
|
56
|
public Class<String> getPresentationType() {
|
57
|
return String.class;
|
58
|
}
|
59
|
}
|