Project

General

Profile

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

    
10
package eu.etaxonomy.cdm.strategy;
11

    
12
import java.io.Serializable;
13
import java.net.URI;
14
import java.util.Collection;
15
import java.util.UUID;
16

    
17
import org.apache.commons.lang3.StringUtils;
18
import org.apache.log4j.Logger;
19
import org.joda.time.DateTime;
20

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

    
31

    
32
public abstract class StrategyBase implements IStrategy, Serializable {
33
	private static final long serialVersionUID = -274791080847215663L;
34
	@SuppressWarnings("unused")
35
	private static final Logger logger = Logger.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
	/**
57
	 * @param fieldType
58
	 * @return
59
	 */
60
	protected boolean isPrimitive(Class<?> fieldType) {
61
		if (fieldType.isPrimitive()){
62
			return true;
63
		}else{
64
			return false;
65
		}
66
	}
67

    
68
	/**
69
	 * @param fieldType
70
	 * @return
71
	 */
72
	protected boolean isSingleCdmBaseObject(Class<?> fieldType) {
73
		if (CdmBase.class.isAssignableFrom(fieldType)){
74
			return true;
75
		}else{
76
			return false;
77
		}
78
	}
79

    
80
	/**
81
	 * @param fieldType
82
	 * @return
83
	 */
84
	protected boolean isUserType(Class<?> fieldType) {
85
		if (	fieldType == TimePeriod.class ||
86
		        fieldType == VerbatimTimePeriod.class ||
87
                fieldType == DateTime.class ||
88
				fieldType == LSID.class ||
89
				fieldType == Contact.class ||
90
				fieldType == URI.class ||
91
				fieldType == DOI.class ||
92
				fieldType == ORCID.class ||
93
		        fieldType == ExternallyManaged.class
94
			){
95
				return true;
96
		}else{
97
			return false;
98
		}
99
	}
100

    
101

    
102
	/**
103
	 * Null safe string. Returns the given string if it is not <code>null</code>.
104
	 * Empty string otherwise.
105
	 * @see CdmUtils#Nz(String)
106
	 * @return the null-safe string
107
	 */
108
	protected String Nz(String str){
109
		return CdmUtils.Nz(str);
110
	}
111

    
112
	/**
113
	 * Checks if a string is not blank.
114
	 * @see StringUtils#isNotBlank(String)
115
	 */
116
	protected boolean isNotBlank(String str){
117
		return StringUtils.isNotBlank(str);
118
	}
119

    
120
	/**
121
	 * Checks if a string is blank.
122
	 * @see StringUtils#isNotBlank(String)
123
	 */
124
	protected boolean isBlank(String str){
125
		return StringUtils.isBlank(str);
126
	}
127

    
128
}
(2-2/2)