Project

General

Profile

Download (2.18 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

    
10
package eu.etaxonomy.cdm.io.common.mapping;
11

    
12
import java.util.ArrayList;
13
import java.util.HashSet;
14
import java.util.List;
15
import java.util.Set;
16

    
17
import org.apache.logging.log4j.LogManager;
18
import org.apache.logging.log4j.Logger;
19

    
20
/**
21
 * Mapper base class mapping a single source attribute to a single destination attribute.
22
 *
23
 * @author a.mueller
24
 * @since 05.08.2008
25
 */
26
public abstract class CdmSingleAttributeMapperBase extends CdmAttributeMapperBase{
27

    
28
	@SuppressWarnings("unused")
29
	private static final Logger logger = LogManager.getLogger();
30

    
31
	private String sourceValue;
32
	private String destinationValue;
33
	protected Object defaultValue;
34

    
35
	protected CdmSingleAttributeMapperBase(String sourceAttributString, String destinationAttributeString){
36
		this(sourceAttributString, destinationAttributeString, null);
37
	}
38

    
39
	protected CdmSingleAttributeMapperBase(String sourceAttributString, String destinationAttributeString, Object defaultValue){
40
		this.sourceValue = sourceAttributString;
41
		this.destinationValue = destinationAttributeString;
42
		this.defaultValue = defaultValue;
43
	}
44

    
45
	public String getSourceAttribute(){
46
		return sourceValue;
47
	}
48

    
49
	public String getDestinationAttribute(){
50
		return destinationValue;
51
	}
52

    
53
	@Override
54
	public Set<String> getSourceAttributes(){
55
		Set<String>  result = new HashSet<>();
56
		result.add(sourceValue);
57
		return result;
58
	}
59

    
60
	@Override
61
	public Set<String> getDestinationAttributes(){
62
		Set<String> result = new HashSet<>();
63
		if(destinationValue != null){
64
			result.add(destinationValue);
65
		}
66
		return result;
67
	}
68

    
69
	@Override
70
	public List<String> getSourceAttributeList(){
71
		List<String> result = new ArrayList<>();
72
		result.add(sourceValue);
73
		return result;
74
	}
75

    
76
	@Override
77
	public List<String> getDestinationAttributeList(){
78
		List<String> result = new ArrayList<>();
79
		if(destinationValue != null){
80
			result.add(destinationValue);
81
		}
82
		return result;
83
	}
84

    
85
	@SuppressWarnings("rawtypes")
86
    public abstract Class getTypeClass();
87
}
(4-4/53)