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.out;
|
11
|
|
12
|
import java.sql.Types;
|
13
|
|
14
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
15
|
|
16
|
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
|
17
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
18
|
|
19
|
/**
|
20
|
* Mapper for a fixed integer value.
|
21
|
*
|
22
|
* TODO deduplicate with {@link DbConstantMapper}
|
23
|
*
|
24
|
* @author a.mueller
|
25
|
* @since 28.09.2019
|
26
|
*/
|
27
|
public class DbFixedIntegerMapper
|
28
|
extends DbSingleAttributeExportMapperBase<DbExportStateBase<?, IExportTransformer>> {
|
29
|
|
30
|
@SuppressWarnings("unused")
|
31
|
private static final Logger logger = LogManager.getLogger(DbFixedIntegerMapper.class);
|
32
|
|
33
|
private Integer fixInteger;
|
34
|
|
35
|
public static DbFixedIntegerMapper NewInstance(Integer fixInteger, String dbAttributeString){
|
36
|
return new DbFixedIntegerMapper(fixInteger, dbAttributeString);
|
37
|
}
|
38
|
|
39
|
private DbFixedIntegerMapper(Integer fixInteger, String dbAttributeString) {
|
40
|
super(null, dbAttributeString, fixInteger, true, false);
|
41
|
this.fixInteger = fixInteger;
|
42
|
}
|
43
|
|
44
|
@Override
|
45
|
protected Object getValue(CdmBase cdmBase) {
|
46
|
return fixInteger;
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
protected int getSqlType() {
|
51
|
return Types.INTEGER;
|
52
|
}
|
53
|
|
54
|
@Override
|
55
|
public Class<?> getTypeClass() {
|
56
|
return Integer.class;
|
57
|
}
|
58
|
}
|