Project

General

Profile

Download (1.29 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 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.remote.dto.assembler.converter;
10

    
11
import java.net.URI;
12
import java.net.URISyntaxException;
13

    
14
import com.github.dozermapper.core.CustomConverter;
15
import com.github.dozermapper.core.MappingException;
16

    
17
import eu.etaxonomy.cdm.model.common.LSID;
18

    
19
/**
20
 * @author ben.clark
21
 * @since 2009-02-25
22
 */
23
public class LsidConverter implements CustomConverter {
24

    
25
	@Override
26
    public Object convert(Object destination, Object source, Class<?> destClass, Class<?> sourceClass) {
27
		if (source == null || ((LSID)source).toString() == null || ((LSID)source).toString().equals("")) {
28
			return null;
29
		}
30
		if (source instanceof LSID) {
31
				try {
32
					return new URI(((LSID)source).getLsid());
33
				} catch (URISyntaxException e) {
34
					throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
35
							+ destination + " and " + source);
36
				}
37
		} else {
38
			throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
39
					+ destination + " and " + source);
40
		}
41
	}
42
}
(6-6/11)