Project

General

Profile

Download (2.82 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.time.ZonedDateTime;
15
import java.util.Collection;
16
import java.util.UUID;
17

    
18
import org.apache.commons.lang.StringUtils;
19
import org.apache.log4j.Logger;
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.common.CdmBase;
25
import eu.etaxonomy.cdm.model.common.LSID;
26
import eu.etaxonomy.cdm.model.common.TimePeriod;
27

    
28

    
29
public abstract class StrategyBase implements IStrategy, Serializable {
30
	private static final long serialVersionUID = -274791080847215663L;
31
	@SuppressWarnings("unused")
32
	private static final Logger logger = Logger.getLogger(StrategyBase.class);
33

    
34
	abstract protected UUID getUuid();
35

    
36
// ************************** CONSTRUCTOR ********************************/
37

    
38
	protected StrategyBase(){}
39

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

    
53
	/**
54
	 * @param fieldType
55
	 * @return
56
	 */
57
	protected boolean isPrimitive(Class<?> fieldType) {
58
		if (fieldType.isPrimitive()){
59
			return true;
60
		}else{
61
			return false;
62
		}
63
	}
64

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

    
77
	/**
78
	 * @param fieldType
79
	 * @return
80
	 */
81
	protected boolean isUserType(Class<?> fieldType) {
82
		if (	fieldType == TimePeriod.class ||
83
				fieldType == ZonedDateTime.class ||
84
				fieldType == LSID.class ||
85
				fieldType == Contact.class ||
86
				fieldType == URI.class ||
87
				fieldType == DOI.class
88
			){
89
				return true;
90
		}else{
91
			return false;
92
		}
93
	}
94

    
95

    
96
	/**
97
	 * Null safe string. Returns the given string if it is not <code>null</code>.
98
	 * Empty string otherwise.
99
	 * @see CdmUtils#Nz(String)
100
	 * @return the null-safe string
101
	 */
102
	protected String Nz(String str){
103
		return CdmUtils.Nz(str);
104
	}
105

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

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

    
122
}
(2-2/2)