Project

General

Profile

Download (3.16 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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.strategy;
10

    
11
import java.io.Serializable;
12
import java.util.Collection;
13
import java.util.UUID;
14

    
15
import org.apache.commons.lang3.StringUtils;
16
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
17
import org.joda.time.DateTime;
18

    
19
import eu.etaxonomy.cdm.common.CdmUtils;
20
import eu.etaxonomy.cdm.common.DOI;
21
import eu.etaxonomy.cdm.common.URI;
22
import eu.etaxonomy.cdm.model.agent.Contact;
23
import eu.etaxonomy.cdm.model.agent.ORCID;
24
import eu.etaxonomy.cdm.model.common.CdmBase;
25
import eu.etaxonomy.cdm.model.common.ExternallyManaged;
26
import eu.etaxonomy.cdm.model.common.LSID;
27
import eu.etaxonomy.cdm.model.common.TimePeriod;
28
import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod;
29

    
30
public abstract class StrategyBase
31
        implements IStrategy, Serializable {
32

    
33
    private static final long serialVersionUID = -274791080847215663L;
34
	@SuppressWarnings("unused")
35
	private static final Logger logger = LogManager.getLogger(StrategyBase.class);
36

    
37
	abstract protected UUID getUuid();
38

    
39
// ************************** CONSTRUCTOR ********************************/
40

    
41
	protected StrategyBase(){}
42

    
43
// ************************* METHODS  ****************************************/
44
	/**
45
	 * @param fieldType
46
	 * @return
47
	 */
48
	protected static boolean isCollection(Class<?> fieldType) {
49
		if (Collection.class.isAssignableFrom(fieldType) ){
50
			return true;
51
		}else{
52
			return false;
53
		}
54
	}
55

    
56
	protected boolean isPrimitive(Class<?> fieldType) {
57
		if (fieldType.isPrimitive()){
58
			return true;
59
		}else{
60
			return false;
61
		}
62
	}
63

    
64
	protected boolean isSingleCdmBaseObject(Class<?> fieldType) {
65
		if (CdmBase.class.isAssignableFrom(fieldType)){
66
			return true;
67
		}else{
68
			return false;
69
		}
70
	}
71

    
72
	protected boolean isUserType(Class<?> fieldType) {
73
		if (	fieldType == TimePeriod.class ||
74
		        fieldType == VerbatimTimePeriod.class ||
75
                fieldType == DateTime.class ||
76
				fieldType == LSID.class ||
77
				fieldType == Contact.class ||
78
				fieldType == URI.class ||
79
				fieldType == DOI.class ||
80
				fieldType == ORCID.class ||
81
		        fieldType == ExternallyManaged.class
82
			){
83
				return true;
84
		}else{
85
			return false;
86
		}
87
	}
88

    
89
	/**
90
	 * Null safe string. Returns the given string if it is not <code>null</code>.
91
	 * Empty string otherwise.
92
	 * @see CdmUtils#Nz(String)
93
	 * @return the null-safe string
94
	 */
95
	protected String Nz(String str){
96
		return CdmUtils.Nz(str);
97
	}
98

    
99
	/**
100
	 * Checks if a string is not blank.
101
	 * @see StringUtils#isNotBlank(String)
102
	 */
103
	protected boolean isNotBlank(String str){
104
		return StringUtils.isNotBlank(str);
105
	}
106

    
107
	/**
108
	 * Checks if a string is blank.
109
	 * @see StringUtils#isNotBlank(String)
110
	 */
111
	protected static boolean isBlank(String str){
112
		return StringUtils.isBlank(str);
113
	}
114

    
115
	protected String removeTrailingDots(String str){
116
	    return CdmUtils.removeTrailingDots(str);
117
	}
118
}
(2-2/2)