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.lang.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.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
|
final static UUID uuid = UUID.fromString("2ff2b1d6-17a6-4807-a55f-f6b45bf429b7");
|
35
|
|
36
|
abstract protected UUID getUuid();
|
37
|
|
38
|
protected StrategyBase(){
|
39
|
}
|
40
|
|
41
|
|
42
|
|
43
|
|
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 == DateTime.class ||
|
87
|
fieldType == LSID.class ||
|
88
|
fieldType == Contact.class ||
|
89
|
fieldType == URI.class ||
|
90
|
fieldType == DOI.class
|
91
|
){
|
92
|
return true;
|
93
|
}else{
|
94
|
return false;
|
95
|
}
|
96
|
}
|
97
|
|
98
|
|
99
|
/**
|
100
|
* Null safe string. Returns the given string if it is not <code>null</code>.
|
101
|
* Empty string otherwise.
|
102
|
* @see CdmUtils#Nz(String)
|
103
|
* @return the null-safe string
|
104
|
*/
|
105
|
protected String Nz(String str){
|
106
|
return CdmUtils.Nz(str);
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* Checks if a string is not blank.
|
111
|
* @see StringUtils#isNotBlank(String)
|
112
|
*/
|
113
|
protected boolean isNotBlank(String str){
|
114
|
return StringUtils.isNotBlank(str);
|
115
|
}
|
116
|
|
117
|
/**
|
118
|
* Checks if a string is blank.
|
119
|
* @see StringUtils#isNotBlank(String)
|
120
|
*/
|
121
|
protected boolean isBlank(String str){
|
122
|
return StringUtils.isBlank(str);
|
123
|
}
|
124
|
|
125
|
|
126
|
|
127
|
}
|