1
|
/**
|
2
|
* Copyright (C) 2021 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 com.github.dozermapper.core.DozerConverter;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
14
|
import eu.etaxonomy.cdm.remote.dto.tdwg.voc.TaxonRelationshipTerm;
|
15
|
|
16
|
/**
|
17
|
* @author a.mueller
|
18
|
* @since 05.02.2021
|
19
|
*/
|
20
|
public class ConstantConverter extends DozerConverter<CdmBase,Object> {
|
21
|
|
22
|
final static String TAX_INCLUDED = "taxIncluded";
|
23
|
|
24
|
public ConstantConverter() {
|
25
|
super(CdmBase.class, Object.class);
|
26
|
}
|
27
|
|
28
|
@Override
|
29
|
public Object convertTo(CdmBase source, Object destination) {
|
30
|
if (TAX_INCLUDED.equals(this.getParameter())){
|
31
|
TaxonRelationshipTerm result = new TaxonRelationshipTerm();
|
32
|
result.setTitle("is taxonomically included in");
|
33
|
return result;
|
34
|
}else{
|
35
|
return this.getParameter();
|
36
|
}
|
37
|
}
|
38
|
|
39
|
@Override
|
40
|
public CdmBase convertFrom(Object source, CdmBase destination) {
|
41
|
throw new RuntimeException("ConstantConverter should be used one-way only");
|
42
|
}
|
43
|
|
44
|
|
45
|
}
|